Example usage for javax.xml.registry.infomodel ClassificationScheme getObjectType

List of usage examples for javax.xml.registry.infomodel ClassificationScheme getObjectType

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel ClassificationScheme getObjectType.

Prototype

Concept getObjectType() throws JAXRException;

Source Link

Document

Gets the object type that best describes the RegistryObject.

Usage

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

/**
 * This method return the Status after setting the value in Registry Object 
 * /*from  w  w  w.ja v  a 2s.c  o m*/
 * @param none
 * @return String
 */
@SuppressWarnings("unused")
public String doSetClassSchemeOrNode() {
    String status = "failure";
    String node = null;
    String classScheme = null;
    String temp = null;
    String value = null;
    ClassificationScheme classificationScheme = null;
    Concept concept = null;
    String message = null;
    try {
        Collection<?> nodes = SearchPanelBean.getInstance().getClassSchemeSelector().getSelectedNodes();
        if (nodes.size() < 1) {
            append(WebUIResourceBundle.getInstance().getString("selectClassSchemeOrNode"));
        } else {
            // Get first selected node
            // TODO: add attribute to ClassSchemeGraph bean to enforce single 
            // node selection. In this case, user should only be able to 
            // select a single ClassificationNode
            RegistryObjectNode ron = (RegistryObjectNode) nodes.iterator().next();
            RegistryObject registryObject = ron.getRegistryObject();
            if (registryObject instanceof ClassificationScheme) {
                classificationScheme = (ClassificationScheme) registryObject;
                concept = classificationScheme.getObjectType();
            } else {
                concept = (Concept) registryObject;
                classificationScheme = concept.getClassificationScheme();
            }
            value = concept.getValue();
            RegistryObject ro = getCurrentRegistryObjectBean().getRegistryObject();
            if (ro instanceof Classification) {
                boolean external = classificationScheme.isExternal();
                //If the node value is null and the Class scheme in not External 
                //type it will return the control to the error page along 
                //with the message.     
                if (value == null && !external) {
                    append(WebUIResourceBundle.getInstance().getString("selectExternalCSorCN"));
                    status = "showErrorMessage";
                    return status;
                }
                ((Classification) ro).setClassificationScheme(classificationScheme);
                if (external) {
                    concept = null;
                    ((Classification) ro).setConcept(concept);
                    ((Classification) ro).setValue(null);
                } else {
                    ((Classification) ro).setConcept(concept);
                    ((Classification) ro).setValue(value);
                }
            }
            if (ro instanceof ExternalIdentifier) {
                ((ExternalIdentifier) ro).setIdentificationScheme(classificationScheme);
                if (value != null) {
                    ((ExternalIdentifier) ro).setValue(value);
                } else {
                    ((ExternalIdentifier) ro).setValue("");
                }
            }
            if (registryObject instanceof ClassificationScheme) {
                append(WebUIResourceBundle.getInstance().getString("selectNewCSSuccessful"));
            } else {
                append(WebUIResourceBundle.getInstance().getString("selectNewCNSuccessful"));
            }
            SearchPanelBean.getInstance().clearClassSchemeSelector();
            status = "showMessagePage";
        }

    } catch (Exception ex) {
        log.error(WebUIResourceBundle.getInstance()
                .getString("message.ExceptionOccuredWhileSetingClassSchemeOrNode"), ex);
        append(WebUIResourceBundle.getInstance().getString("errorSettingCSorCN") + " "
                + ex.getLocalizedMessage());
    }
    return status;
}