To find objects by classification, you first establish the classification within a particular classification scheme. Then you specify the classification as an argument to the BusinessQueryManagerImpl.findObjects method.
To establish the classification within a particular classification scheme, you first find the classification scheme. Then you create a Classification object to be used as an argument to the findObjects method or another finder method.
The following code fragment finds all organizations that correspond to a particular classification within the ISO 3166 country codes classification system that is maintained by the International Organization for Standardization (ISO). See http://www.iso.org/iso/en/prods-services/iso3166ma/index.html for details. This classification scheme is provided in the sample database that is included with the Registry.
ClassificationScheme cScheme = bqm.findClassificationSchemeByName(null, "iso-ch:3166:1999"); Classification classification = blcm.createClassification(cScheme, "United States", "US"); Collection classifications = new ArrayList(); classifications.add(classification); // perform search BulkResponse response = bqm.findObjects("Organization", null, null, classifications, null, null, null); Collection orgs = response.getCollection();
The ebXML Registry Information Model Specification requires a set of canonical classification schemes to be present in an ebXML registry. Each scheme also has a set of required concepts (which are called ClassificationNode objects in the ebXML specifications). The primary purpose of the canonical classification schemes is not to classify objects but to provide enumerated types for object attributes. For example, the EmailType classification scheme provides a set of values for the type attribute of an EmailAddress object.
Table 3–3 lists and describes these canonical classification schemes.
Table 3–3 Canonical Classification Schemes
Classification Scheme |
Description |
---|---|
Defines the types of associations between RegistryObjects. |
|
Defines the types of content management services. |
|
Defines the data types for attributes in classes defined by the specification. |
|
Defines the values for the deletionScope attribute in the RemoveObjectsRequest protocol message. |
|
Defines the types of email addresses. |
|
Defines the types of error handling models for content management services. |
|
Defines the different error severity types encountered by the registry during processing of protocol messages. |
|
Defines the types of events that can occur in a registry. |
|
Defines the different ways that a content management service may be invoked by the registry. |
|
Defines the different ways in which a ClassificationScheme may assign the value of the code attribute for its ClassificationNodes. |
|
Defines the different ways in which a client may be notified by the registry of an event within a Subscription. |
|
Defines the different types of RegistryObjects a registry may support. |
|
Defines the types of telephone numbers. |
|
Defines the query languages supported by a registry. |
|
Defines the different types of status for a RegistryResponse. |
|
Defines the different types of status for a RegistryObject. |
|
Defines the groups that a User may belong to for access control purposes. |
|
Defines the roles that may be assigned to a User for access control purposes. |
To find objects that use the canonical classification schemes and their concepts, you can look up the objects by using string constants that are defined in the package org.freebxml.common.CanonicalConstants. The constants are listed in Constants for Classification Schemes.
First, you look up the classification scheme by using the value of its unique identifier:
String schemeId = CanonicalConstants.CANONICAL_CLASSIFICATION_SCHEME_ID_SubjectRole; ClassificationScheme cScheme = (ClassificationScheme) bqm.getRegistryObject(schemeId); String schemeName = getName(cScheme);
Then you look up the concept in the same way and create a classification from it:
String concId = CanonicalConstants.CANONICAL_SUBJECT_ROLE_ID_RegistryAdministrator; Concept concept = (Concept) bqm.getRegistryObject(concId); Classification classification = blcm.createClassification(concept);
Finally, you search for objects in the same way you do with a non-canonical classification scheme:
Collection classifications = new ArrayList(); classifications.add(classification); BulkResponse response = bqm.findObjects("RegistryObject", null, null, classifications, null, null, null); Collection objects = response.getCollection();
For a sample program that displays all the canonical classification schemes and their concepts, see JAXRGetCanonicalSchemes.java in the directory <INSTALL>/registry/samples/classification-schemes/src.
Go to the directory <INSTALL>/registry/samples/classification-schemes.
Type the following command:
asant get-schemes |
For examples of finding objects by classification, see JAXRSearchByClassification.java and JAXRSearchByCountryClassification.java in the directory <INSTALL>/registry/samples/search-classification/src. The first example searches for objects that use the canonical classification scheme SubjectRole, while the other example searches for organizations that use a geographical classification.
To obtain results from the JAXRSearchByCountryClassification example, you must publish an object that uses the specified classifications. Run the example in either Adding Classifications: Example or Creating an Organization: Examples first.
Go to the directory <INSTALL>/registry/samples/search-classification.
Type either of the following commands:
asant search-class asant search-geo |
The search-class target typically returns one result. The search-geo target returns results if you have run the run target in Adding Classifications: Example or the pub-org target in Creating an Organization: Examples.