Example usage for javax.xml.registry BusinessQueryManager findConcepts

List of usage examples for javax.xml.registry BusinessQueryManager findConcepts

Introduction

In this page you can find the example usage for javax.xml.registry BusinessQueryManager findConcepts.

Prototype

BulkResponse findConcepts(Collection findQualifiers, Collection namePatterns, Collection classifications,
        Collection externalIdentifiers, Collection externalLinks) throws JAXRException;

Source Link

Document

Finds all Concept objects that match all of the criteria specified by the parameters of this call.

Usage

From source file:JAXRQueryByWSDLClassification.java

/**
     * Searches for organizations using a WSDL
     * classification and displays data about them.
     */* www  .  j  a  v  a2  s  .  co  m*/
     * @param qString        the string argument
     */
    public void executeQuery(String qString) {
        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 the uddi-org:types classification scheme defined
             * by the UDDI specification, using well-known key id.
             */
            String uuid_types = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4";
            ClassificationScheme uddiOrgTypes = (ClassificationScheme) bqm.getRegistryObject(uuid_types,
                    LifeCycleManager.CLASSIFICATION_SCHEME);

            // Define name pattern
            Collection<String> namePatterns = new ArrayList<String>();
            namePatterns.add("%" + qString + "%");

            /*
             * Create a classification, specifying the scheme
             *  and the taxonomy name and value defined for WSDL
             *  documents by the UDDI specification.
             */
            Classification wsdlSpecClassification = blcm.createClassification(uddiOrgTypes,
                    blcm.createInternationalString("wsdlSpec"), "wsdlSpec");

            Collection<Classification> classifications = new ArrayList<Classification>();
            classifications.add(wsdlSpecClassification);

            // Find concepts
            BulkResponse br = bqm.findConcepts(null, namePatterns, classifications, null, null);
            Collection specConcepts = br.getCollection();

            // Display information about the concepts found
            int numConcepts = 0;

            if (specConcepts.isEmpty()) {
                System.out.println("No WSDL specification concepts found");
            } else {
                for (Object sc : specConcepts) {
                    numConcepts++;

                    Concept concept = (Concept) sc;

                    String name = getName(concept);

                    Collection links = concept.getExternalLinks();

                    System.out.println("\nSpecification Concept:\n\tName: " + name + "\n\tKey: " + getKey(concept)
                            + "\n\tDescription: " + getDescription(concept));

                    if (links.size() > 0) {
                        ExternalLink link = (ExternalLink) links.iterator().next();
                        System.out.println("\tURL of WSDL document: '" + link.getExternalURI() + "'");
                    }

                    // Find organizations that use this concept
                    Collection<Concept> specConcepts1 = new ArrayList<Concept>();
                    specConcepts1.add(concept);

                    br = bqm.findOrganizations(null, null, null, specConcepts1, null, null);

                    Collection orgs = br.getCollection();

                    // Display information about organizations
                    if (!(orgs.isEmpty())) {
                        System.out.println("Organizations using the '" + name + "' WSDL Specification:");
                    } else {
                        System.out.println("No Organizations using the '" + name + "' WSDL Specification");
                    }

                    for (Object o : orgs) {
                        Organization org = (Organization) o;
                        System.out.println("\tName: " + getName(org) + "\n\tKey: " + getKey(org)
                                + "\n\tDescription: " + getDescription(org));
                    }
                }
            }

            System.out.println("Found " + numConcepts + " concepts");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // At end, close connection to registry
            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }