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

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

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel RegistryObject 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.RelationshipBean.java

public void setSourceRegistryObjectName(RegistryObject ro) {
    try {/* w ww .ja  v  a 2s. c o m*/
        sourceRegistryObjectName = ro.getObjectType().getValue();
    } catch (Exception ex) {
        log.error(WebUIResourceBundle.getInstance()
                .getString("message.errorOccuredWhileSettingSourceRegistryObjectNameOperation"), ex);
    }
}

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

public void setTargetRegistryObjectName(RegistryObject ro) {
    try {/*from ww w. j a  v  a2  s . com*/
        targetRegistryObjectName = ro.getObjectType().getValue();
    } catch (Exception ex) {
        log.error(WebUIResourceBundle.getInstance()
                .getString("message.errorOccuredWhileSettingTargetRegistryObjectNameOperation"), ex);
    }
}

From source file:it.cnr.icar.eric.client.ui.common.UIUtility.java

public Concept getCommonObjectType(Collection<?> registryObjects) throws JAXRException {
    Concept commonType = null;/*from  ww  w.ja  v  a 2s  .c om*/
    String commonPath = null;

    Iterator<?> iter = registryObjects.iterator();
    while (iter.hasNext()) {
        RegistryObject ro = (RegistryObject) iter.next();
        if (ro != null) {
            ConceptImpl type = (ConceptImpl) ro.getObjectType();

            String path = null;
            if (ro instanceof ExternalLink) {
                path = commonPath = "/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType
                        + "/RegistryObject/ExternalLink";
            } else {
                path = type.getPath();
            }

            if (commonPath == null) {
                commonPath = path;
            } else {
                if (!(commonPath.equals(path))) {
                    //Determine common base type for both:
                    if (commonPath.startsWith(path + "/")) {
                        //The new type is a baseType of current commonType
                        //Set commonType to new type
                        commonPath = path;
                    } else if (path.startsWith(commonPath + "/")) {
                        //The current commonType is a baseType of new type
                        //Leave commonType unchanged
                        continue;
                    } else {
                        //The current commonType and new type 
                        //do not have an ancestor/descendant relationship
                        //Find a common base type between them.
                        String smallerPath = commonPath;
                        String biggerPath = path;
                        @SuppressWarnings("unused")
                        boolean swap = false;

                        if (commonPath.length() > path.length()) {
                            smallerPath = path;
                            biggerPath = commonPath;
                            swap = true;
                        }

                        int len = smallerPath.length();

                        for (int i = 0; i < len; i++) {
                            if (smallerPath.charAt(i) != biggerPath.charAt(i)) {
                                commonPath = smallerPath.substring(0, smallerPath.lastIndexOf('/', i));

                                break;
                            }
                        }
                    }
                }
            }
        }
    }

    if (commonPath == null) {
        //Use RegistryObject path
        commonPath = "/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType + "/RegistryObject";
    }

    commonType = getBusinessQueryManager().findConceptByPath(commonPath);

    return commonType;
}

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

public RegistryObjectBean(Collection<SearchResultValueBean> searchResultValueBeans,
        RegistryObject registryObject) {
    this(searchResultValueBeans);
    this.registryObject = registryObject;
    if (registryObject != null) {
        try {//from  w w  w.j  ava2s.  co m
            this.id = registryObject.getKey().getId();
        } catch (JAXRException ex) {
            log.warn(WebUIResourceBundle.getInstance()
                    .getString("message.CouldNotGetObjectTypeDefaultToRegistryObject"), ex);
            this.objectType = "RegistryObject";
        }
        try {
            if (nonRegistryObject == null) {
                this.objectType = registryObject.getObjectType().getValue();
                Concept objectTypeConcept = registryObject.getObjectType();

                if (registryObject instanceof Association) {
                    extendedObjectType = ((Association) registryObject).getAssociationType().getKey().getId();
                } else {
                    extendedObjectType = objectTypeConcept.getKey().getId();
                }
                if (registryObject instanceof ExternalLink) {
                    this.objectType = "ExternalLink";
                } else if (objectTypeConcept.getPath()
                        .startsWith("/" + CanonicalSchemes.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType
                                + "/RegistryObject/ExtrinsicObject/")) {
                    this.objectType = "ExtrinsicObject";
                }
            }
        } catch (Throwable t) {
            log.error(WebUIResourceBundle.getInstance()
                    .getString("message.ErrorInConstructingRegistryObjectBean"), t);
        }
    }
}

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

