Example usage for javax.xml.registry BusinessQueryManager findOrganizations

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:JAXRQuery.java

/**
     * Searches for organizations containing a string and
     * displays data about them.//from w  ww  . j  a  v  a 2  s.c om
     *
     * @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 orgs with names that contain qString
            BulkResponse response = bqm.findOrganizations(findQualifiers, namePatterns, null, 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 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(" --- ");
                }
            }

            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: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.
     *//from ww w. j  av  a 2  s  .co 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:JAXRQueryByNAICSClassification.java

/**
     * Searches for organizations corresponding to an NAICS
     * classification and displays data about them.
     *//*from  w  ww .j a  v a 2 s.  com*/
    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:JAXRQueryByWSDLClassification.java

/**
     * Searches for organizations using a WSDL
     * classification and displays data about them.
     *//  www  .j a  va 2 s. c  o 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) {
                }
            }
        }
    }