Example usage for javax.xml.registry.infomodel Concept getValue

List of usage examples for javax.xml.registry.infomodel Concept getValue

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel Concept getValue.

Prototype

String getValue() throws JAXRException;

Source Link

Document

Gets the value (usually a code in a taxonomy) associated with this Concept.

Usage

From source file:it.cnr.icar.eric.client.ui.swing.BusinessQueryPanel.java

public static String[] getObjectTypes() {
    String[] array = null;//from   ww w  .j a va 2  s  .c  o  m
    ArrayList<String> objectTypes = new ArrayList<String>();

    try {
        JAXRClient client = RegistryBrowser.getInstance().getClient();
        BusinessQueryManagerImpl bqm = (BusinessQueryManagerImpl) (client.getBusinessQueryManager());
        Collection<?> concepts = bqm.findConceptsByPath(
                "/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType + "/RegistryObject%");

        int size = concepts.size();

        Iterator<?> iter = concepts.iterator();
        @SuppressWarnings("unused")
        int i = 0;

        while (iter.hasNext()) {
            Concept concept = (Concept) iter.next();
            String objectType = concept.getValue();

            if (objectType.equals("ClassificationNode")) {
                objectType = "Concept";
            }

            objectTypes.add(objectType);
        }

        //Collections.sort(objectTypes);

        array = new String[size];
    } catch (JAXRException e) {
        RegistryBrowser.displayError(e);
    }

    return objectTypes.toArray(array);
}

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

private void loadRegistryObjectChildNodes(RegistryObjectNode parentNode) throws JAXRException {
    Concept concept = parentNode.getRegistryObjectType();
    Iterator<?> itr = concept.getChildrenConcepts().iterator();
    RegistryObjectNode roNode = null;/* ww  w  .j a va  2  s  .  co  m*/
    if (itr.hasNext()) {
        parentNode.clearChildren();
        RegistryPackage rOCPkg = null;
        while (itr.hasNext()) {
            Concept childConcept = (Concept) itr.next();
            try {
                rOCPkg = RegistryBrowser.getBLCM().createRegistryPackage(childConcept.getValue());
            } catch (Exception ex) {
                throw new JAXRException(ex);
            }
            roNode = new RegistryObjectNode(rOCPkg, childConcept);
            parentNode.addChild(roNode);
            roNode.setHasChild(childConcept.getChildConceptCount() > 0);
        }
        if (roNode != null) {
            roNode.setLast(true);
        }
    }
}

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

public String[] getAssociationTypes() {
    String[] assocTypes = null;/*from  w  ww . ja  v a  2 s  . co m*/

    try {
        Collection<?> concepts = ((BusinessQueryManagerImpl) getBusinessQueryManager()).findConceptsByPath(
                "/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_AssociationType + "/%");

        int size = concepts.size();
        assocTypes = new String[size];

        Iterator<?> iter = concepts.iterator();
        int i = 0;

        while (iter.hasNext()) {
            Concept concept = (Concept) iter.next();
            assocTypes[i++] = concept.getValue();
        }
    } catch (JAXRException e) {
        RegistryBrowser.displayError(e);
    }

    return assocTypes;
}

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

public String[] getPhoneTypes() {
    String[] phoneTypes = null;//from   w  w w. j  av  a2 s . com

    try {
        Collection<?> concepts = ((BusinessQueryManagerImpl) getBusinessQueryManager())
                .findConceptsByPath("/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_PhoneType + "/%");

        int size = concepts.size();
        phoneTypes = new String[size];

        Iterator<?> iter = concepts.iterator();
        int i = 0;

        while (iter.hasNext()) {
            Concept concept = (Concept) iter.next();
            phoneTypes[i++] = concept.getValue();
        }
    } catch (JAXRException e) {
        RegistryBrowser.displayError(e);
    }

    return phoneTypes;
}

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

public String[] getEmailTypes() {
    String[] emailTypes = null;/*from w  w  w.j ava2  s  . c  om*/

    try {
        Collection<?> concepts = ((BusinessQueryManagerImpl) getBusinessQueryManager())
                .findConceptsByPath("/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_EmailType + "/%");

        int size = concepts.size();
        emailTypes = new String[size];

        Iterator<?> iter = concepts.iterator();
        int i = 0;

        while (iter.hasNext()) {
            Concept concept = (Concept) iter.next();
            emailTypes[i++] = concept.getValue();
        }
    } catch (JAXRException e) {
        RegistryBrowser.displayError(e);
    }

    return emailTypes;
}

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

private Collection<RegistryObject> sortChildConceptsByName(Collection<?> childConcepts) {
    TreeMap<String, RegistryObject> treeMap = new TreeMap<String, RegistryObject>();
    Iterator<?> itr = childConcepts.iterator();
    while (itr.hasNext()) {
        Concept concept = (Concept) itr.next();
        try {/*from   ww w.  java  2s. c o  m*/
            treeMap.put(concept.getValue(), concept);
        } catch (JAXRException ex) {
            log.warn(WebUIResourceBundle.getInstance().getString("message.CouldNotGetNameFromConcept"), ex);
        }
    }
    return treeMap.values();

}

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

private SelectItem loadConceptItem(Concept concept, String indent) {
    SelectItem item = null;/*from  w w w .  j a v  a2s  . c  o  m*/
    try {
        String name = indent + ((InternationalStringImpl) concept.getName())
                .getClosestValue(FacesContext.getCurrentInstance().getViewRoot().getLocale());
        if (name == null || name.indexOf("null") != -1) {
            name = indent + concept.getValue();
        }

        Object path = concept.getPath();
        item = new SelectItem(path, name);
    } catch (JAXRException ex) {
        log.error(WebUIResourceBundle.getInstance().getString("message.ErrorGettingDataFromConcept"), ex);
    }
    return item;
}

From source file:it.cnr.icar.eric.client.ui.swing.BusinessQueryPanel.java

/**
 * Execute the query using parameters defined by the fields in QueryPanel.
 *///from ww w .  ja va 2 s  .co  m
BulkResponse executeQuery() {
    BulkResponse resp = null;

    try {
        // create namePattern collection
        String nameStr = nameText.getText();
        String descStr = descText.getText();

        ArrayList<Object> classifications = ((ClassificationsListModel) (classificationsList.getModel()))
                .getModels();
        ArrayList<?> extIds = ((ExternalIdentifiersListModel) (extIdsList.getModel())).getModels();
        ArrayList<?> extLinks = ((ExternalLinksListModel) (linksList.getModel())).getModels();

        JAXRClient client = RegistryBrowser.getInstance().getClient();
        Connection connection = RegistryBrowser.client.getConnection();
        RegistryService service = connection.getRegistryService();
        @SuppressWarnings("unused")
        BusinessQueryManagerImpl bqm = (BusinessQueryManagerImpl) service.getBusinessQueryManager();
        DeclarativeQueryManagerImpl dqm = (DeclarativeQueryManagerImpl) service.getDeclarativeQueryManager();

        Object objectTypeObj = getObjectType();
        if (!(objectTypeObj instanceof Concept)) {
            throw new JAXRException("Search not supported for objectType: " + objectTypeObj.toString());
        }

        Concept objectType = (Concept) objectTypeObj;
        if (!(objectType.getPath()
                .startsWith("/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_ID_ObjectType))) {
            throw new JAXRException("Search not supported for objectType: " + objectType.getPath());
        }

        boolean isIntrinsic = isIntrinsicObjectType(objectType);
        boolean caseSensitive = caseSensitiveCheckBox.isSelected();

        // make declarative query
        String queryStr = "SELECT obj.* from ";

        if (isIntrinsic) {
            queryStr += (objectType.getValue() + " obj ");
        } else {
            //Following using RegistryObject as it could be an ExtrinsicObject
            //or an ExternalLink
            queryStr += "RegistryObject obj, ClassificationNode typeNode ";
        }

        //Add name to tables in join
        if ((nameStr != null) && (nameStr.length() != 0)) {
            queryStr += ", Name_ nm ";
        }

        //Add description to tables in join
        if ((descStr != null) && (descStr.length() != 0)) {
            queryStr += ", Description des ";
        }

        boolean addedPredicate = false;

        //Add objectType predicate
        if (!isIntrinsic) {
            if (!addedPredicate) {
                queryStr += "WHERE ";
                addedPredicate = true;
            } else {
                queryStr += "AND ";
            }

            queryStr += ("((obj.objectType = typeNode.id) AND " + "(typeNode.path LIKE '" + objectType.getPath()
                    + "' OR typeNode.path LIKE '" + objectType.getPath() + "/%'))");
        }

        //Add name predicate if needed
        if ((nameStr != null) && (nameStr.length() > 0)) {
            if (!addedPredicate) {
                queryStr += "WHERE ";
                addedPredicate = true;
            } else {
                queryStr += "AND ";
            }

            queryStr += ("((nm.parent = obj.id) AND ("
                    + BusinessQueryManagerImpl.caseSensitise("nm.value", caseSensitive) + " LIKE "
                    + BusinessQueryManagerImpl.caseSensitise("'" + nameStr + "'", caseSensitive) + ")) ");
        }

        //Add description predicate if needed
        if ((descStr != null) && (descStr.length() > 0)) {
            if (!addedPredicate) {
                queryStr += "WHERE ";
                addedPredicate = true;
            } else {
                queryStr += "AND ";
            }

            queryStr += ("((des.parent = obj.id) AND ("
                    + BusinessQueryManagerImpl.caseSensitise("des.value", caseSensitive) + " LIKE "
                    + BusinessQueryManagerImpl.caseSensitise("'" + descStr + "'", caseSensitive) + ")) ");
        }

        //Add nested query for Classifications if needed
        if (classifications.size() > 0) {
            if (!addedPredicate) {
                queryStr += "WHERE ";
                addedPredicate = true;
            } else {
                queryStr += "AND ";
            }

            queryStr += qu.getClassificationsPredicate(classifications, "obj.id", null);
        }

        //Add predicate for ExternalIdentifiers if needed
        if (extIds.size() > 0) {
            if (!addedPredicate) {
                queryStr += "WHERE ";
                addedPredicate = true;
            } else {
                queryStr += "AND ";
            }

            queryStr += qu.getExternalIdentifiersPredicate(extIds, "obj.id", null);
        }

        //Add nested query for ExternalLinks if needed
        if (extLinks.size() > 0) {
            if (!addedPredicate) {
                queryStr += "WHERE ";
                addedPredicate = true;
            } else {
                queryStr += "AND ";
            }

            queryStr += qu.getExternalLinksPredicate(extLinks, "obj.id", null);
        }

        QueryImpl query = (QueryImpl) dqm.createQuery(Query.QUERY_TYPE_SQL, queryStr);
        query.setFederated(isFederated());

        // make JAXR request
        resp = dqm.executeQuery(query);

        client.checkBulkResponse(resp);
    } catch (JAXRException e) {
        RegistryBrowser.displayError(e);
    }

    return resp;
}

From source file:it.cnr.icar.eric.client.ui.swing.graph.JBGraph.java

/**
 * DOCUMENT ME!//w w w .j a va  2 s.  c o  m
 *
 * @param cell DOCUMENT ME!
 * @param ro DOCUMENT ME!
 *
 * @return ArrayList of GraphCell for the related objects.
 */
private ArrayList<Object> showRelatedObjects(JBGraphCell cell, RegistryObject ro) {
    ArrayList<Object> relatedCells = new ArrayList<Object>();

    if (ro == null) {
        return relatedCells;
    }

    try {
        CellView cellView = getView().getMapping(cell, false);
        Rectangle bounds = cellView.getBounds();

        //Classifications
        Collection<?> classifications = ro.getClassifications();
        DefaultGraphCell groupCell = createGroupFromObjectCollection(classifications);

        if (groupCell != null) {
            connectCells(cell, groupCell, "classifications", false);
            relatedCells.add(groupCell);
        }

        //ExternalIdentifiers
        Collection<?> extIds = ro.getExternalIdentifiers();
        groupCell = createGroupFromObjectCollection(extIds);

        if (groupCell != null) {
            connectCells(cell, groupCell, "externalIdentifiers", false);
            relatedCells.add(groupCell);
        }

        //ExternalLinks
        Collection<?> extLinks = ro.getExternalLinks();
        groupCell = createGroupFromObjectCollection(extLinks);

        if (groupCell != null) {
            connectCells(cell, groupCell, "externalLinks", false);
            relatedCells.add(groupCell);
        }

        /*
           //RegistryPackages
           try {
           Collection pkgs = ro.getRegistryPackages();
           Iterator iter = pkgs.iterator();
           while (iter.hasNext()) {
               RegistryPackage pkg = (RegistryPackage)iter.next();
               if (pkg != null) {
                   JBGraphCell newCell = addRelatedObject(cell, pkg, new Rectangle(0, 0, 50, 50), "HasMember", true);
                   relatedCells.add(newCell);
               }
           }
           } catch (UnsupportedCapabilityException e) {
           }
         **/

        try {
            //Associations
            Collection<?> assocs = ((RegistryObjectImpl) ro).getAllAssociations();
            Iterator<?> iter = assocs.iterator();

            while (iter.hasNext()) {
                Association assoc = (Association) iter.next();
                RegistryObject srcObj = assoc.getSourceObject();
                RegistryObject targetObj = assoc.getTargetObject();
                Concept concept = assoc.getAssociationType();

                String label = "associatedWith";

                if (concept != null) {
                    label = concept.getValue();
                }

                if ((srcObj != null) && (targetObj != null)) {
                    JBGraphCell newCell = null;

                    if (srcObj.getKey().getId().equalsIgnoreCase(ro.getKey().getId())) {
                        //ro is the source, newCell is the target
                        newCell = addRelatedObject(cell, targetObj,
                                new Rectangle(bounds.x + 100, bounds.y, 50, 50), label, false);
                    } else {
                        //ro is the target, newCell is the source
                        newCell = addRelatedObject(cell, srcObj,
                                new Rectangle(bounds.x + 100, bounds.y, 50, 50), label, true);
                    }

                    relatedCells.add(newCell);
                } else {
                    System.err.println(
                            "Invalid association. Source or target is null: " + assoc.getKey().getId());
                }
            }

        } catch (UnsupportedCapabilityException e) {
        }
    } catch (JAXRException e) {
        RegistryBrowser.displayError(e);
    }

    return relatedCells;
}

From source file:it.cnr.icar.eric.client.xml.registry.LifeCycleManagerImpl.java

private void initializeObjectTypesMap() {
    try {/*  ww w. ja  v  a 2  s .  co m*/
        DeclarativeQueryManager dqm = getRegistryService().getDeclarativeQueryManager();
        //         String queryStr = "SELECT children.* FROM ClassificationNode children, ClassificationNode parent where (parent.path LIKE '/"
        //               + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType
        //               + "/RegistryObject%') AND (parent.path NOT LIKE '/"
        //               + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType
        //               + "/RegistryObject/ExtrinsicObject/%') AND parent.id = children.parent";
        //         Query query = dqm.createQuery(Query.QUERY_TYPE_SQL, queryStr);

        Query query = SQLQueryProvider.initializeObjectTypesMap(dqm);

        BulkResponse resp = dqm.executeQuery(query);

        if ((resp != null) && (!(resp.getStatus() == JAXRResponse.STATUS_SUCCESS))) {
            Collection<?> exceptions = resp.getExceptions();

            if (exceptions != null) {
                Iterator<?> iter = exceptions.iterator();

                while (iter.hasNext()) {
                    Exception e = (Exception) iter.next();
                    e.printStackTrace();
                }
            }

            return;
        }

        objectTypesMap = new HashMap<String, Concept>();

        Collection<?> concepts = resp.getCollection();
        Iterator<?> iter = concepts.iterator();

        while (iter.hasNext()) {
            Concept concept = (Concept) iter.next();
            String value = concept.getValue();

            if (value.equals("ClassificationNode")) {
                value = "Concept";
            }

            objectTypesMap.put(value, concept);
        }
    } catch (JAXRException e) {
        e.printStackTrace();
    }
}