List of usage examples for javax.xml.registry.infomodel Concept getPath
String getPath() throws JAXRException;
From source file:it.cnr.icar.eric.client.ui.swing.BusinessQueryPanel.java
public static boolean isIntrinsicObjectType(Concept objectType) throws JAXRException { boolean isIntrinsic = true; String path = objectType.getPath(); if (path.startsWith("/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType + "/RegistryObject/ExtrinsicObject")) { isIntrinsic = false;// w w w. java 2 s .c om } return isIntrinsic; }
From source file:it.cnr.icar.eric.client.ui.swing.BusinessQueryPanel.java
/** * Execute the query using parameters defined by the fields in QueryPanel. *//*from w w w .ja va 2 s . c o 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.xml.registry.infomodel.RegistryObjectImpl.java
/** * Gets all Concepts classifying this object that have specified path as prefix. * Used in RegistryObjectsTableModel.getValueAt via reflections API if so configured. *//* www .ja va2 s. co m*/ public Collection<Concept> getClassificationConceptsByPath(String pathPrefix) throws JAXRException { Collection<Concept> matchingClassificationConcepts = new ArrayList<Concept>(); ArrayList<RegistryObject> _classifications = getClassifications(); Iterator<RegistryObject> iter = _classifications.iterator(); while (iter.hasNext()) { Classification cl = (Classification) iter.next(); Concept concept = cl.getConcept(); String conceptPath = concept.getPath(); if (conceptPath.startsWith(pathPrefix)) { matchingClassificationConcepts.add(concept); } } return matchingClassificationConcepts; }
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 . ja v a2 s . com*/ 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.thin.RegistryObjectBean.java
public RegistryObjectBean(Collection<SearchResultValueBean> searchResultValueBeans, RegistryObject registryObject) { this(searchResultValueBeans); this.registryObject = registryObject; if (registryObject != null) { try {// w w w . ja v a2 s .c o 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.xml.registry.LifeCycleManagerImpl.java
/** * Create an object for the specified objectType Add to JAXR 2.0 *//*from w w w. java 2 s .c o m*/ public Object createObject(Concept objectTypeConcept) throws JAXRException, InvalidRequestException, UnsupportedCapabilityException { Object obj = null; String path = objectTypeConcept.getPath(); if (path == null) { throw new JAXRException(JAXRResourceBundle.getInstance().getString("message.error.Concept.path.null", new Object[] { objectTypeConcept.getKey().getId() })); } if (path.startsWith("/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType + "/RegistryObject/ExtrinsicObject")) { obj = createExtrinsicObject(objectTypeConcept); } else if (path.startsWith("" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_AssociationType + "/") || path.startsWith("/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType + "/RegistryObject/Association")) { obj = createAssociation(objectTypeConcept); } else { String className = getJAXRClassNameFromObjectType(objectTypeConcept); obj = createObject(className); } return obj; }
From source file:it.cnr.icar.eric.client.xml.registry.LifeCycleManagerImpl.java
public boolean isIntrinsicObjectType(Concept objectTypeConcept) throws JAXRException { boolean isIntrinsic = true; // This is risky as we may allow ExtrinsicObjects to be sub-classes of // other classes in future. if (objectTypeConcept.getPath() .startsWith("/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType + "/RegistryObject/ExtrinsicObject/")) { isIntrinsic = false;//from w w w . j a v a 2 s. c o m } return isIntrinsic; }
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 ww w .j a v a2 s .c om*/ 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; }