Example usage for javax.xml.registry.infomodel Service getServiceBindings

List of usage examples for javax.xml.registry.infomodel Service getServiceBindings

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel Service getServiceBindings.

Prototype

Collection getServiceBindings() throws JAXRException;

Source Link

Document

Gets all children ServiceBindings.

Usage

From source file:JAXRQuery.java

/**
     * Searches for organizations containing a string and
     * displays data about them.//from  ww w . ja v  a 2s . 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 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.
     */* w  w w  .  j av a2s. com*/
     * @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.swing.graph.JBGraph.java

/**
 * DOCUMENT ME!/*from ww  w .j  a v  a 2  s.com*/
 *
 * @param cell DOCUMENT ME!
 * @param service DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
private ArrayList<DefaultGraphCell> showRelatedObjects(JBGraphCell cell, Service service) {
    ArrayList<DefaultGraphCell> relatedCells = new ArrayList<DefaultGraphCell>();

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

    try {
        //bindings
        Collection<?> bindings = service.getServiceBindings();
        DefaultGraphCell groupCell = createGroupFromObjectCollection(bindings);

        if (groupCell != null) {
            connectCells(cell, groupCell, "service bindings", false);
            relatedCells.add(groupCell);
        }

        //parent Organization
        Organization parentOrg = service.getProvidingOrganization();

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

    return relatedCells;
}

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

public static BusinessService getBusinessServiceFromJAXRService(Service service) throws JAXRException {
    BusinessService bs = objectFactory.createBusinessService();
    try {//from w w w .  ja v a 2 s.  com
        InternationalString iname = service.getName();

        addNames(bs.getName(), iname);

        InternationalString idesc = service.getDescription();

        addDescriptions(bs.getDescription(), idesc);

        Organization o = service.getProvidingOrganization();

        /*
         * there may not always be a key...
         */
        if (o != null) {
            Key k = o.getKey();

            if (k != null && k.getId() != null) {
                bs.setBusinessKey(k.getId());
            }

        } else {
            /*
             * gmj - I *think* this is the right thing to do
             */
            throw new JAXRException("Service has no associated organization");
        }

        if (service.getKey() != null && service.getKey().getId() != null) {
            bs.setServiceKey(service.getKey().getId());
        } else {
            bs.setServiceKey("");
        }

        CategoryBag catBag = getCategoryBagFromClassifications(service.getClassifications());
        if (catBag != null) {
            bs.setCategoryBag(catBag);
        }

        //Add the ServiceBinding information
        BindingTemplates bt = getBindingTemplates(service.getServiceBindings());
        if (bt != null) {
            bs.setBindingTemplates(bt);
        }

        log.debug("BusinessService=" + bs.toString());
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
    return bs;
}