Service Registry 3 2005Q4 Developer's Guide

Finding Objects by Classification

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 

AssociationType

Defines the types of associations between RegistryObjects.

ContentManagementService

Defines the types of content management services. 

DataType

Defines the data types for attributes in classes defined by the specification. 

DeletionScopeType

Defines the values for the deletionScope attribute in the RemoveObjectsRequest protocol message.

EmailType

Defines the types of email addresses. 

ErrorHandlingModel

Defines the types of error handling models for content management services. 

ErrorSeverityType

Defines the different error severity types encountered by the registry during processing of protocol messages. 

EventType

Defines the types of events that can occur in a registry. 

InvocationModel

Defines the different ways that a content management service may be invoked by the registry. 

NodeType

Defines the different ways in which a ClassificationScheme may assign the value of the code attribute for its ClassificationNodes.

NotificationOptionType

Defines the different ways in which a client may be notified by the registry of an event within a Subscription.

ObjectType

Defines the different types of RegistryObjects a registry may support.

PhoneType

Defines the types of telephone numbers. 

QueryLanguage

Defines the query languages supported by a registry. 

ResponseStatusType

Defines the different types of status for a RegistryResponse.

StatusType

Defines the different types of status for a RegistryObject.

SubjectGroup

Defines the groups that a User may belong to for access control purposes.

SubjectRole

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.

ProcedureTo Run the JAXRGetCanonicalSchemes Example

Steps
  1. Go to the directory <INSTALL>/registry/samples/classification-schemes.

  2. Type the following command:


    asant get-schemes
    

Finding Objects by Classification: Examples

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.

ProcedureTo Run the JAXRSearchByClassification and JAXRSearchByCountryClassification Examples

Before You Begin

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.

Steps
  1. Go to the directory <INSTALL>/registry/samples/search-classification.

  2. 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.