/**
 * This method is used to build the custom error message in case of dangling
 * references for Association Object.This method prepare a list of  messages
 * which is useful to display error message in multiple lines.
 * @param Registry object  //from   w  ww .ja va  2  s.  c  o  m
 * @return void
 */
private void buildAssociationErrorMessage(RegistryObject ro) {
    String[] errorMessage = new String[5];
    String sourceMessage = "";
    String targetMessage = "";
    try {
        errorMessage[0] = ro.getKey().getId();
        errorMessage[1] = ro.getObjectType().toString();
        errorMessage[2] = "";
        try {
            if (RegistryBrowser.getBQM()
                    .getRegistryObject(((Association) ro).getSourceObject().getKey().getId().trim()) == null) {
                errorMessage[2] = WebUIResourceBundle.getInstance().getString("sourceLabel");
            } else {
                sourceMessage = WebUIResourceBundle.getInstance().getString("message.AssociationNotValid2",
                        new Object[] { ((Association) ro).getSourceObject().getKey().getId(),
                                ((Association) ro).getSourceObject().getObjectType().toString(),
                                ((Association) ro).getSourceObject().getName().toString() });
            }
        } catch (Exception ex) {
            errorMessage[2] = WebUIResourceBundle.getInstance().getString("sourceLabel");
        }
        try {
            if (RegistryBrowser.getBQM()
                    .getRegistryObject(((Association) ro).getTargetObject().getKey().getId().trim()) == null) {
                errorMessage[2] = WebUIResourceBundle.getInstance().getString("targetLabel");

            } else {
                targetMessage = WebUIResourceBundle.getInstance().getString("message.AssociationNotValid3",
                        new Object[] { ((Association) ro).getTargetObject().getKey().getId(),
                                ((Association) ro).getTargetObject().getObjectType().toString(),
                                ((Association) ro).getTargetObject().getName().toString() });
            }
        } catch (Exception ex) {
            errorMessage[2] = WebUIResourceBundle.getInstance().getString("targetLabel");
        }
        //build error message list to display.
        if (this.assoErroMessageList != null) {
            this.assoErroMessageList.clear();
        }
        this.setAssociationErrorMessage(
                WebUIResourceBundle.getInstance().getString("message.AssociationNotValid1", errorMessage));
        if (sourceMessage.length() > 0) {
            this.setAssociationErrorMessage(sourceMessage);
        }
        if (targetMessage.length() > 0) {
            this.setAssociationErrorMessage(targetMessage);
        }
        this.setAssociationErrorMessage(
                WebUIResourceBundle.getInstance().getString("message.AssociationNotValid4"));
    } catch (Exception ex) {
        return;
    }

}

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

public String getDirtyObjectsMessage() {
    String message = null;/*from w ww.  j av a  2 s .  co  m*/
    FacesContext context = FacesContext.getCurrentInstance();
    Iterator<?> iter = context.getMessages();
    if ((iter == null || !iter.hasNext()) && registryObjectBeans != null) {
        Iterator<RegistryObjectBean> itr = registryObjectBeans.iterator();
        StringBuffer sb = null;
        while (itr.hasNext()) {
            RegistryObjectBean rob = itr.next();
            if (rob.isDirty() || isPseudoComposedObjectDirty(rob)) {
                if (sb == null) {
                    sb = new StringBuffer(WebUIResourceBundle.getInstance().getString("modifiedObjects"));
                    sb.append("<br>");
                }
                RegistryObject ro = rob.getRegistryObject();
                try {
                    sb.append(' ');
                    sb.append(WebUIResourceBundle.getInstance().getString("objectType"));
                    sb.append(": ");
                    sb.append(ro.getObjectType().getValue());
                } catch (JAXRException ex) {
                    sb.append("RegistryObject");
                }
                try {
                    sb.append(", ");
                    sb.append(WebUIResourceBundle.getInstance().getString("name"));
                    sb.append(": ");
                    String nameValue = getLocalizedNameString(ro);
                    sb.append(nameValue);
                } catch (JAXRException ex) {
                }
                sb.append("<br>");
            }
        }
        if (sb == null) {
            message = "";
        } else {
            message = sb.toString();
        }
    }
    return message;
}

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

