List of usage examples for javax.xml.registry.infomodel Slot getValues
public Collection getValues() throws JAXRException;
From source file:JAXRQueryPostal.java
/** * Searches for organizations containing a string and * displays data about them, including the postal address in * either the JAXR PostalAddress format or the Slot format. *// www. j a va2 s. c o m * @param qString the string argument */ public void executeQuery(String qString) { RegistryService rs = null; BusinessQueryManager bqm = null; try { // Get registry service and query manager rs = connection.getRegistryService(); bqm = rs.getBusinessQueryManager(); System.out.println("Got registry service and " + "query manager"); // Define find qualifiers and name patterns Collection<String> findQualifiers = new ArrayList<String>(); findQualifiers.add(SORT_BY_NAME_DESC); Collection<String> namePatterns = new ArrayList<String>(); namePatterns.add("%" + qString + "%"); // Find using the name BulkResponse response = bqm.findOrganizations(findQualifiers, namePatterns, null, null, null, null); Collection orgs = response.getCollection(); // Display information about the organizations found for (Object o : orgs) { Organization org = (Organization) o; System.out.println("Org name: " + getName(org)); System.out.println("Org description: " + getDescription(org)); System.out.println("Org key id: " + getKey(org)); // Display primary contact information User pc = org.getPrimaryContact(); if (pc != null) { PersonName pcName = pc.getPersonName(); System.out.println(" Contact name: " + pcName.getFullName()); Collection phNums = pc.getTelephoneNumbers(null); for (Object n : phNums) { TelephoneNumber num = (TelephoneNumber) n; System.out.println(" Phone number: " + num.getNumber()); } Collection eAddrs = pc.getEmailAddresses(); for (Object a : eAddrs) { EmailAddress eAd = (EmailAddress) a; System.out.println(" Email Address: " + eAd.getAddress()); } // Display postal addresses // using PostalAddress methods Collection pAddrs = pc.getPostalAddresses(); for (Object pa : pAddrs) { PostalAddress pAd = (PostalAddress) pa; System.out.println(" Postal Address (PostalAddress methods):\n " + pAd.getStreetNumber() + " " + pAd.getStreet() + "\n " + pAd.getCity() + ", " + pAd.getStateOrProvince() + " " + pAd.getPostalCode() + "\n " + pAd.getCountry()); } // Display postal addresses // using Slot methods Collection pAddrs2 = pc.getPostalAddresses(); for (Object pa2 : pAddrs2) { PostalAddress pAd = (PostalAddress) pa2; Collection slots = pAd.getSlots(); System.out.println(" Postal Address (Slot methods):"); for (Object s : slots) { Slot slot = (Slot) s; Collection values = slot.getValues(); for (Object v : values) { String line = (String) v; System.out.println(" Line: " + line); } } } } // Display service and binding information Collection services = org.getServices(); for (Object s : services) { Service svc = (Service) s; System.out.println(" Service name: " + getName(svc)); System.out.println(" Service description: " + getDescription(svc)); Collection serviceBindings = svc.getServiceBindings(); for (Object b : serviceBindings) { ServiceBinding sb = (ServiceBinding) b; System.out.println(" Binding " + "Description: " + getDescription(sb)); System.out.println(" Access URI: " + sb.getAccessURI()); } } // Print spacer between organizations System.out.println(" --- "); } } catch (Exception e) { e.printStackTrace(); } finally { // At end, close connection to registry if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:it.cnr.icar.eric.client.ui.thin.ExportBean.java
/** * This method is used to export a collection of selected objects from * the search results table./*from w w w .java 2 s. c o m*/ * * @return java.lang.String * Return status string: used by JSF for page navigation */ @SuppressWarnings("unchecked") public String doExport() { String status = "failure"; // Reset the zipFileName class member variable zipFileName = null; try { // Execute a compressed content filter query to get a zip file of content ArrayList<String> filterQueryIds = new ArrayList<String>(); filterQueryIds.add(BindingUtility.FREEBXML_REGISTRY_FILTER_QUERY_COMPRESSCONTENT); queryParams.put("$queryFilterIds", filterQueryIds); queryParams.put(CanonicalConstants.CANONICAL_SEARCH_DEPTH_PARAMETER, SearchPanelBean.getInstance().getSearchDepth()); Iterator<RegistryObjectBean> beanItr = getAllSelectedRegistryObjectBeans().iterator(); List<String> ids = new ArrayList<String>(); while (beanItr.hasNext()) { RegistryObjectBean rob = beanItr.next(); if (rob.getObjectType().equalsIgnoreCase("ExtrinsicObject")) { ids.add(rob.getId()); } } // Execute an arbitrary query with selected ids String queryId = CanonicalConstants.CANONICAL_QUERY_ArbitraryQuery; String sqlString = getExportSQLString(ids); queryParams.put(CanonicalConstants.CANONICAL_SLOT_QUERY_ID, queryId); queryParams.put("$query", sqlString); Query query = RegistryBrowser.getDQM().createQuery(Query.QUERY_TYPE_SQL); BulkResponse bResponse = RegistryBrowser.getDQM().executeQuery(query, queryParams); Collection<?> registryObjects = bResponse.getCollection(); // There should just be one EO containing the zip file Iterator<?> roItr = registryObjects.iterator(); if (roItr.hasNext()) { Object obj = roItr.next(); if (obj instanceof ExtrinsicObjectImpl) { ExtrinsicObjectImpl eo = (ExtrinsicObjectImpl) obj; // Get the zip filename and set it to this.zipFileName Slot filenameSlot = eo .getSlot(BindingUtility.FREEBXML_REGISTRY_FILTER_QUERY_COMPRESSCONTENT_FILENAME); if (filenameSlot != null) { Iterator<?> filenameItr = filenameSlot.getValues().iterator(); if (filenameItr.hasNext()) { zipFileName = (String) filenameItr.next(); } } status = "success"; } else { String msg = WebUIResourceBundle.getInstance().getString("message.ExpectedExtrinsicObject", new Object[] { obj }); RegistryObjectCollectionBean.getInstance().append(msg); status = "showExportPage"; } } else { String msg = WebUIResourceBundle.getInstance().getString("message.extrinsicObjectWithNoRI"); RegistryObjectCollectionBean.getInstance().append(msg); status = "showExportPage"; } } catch (Throwable t) { OutputExceptions.error(log, t); } finally { try { queryParams.clear(); } catch (Throwable t) { OutputExceptions.warn(log, t); } } return status; }
From source file:it.cnr.icar.eric.client.ui.thin.SearchPanelBean.java
private void handleCompressedContent(BulkResponse bulkResponse) throws JAXRException { try {//from w ww . j av a 2 s.c o m Iterator<?> itr = bulkResponse.getCollection().iterator(); if (itr.hasNext()) { RegistryObject ro = (RegistryObject) itr.next(); if (ro != null) { Slot fileNameSlot = ro .getSlot(BindingUtility.FREEBXML_REGISTRY_FILTER_QUERY_COMPRESSCONTENT_FILENAME); if (fileNameSlot != null) { Iterator<?> slotItr = fileNameSlot.getValues().iterator(); if (slotItr.hasNext()) { String filename = (String) slotItr.next(); ExportBean.getInstance().setZipFileName(filename); } } } } } catch (Throwable t) { throw new JAXRException(t); } }
From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java
/** * Shows the specified RepositoryItem for the RegistryObject in a Web * Browser//from w w w. j a v a2 s .c o m * * @param registryObject * DOCUMENT ME! */ public static void showRepositoryItem(RegistryObject registryObject) { DataHandler repositoryItem = null; @SuppressWarnings("unused") File defaultItemFile = null; try { repositoryItem = ((ExtrinsicObject) registryObject).getRepositoryItem(); String url = null; if (repositoryItem == null) { // I18N?? // displayInfo("There is no repository item for this object"); Slot contentLocatorSlot = registryObject.getSlot(CanonicalConstants.CANONICAL_SLOT_CONTENT_LOCATOR); if (contentLocatorSlot != null) { @SuppressWarnings("rawtypes") Collection values = contentLocatorSlot.getValues(); String contentLocator = null; if (values.size() > 0) { contentLocator = (String) (values.toArray())[0]; } if (isExternalURL(contentLocator)) { url = contentLocator; } } } else { url = baseURL.substring(0, baseURL.length() - 4) + "http?interface=QueryManager&method=getRepositoryItem¶m-id=" + URLEncoder.encode(registryObject.getKey().getId(), "utf-8"); } if (url != null) { HyperLinker.displayURL(url); } else { displayInfo(resourceBundle.getString("message.info.noRepositoryItemOrURL")); } } catch (Exception e) { displayError(e); } }
From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectBean.java
public String getSlotValues() throws JAXRException { StringBuffer sb = new StringBuffer(""); // Presume that the nonRegistryObject is a Slot when this method // is invoked. Catch ClassCastExceptions try {// w w w .j a va2 s .c om Slot slot = (SlotImpl) this.nonRegistryObject; Iterator<?> valItr = slot.getValues().iterator(); for (int i = 0; valItr.hasNext(); i++) { if (i > 0) { sb.append('|'); } sb.append(valItr.next()); } } catch (ClassCastException ex) { log.error(WebUIResourceBundle.getInstance().getString("message.TheNonRegistryObjectIsNotASlot")); } return sb.toString(); }
From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java
public List<SelectItem> getSlots() throws JAXRException { ArrayList<SelectItem> list = new ArrayList<SelectItem>(); Collection<?> slots = (Collection<?>) getCurrentRegistryObjectBean().getFields().get("slots"); Iterator<?> iter = slots.iterator(); while (iter.hasNext()) { Slot anItem = (Slot) iter.next(); String cstr = "name=" + anItem.getName() + " type=" + anItem.getSlotType() + " values=" + anItem.getValues(); list.add(new SelectItem(cstr)); }//from w w w .ja v a 2 s .c o m return list; }
From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java
private List<RegistryObjectBean> getSlotsSearchResultsBeans(RegistryObjectBean roBean) throws ClassNotFoundException, NoSuchMethodException, ExceptionInInitializerError, Exception { List<?> slots = roBean.getSlots(); if (slots == null) { return null; }//w ww . java 2 s .c o m int numSlotObjects = slots.size(); @SuppressWarnings("unused") List<Object> list = new ArrayList<Object>(numSlotObjects); Iterator<?> roItr = slots.iterator(); if (log.isDebugEnabled()) { log.debug("Query results: "); } String objectType = "Slot"; int numCols = 5; // Replace ObjectType with Id. TODO - formalize this convention ArrayList<RegistryObjectBean> roBeans = new ArrayList<RegistryObjectBean>(numSlotObjects); for (@SuppressWarnings("unused") int i = 0; roItr.hasNext(); i++) { Slot slot = (Slot) roItr.next(); String header = null; Object columnValue = null; @SuppressWarnings("unused") ArrayList<Object> srvbHeader = new ArrayList<Object>(numCols); List<SearchResultValueBean> searchResultValueBeans = new ArrayList<SearchResultValueBean>(numCols); header = WebUIResourceBundle.getInstance().getString("Details"); columnValue = roBean.getId() + "." + slot.hashCode(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); header = WebUIResourceBundle.getInstance().getString("Name"); columnValue = slot.getName(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); header = WebUIResourceBundle.getInstance().getString("Slot Type"); columnValue = slot.getSlotType(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); header = WebUIResourceBundle.getInstance().getString("Values"); columnValue = slot.getValues(); searchResultValueBeans.add(new SearchResultValueBean(header, columnValue)); RegistryObjectBean srb = new RegistryObjectBean(searchResultValueBeans, roBean.getRegistryObject(), objectType, slot, false); roBeans.add(srb); } return roBeans; }