List of usage examples for javax.xml.registry RegistryService getDeclarativeQueryManager
DeclarativeQueryManager getDeclarativeQueryManager() throws JAXRException, UnsupportedCapabilityException;
From source file:it.cnr.icar.eric.server.query.federation.FederatedQueryWorker.java
/** Setup JAXR Connection for target registry */ protected void setUpConnection() throws JAXRException { String home = registry.getHome(); if ((home != null) && (connection == null)) { connection = ConnectionManager.getInstance().getConnection(home); ((ConnectionImpl) connection).setLocalCallMode(false); RegistryService service = connection.getRegistryService(); dqm = (DeclarativeQueryManagerImpl) service.getDeclarativeQueryManager(); }//from ww w .j a va 2 s . com }
From source file:it.cnr.icar.eric.client.ui.swing.JAXRClient.java
/** * Makes a connection to a JAXR Registry. * * @param url The URL of the registry.// ww w.j a va2 s. com * @return boolean true if connected, false otherwise. */ public synchronized boolean createConnection(String url) { try { if (!RegistryBrowser.localCall) { (new URL(url)).openStream().read(); } Thread.currentThread().setContextClassLoader(RegistryBrowser.getInstance().classLoader); ProviderProperties.getInstance().put("javax.xml.registry.queryManagerURL", url); ConnectionFactory connFactory = JAXRUtility.getConnectionFactory(); connection = (it.cnr.icar.eric.client.xml.registry.ConnectionImpl) connFactory.createConnection(); RegistryService service = connection.getRegistryService(); bqm = service.getBusinessQueryManager(); dqm = (it.cnr.icar.eric.client.xml.registry.DeclarativeQueryManagerImpl) service .getDeclarativeQueryManager(); lcm = (it.cnr.icar.eric.client.xml.registry.BusinessLifeCycleManagerImpl) service .getBusinessLifeCycleManager(); lmm = connection.getLoginModuleManager(); lmm.setParentFrame(RegistryBrowser.getInstance()); connected = true; } catch (final JAXRException e) { connected = false; String msg = JavaUIResourceBundle.getInstance().getString("message.error.failedConnecting", new String[] { url, e.getLocalizedMessage() }); log.error(msg, e); RegistryBrowser.displayError(msg, e); } catch (MalformedURLException e) { connected = false; String msg = JavaUIResourceBundle.getInstance().getString("message.error.failedConnecting", new String[] { url, e.getLocalizedMessage() }); log.error(msg, e); RegistryBrowser.displayError(msg, e); } catch (IOException e) { connected = false; String msg = JavaUIResourceBundle.getInstance().getString("message.error.failedConnecting", new String[] { url, e.getLocalizedMessage() }); log.error(msg, e); RegistryBrowser.displayError(msg, e); } return connected; }
From source file:it.cnr.icar.eric.client.ui.swing.AdhocQuerySearchPanel.java
public void reloadModel() { final SwingWorker worker = new SwingWorker(this) { public Object doNonUILogic() { try { // This might take a while. Contructor should be running as SwingWorker JAXRClient client = RegistryBrowser.getInstance().getClient(); Connection connection = client.getConnection(); RegistryService service = connection.getRegistryService(); dqm = (it.cnr.icar.eric.client.xml.registry.DeclarativeQueryManagerImpl) service .getDeclarativeQueryManager(); lcm = (it.cnr.icar.eric.client.xml.registry.LifeCycleManagerImpl) service .getBusinessLifeCycleManager(); processConfiguration();/*from w w w .j a va 2 s . c o m*/ // model!!! } catch (JAXRException e) { throw new UndeclaredThrowableException(e); } return null; } @SuppressWarnings({ "unchecked", "rawtypes" }) public void doUIUpdateLogic() { try { selectQueryCombo.setModel(new DefaultComboBoxModel(getQueryNames())); if (queries.size() > 0) { setQuery(queries.get(0)); } } catch (JAXRException e) { throw new UndeclaredThrowableException(e); } } }; worker.start(); }
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 . j a v a 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; }