private List<RegistryObjectBean> createComposedRegistryObjectBeans(Collection<RegistryObject> registryObjects)
        throws ClassNotFoundException, NoSuchMethodException, ExceptionInInitializerError, Exception {
    if (registryObjects == null) {
        return null;
    }//from   w  w  w .j  a  v a  2  s  .co  m
    int numObjects = registryObjects.size();
    @SuppressWarnings({ "unused" })
    List<RegistryObject> list = new ArrayList<RegistryObject>(registryObjects);

    Iterator<RegistryObject> roItr = registryObjects.iterator();
    if (log.isDebugEnabled()) {
        log.debug("Query results: ");
    }

    int numCols = 5;
    // Replace ObjectType with Id. TODO - formalize this convention
    List<RegistryObjectBean> roBeans = new ArrayList<RegistryObjectBean>(numObjects);
    for (@SuppressWarnings("unused")
    int i = 0; roItr.hasNext(); i++) {
        RegistryObject ro = roItr.next();
        String header = null;
        Object columnValue = null;
        @SuppressWarnings("unused")
        ArrayList<Object> srvbHeader = new ArrayList<Object>(numCols);
        ArrayList<SearchResultValueBean> searchResultValueBeans = new ArrayList<SearchResultValueBean>(numCols);

        header = WebUIResourceBundle.getInstance().getString("Details");
        columnValue = ro.getKey().getId();
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        header = WebUIResourceBundle.getInstance().getString("ObjectType");
        columnValue = ro.getObjectType().getValue();
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        header = WebUIResourceBundle.getInstance().getString("Name");
        columnValue = getLocalizedNameString(ro);

        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        header = WebUIResourceBundle.getInstance().getString("Description");
        columnValue = getLocalizedDescriptionString(ro);
        if (columnValue == null) {
            if (ro instanceof ClassificationImpl) {
                Concept concept = ((ClassificationImpl) ro).getConcept();
                if (concept != null)
                    columnValue = concept.getPath();
            }
        }
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        RegistryObjectBean srb = new RegistryObjectBean(searchResultValueBeans, ro, false);
        roBeans.add(srb);
    }
    return roBeans;
}

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

