Example usage for javax.xml.registry.infomodel Classification getClassificationScheme

List of usage examples for javax.xml.registry.infomodel Classification getClassificationScheme

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel Classification getClassificationScheme.

Prototype

ClassificationScheme getClassificationScheme() throws JAXRException;

Source Link

Document

Gets the ClassificationScheme that is used in classifying the object.

Usage

From source file:JAXRQueryByNAICSClassification.java

/**
     * Searches for organizations corresponding to an NAICS
     * classification and displays data about them.
     *//*from ww  w  . j av a2  s .  c  o m*/
    public void executeQuery() {
        RegistryService rs = null;
        BusinessQueryManager bqm = null;
        BusinessLifeCycleManager blcm = null;

        try {
            // Get registry service and managers
            rs = connection.getRegistryService();
            bqm = rs.getBusinessQueryManager();
            blcm = rs.getBusinessLifeCycleManager();
            System.out.println("Got registry service, query " + "manager, and lifecycle manager");

            ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");

            // Find using an NAICS classification
            // Set classification scheme to NAICS, using
            // well-known UUID of ntis-gov:naics:1997
            String uuid_naics = "uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2";
            ClassificationScheme cScheme = (ClassificationScheme) bqm.getRegistryObject(uuid_naics,
                    LifeCycleManager.CLASSIFICATION_SCHEME);

            Collection<Classification> classifications = new ArrayList<Classification>();

            if (cScheme != null) {
                // Create and add classification
                InternationalString sn = blcm.createInternationalString(bundle.getString("classification.name"));
                Classification classification = blcm.createClassification(cScheme, sn,
                        bundle.getString("classification.value"));
                classifications.add(classification);
            } else {
                System.out.println("Classification scheme not found");
            }

            BulkResponse response = bqm.findOrganizations(null, null, classifications, null, null, null);
            Collection orgs = response.getCollection();

            // Display information about the organizations found
            int numOrgs = 0;

            if (orgs.isEmpty()) {
                System.out.println("No organizations found");
            } else {
                for (Object o : orgs) {
                    numOrgs++;

                    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 classifications
                    Collection classList = org.getClassifications();

                    for (Object cl : classList) {
                        Classification c = (Classification) cl;
                        System.out.println(" Classification name: " + getName(c));
                        System.out.println(" Classification value: " + c.getValue());

                        ClassificationScheme sch = c.getClassificationScheme();
                        System.out.println(" Classification scheme key: " + getKey(sch));
                    }

                    // Print spacer between organizations
                    System.out.println(" --- ");
                }
            }

            System.out.println("Found " + numOrgs + " organization(s)");
        } 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.swing.graph.JBGraph.java

/**
 * DOCUMENT ME!//w ww . j  av a2s.co  m
 *
 * @param cell DOCUMENT ME!
 * @param classification DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
private ArrayList<DefaultGraphCell> showRelatedObjects(JBGraphCell cell, Classification classification) {
    ArrayList<DefaultGraphCell> relatedCells = new ArrayList<DefaultGraphCell>();

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

    try {
        //scheme
        ClassificationScheme scheme = classification.getClassificationScheme();
        JBGraphCell newCell = addRelatedObject(cell, scheme, new Rectangle(0, 0, 50, 50),
                "classification scheme", false);
        relatedCells.add(newCell);

        //Concept
        Concept concept = classification.getConcept();

        if (concept != null) {
            newCell = addRelatedObject(cell, concept, new Rectangle(0, 0, 50, 50), "value", false);
            relatedCells.add(newCell);
        }
    } catch (JAXRException e) {
        RegistryBrowser.displayError(e);
    }

    return relatedCells;
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

/**
  * According to JAXR Javadoc, there are two types of classification, internal and external and they use the Classification, Concept,     
  * and ClassificationScheme objects.  It seems the only difference between internal and external (as related to UDDI) is that the
  * name/value pair of the categorization is held in the Concept for internal classifications and the Classification for external (bypassing
  * the Concept entirely).//w ww. jav a2 s .  c om
  * 
  * The translation to UDDI is simple.  Relevant objects have a category bag which contains a bunch of KeyedReferences (name/value pairs).  
  * These KeyedReferences optionally refer to a tModel that identifies the type of category (translates to the ClassificationScheme key).  If
  * this is set and the tModel doesn't exist in the UDDI registry, then an invalid key error will occur when trying to save the object.
  * 
  * @param classifications classifications to turn into categories
  * @throws JAXRException
  */
public static CategoryBag getCategoryBagFromClassifications(Collection classifications) throws JAXRException {
    try {
        if (classifications == null || classifications.size() == 0)
            return null;

        // Classifications
        CategoryBag cbag = objectFactory.createCategoryBag();
        Iterator classiter = classifications.iterator();
        while (classiter.hasNext()) {
            Classification classification = (Classification) classiter.next();
            if (classification != null) {
                KeyedReference keyr = objectFactory.createKeyedReference();
                cbag.getKeyedReference().add(keyr);

                InternationalStringImpl iname = null;
                String value = null;
                ClassificationScheme scheme = classification.getClassificationScheme();
                if (scheme == null || (classification.isExternal() && classification.getConcept() == null)) {
                    /*
                    * JAXR 1.0 Specification: Section D6.4.4
                    * Specification related tModels mapped from Concept may be automatically
                    * categorized by the well-known uddi-org:types taxonomy in UDDI (with
                    * tModelKey uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4) as follows:
                    * The keyed reference is assigned a taxonomy value of specification.
                    */
                    keyr.setTModelKey(UDDI_ORG_TYPES);
                    keyr.setKeyValue("specification");
                } else {
                    if (classification.isExternal()) {
                        iname = (InternationalStringImpl) ((RegistryObject) classification).getName();
                        value = classification.getValue();
                    } else {
                        Concept concept = classification.getConcept();
                        if (concept != null) {
                            iname = (InternationalStringImpl) ((RegistryObject) concept).getName();
                            value = concept.getValue();
                            scheme = concept.getClassificationScheme();
                        }
                    }

                    String name = iname.getValue();
                    if (name != null)
                        keyr.setKeyName(name);

                    if (value != null)
                        keyr.setKeyValue(value);

                    if (scheme != null) {
                        Key key = scheme.getKey();
                        if (key != null && key.getId() != null)
                            keyr.setTModelKey(key.getId());
                    }
                }
            }
        }
        return cbag;
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiV3Helper.java

/**
  * According to JAXR Javadoc, there are two types of classification, internal and external and they use the Classification, Concept,     
  * and ClassificationScheme objects.  It seems the only difference between internal and external (as related to UDDI) is that the
  * name/value pair of the categorization is held in the Concept for internal classifications and the Classification for external (bypassing
  * the Concept entirely).//from w w  w.j a v a 2 s  .  co  m
  * 
  * The translation to UDDI is simple.  Relevant objects have a category bag which contains a bunch of KeyedReferences (name/value pairs).  
  * These KeyedReferences optionally refer to a tModel that identifies the type of category (translates to the ClassificationScheme key).  If
  * this is set and the tModel doesn't exist in the UDDI registry, then an invalid key error will occur when trying to save the object.
  * 
  * @param classifications classifications to turn into categories
  * @throws JAXRException
  */
public static CategoryBag getCategoryBagFromClassifications(Collection classifications) throws JAXRException {
    try {
        if (classifications == null || classifications.size() == 0)
            return null;

        // Classifications
        CategoryBag cbag = objectFactory.createCategoryBag();
        Iterator classiter = classifications.iterator();
        while (classiter.hasNext()) {
            Classification classification = (Classification) classiter.next();
            if (classification != null) {
                KeyedReference keyr = objectFactory.createKeyedReference();
                cbag.getKeyedReference().add(keyr);

                InternationalStringImpl iname = null;
                String value = null;
                ClassificationScheme scheme = classification.getClassificationScheme();
                if (scheme == null || (classification.isExternal() && classification.getConcept() == null)) {
                    /*
                    * JAXR 1.0 Specification: Section D6.4.4
                    * Specification related tModels mapped from Concept may be automatically
                    * categorized by the well-known uddi-org:types taxonomy in UDDI (with
                    * tModelKey uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4) as follows:
                    * The keyed reference is assigned a taxonomy value of specification.
                    */
                    keyr.setTModelKey(UDDI_ORG_TYPES);
                    keyr.setKeyValue("specification");
                } else {
                    if (classification.isExternal()) {
                        iname = (InternationalStringImpl) ((RegistryObject) classification).getName();
                        value = classification.getValue();
                    } else {
                        Concept concept = classification.getConcept();
                        if (concept != null) {
                            iname = (InternationalStringImpl) ((RegistryObject) concept).getName();
                            value = concept.getValue();
                            scheme = concept.getClassificationScheme();
                        }
                    }

                    String name = iname.getValue();
                    if (name != null)
                        keyr.setKeyName(name);

                    if (value != null)
                        keyr.setKeyValue(value);

                    if (scheme != null) {
                        Key key = scheme.getKey();
                        if (key != null && key.getId() != null)
                            keyr.setTModelKey(key.getId());
                    }
                }
            }
        }
        if (cbag.getKeyedReference().isEmpty())
            return null;
        else
            return cbag;
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
}