An Organization object is probably the most complex registry object. This object normally includes the following attributes, in addition to those common to all objects:
One or more PostalAddress objects.
One or more TelephoneNumber objects.
A PrimaryContact object, which is a User object. A User object normally includes a PersonName object and collections of TelephoneNumber, EmailAddress, and PostalAddress objects.
One or more Service objects and their associated ServiceBinding objects.
An organization can also have one or more child organizations, which can in turn have children, to form a hierarchy of organizations.
The following code fragment creates an organization and specifies its name, description, postal address, and telephone number.
// Create organization name and description Organization org = blcm.createOrganization("The ebXML Coffee Break"); InternationalString is = blcm.createInternationalString("Purveyor of " + "the finest coffees. Established 1905"); org.setDescription(is); // create postal address for organization String streetNumber = "99"; String street = "Imaginary Ave. Suite 33"; String city = "Imaginary City"; String state = "NY"); String country = "USA"); String postalCode = "00000"; String type = "Type US"; PostalAddress postAddr = blcm.createPostalAddress(streetNumber, street, city, state, country, postalCode, type); org.setPostalAddress(postAddr); // create telephone number for organization TelephoneNumber tNum = blcm.createTelephoneNumber(); tNum.setCountryCode("1"); tNum.setAreaCode("100"); tNum.setNumber("100-1000"); tNum.setType("OfficePhone"); Collection tNums = new ArrayList(); tNums.add(tNum); org.setTelephoneNumbers(tNums);
The telephone number type is the value of a concept in the PhoneType classification scheme: "OfficePhone", "MobilePhone", "HomePhone", "FAX", or "Beeper".
To create a hierarchy of organizations, use the Organization.addChildOrganization method to add one organization to another, or use the Organization.addChildOrganizations method to add a Collection of organizations to another.
For examples of creating an organization, see JAXRPublishOrg.java and JAXRPublishOrgNoPC.java in the directory <INSTALL>/registry/samples/organizations/src.
The JAXRPublishOrg example creates an organization, its primary contact, and a service and service binding. The example displays the unique identifiers for the organization, user, and service so that you can use the identifiers later when you delete the objects. This example creates a fictitious User as the primary contact for the organization.
The other example, JAXRPublishOrgNoPC.java, does not set a primary contact for the organization. In this case, the primary contact by default is the User who is authenticated when you run the program.
Go to the directory <INSTALL>/registry/samples/organizations.
Type the following commands:
asant pub-org asant pub-org-nopc |
For examples of publishing and retrieving an organization hierarchy, see JAXRPublishOrgFamily.java and JAXRSearchOrgFamily.java in the directory<INSTALL>/registry/samples/organizations/src.