public String doAddRoToRegistryPackage() {
    String status = "failure";
    String result = null;//  w  w w .  j  av  a2 s. co m
    try {
        String memberObjectId = getCurrentDrilldownRegistryObjectBean().getMemberObjectId();
        getCurrentDrilldownRegistryObjectBean().setMemberObjectId(null);
        if (memberObjectId == null || memberObjectId.equals("")) {
            result = WebUIResourceBundle.getInstance().getString("objectIdIsNull");
        } else {
            RegistryPackageImpl regPkg = null;
            RegistryObject drilldownRO = getCurrentDrilldownRegistryObjectBean().getRegistryObject();
            if (!(drilldownRO instanceof RegistryPackageImpl)) {
                if (cachedROBId != null) {
                    RegistryObjectBean rob = getRegistryObjectLookup().get(cachedROBId);
                    if (rob != null) {
                        drilldownRO = rob.getRegistryObject();
                        currentRegistryObject = rob;
                    }
                }
            }
            if (drilldownRO instanceof RegistryPackageImpl) {
                regPkg = (RegistryPackageImpl) drilldownRO;
                RegistryObject ro = (RegistryBrowser.getBQM()).getRegistryObject(memberObjectId);
                if (ro == null) {
                    result = WebUIResourceBundle.getInstance().getString("objectIdIsInvalid");
                } else if (isRoAlreadyAMember(regPkg, memberObjectId)) {
                    result = WebUIResourceBundle.getInstance().getString("objectAlreadyMember");
                } else {
                    ArrayList<SearchResultValueBean> searchResultValueBeans = new ArrayList<SearchResultValueBean>(
                            4);
                    String header = WebUIResourceBundle.getInstance().getString("Details");
                    String columnValue = ro.getKey().getId();
                    searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

                    header = WebUIResourceBundle.getInstance().getString("ObjectType");
                    columnValue = ro.getObjectType().getValue();
                    searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

                    header = WebUIResourceBundle.getInstance().getString("Name");

                    columnValue = getLocalizedNameString(ro);
                    searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

                    header = WebUIResourceBundle.getInstance().getString("Description");
                    columnValue = getLocalizedDescriptionString(ro);
                    searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

                    currentComposedRegistryObject = new RegistryObjectBean(searchResultValueBeans, ro, false);
                    RegistryObjectBean rob = registryObjectLookup.get(memberObjectId);
                    if (rob == null) {
                        registryObjectLookup.put(memberObjectId, currentComposedRegistryObject);
                    }
                }
                relatedSearchResults.add(currentComposedRegistryObject);
                currentComposedRegistryObject.setRelatedSelected(true);
                currentComposedRegistryObject.setAddRoToRegistryPackage(true);
                currentRegistryObject.setDirty(true);
                currentRegistryObject.setSelected(true);
                result = WebUIResourceBundle.getInstance().getString("addSuccessful");
                status = "saveSuccessful";
            } else {
                result = WebUIResourceBundle.getInstance().getString("incorrectDrilldownObject",
                        new Object[] { "RegistryPackage" });
            }
        }
    } catch (Throwable t) {
        String message = WebUIResourceBundle.getInstance().getString("couldNotAddRegistryObjectToPackage");
        log.error(message, t);
        result = message + " " + t.getMessage();
    }
    append(result);
    return status;
}

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

/**
 * This method use to check the validity of Association Object by checking 
 * its source/target object still exist.In case an exception occurs like
 * UnresolvedReferenceException it build user friendly message to display on
 * UI and server log. /*from  w ww. java 2s. c  o  m*/
 */
private boolean checkAssociationObjectValidity(String id, boolean isCurrentRegistryObject) {
    boolean status = true;
    RegistryObject ro = null;
    try {
        ro = RegistryBrowser.getBQM().getRegistryObject(id.trim());
        if (ro instanceof Association) {
            if (((Association) ro).getSourceObject() != null && ((Association) ro).getTargetObject() != null) {
                status = true;
                if (RegistryBrowser.getBQM()
                        .getRegistryObject(((Association) ro).getSourceObject().getKey().getId().trim()) == null
                        || RegistryBrowser.getBQM().getRegistryObject(
                                ((Association) ro).getTargetObject().getKey().getId().trim()) == null) {
                    throw new NullPointerException();
                }
            }
        }
    } catch (UnresolvedReferenceException ure) {
        try {
            if (isCurrentRegistryObject) {
                this.buildAssociationErrorMessage(ro);
                this.currentRegistryObject = null;
                log.warn(ure.getMessage());
            }
        } catch (Exception ex) {
        }
        status = false;
    } catch (NullPointerException npe) {
        try {
            if (isCurrentRegistryObject) {
                this.buildAssociationErrorMessage(ro);
                this.currentRegistryObject = null;
                log.warn(npe.getMessage());
            }
        } catch (Exception ex) {
        }
        status = false;
    } catch (Exception ex) {
        try {
            String msg = WebUIResourceBundle.getInstance().getString("message.AssociationNotValid1",
                    new Object[] { ro.getKey().getId(), ro.getObjectType().toString(),
                            WebUIResourceBundle.getInstance().getString("message.SourceTarget") });
            OutputExceptions.warn(log, msg, msg, ex);
        } catch (Exception e) {
        }
    }
    return status;
}