Service Registry 3 2005Q4 Developer's Guide

Adding Classifications to Objects

Objects can have one or more classifications based on one or more classification schemes (taxonomies). To establish a classification for an object, the client first locates the taxonomy. The client then creates a classification by using the classification scheme and a concept (a taxonomy element) within the classification scheme.

For information on creating a new classification scheme with a hierarchy of concepts, see Creating Relationships Between Objects: Associations. A classification scheme with a concept hierarchy is called an internal classification scheme.

To add a classification that uses an existing classification scheme, you usually call the BusinessQueryManager.findClassificationSchemeByName method. This method takes two arguments, a Collection of FindQualifier objects and a String that specifies a name pattern. It is an error for this method to return more than one result, so you must define the search very precisely. For example, the following code fragment searches for the classification scheme that is named AssociationType:

String schemeName = "AssociationType";
ClassificationScheme cScheme =
     bqm.findClassificationSchemeByName(null, schemeName);

After you locate the classification scheme, you call the LifeCycleManager.createClassification method, specifying three arguments: the classification scheme and the name and value of the concept.

Classification classification =
     blcm.createClassification(cScheme, "Extends", "Extends");

An alternative method is to call BusinessQueryManager.findConcepts (or BusinessQueryManagerImpl.findObjects with a "Concept" argument) to locate the concept you wish to use, and then to call another form of createClassification, with the concept as the only argument:

Classification classification =
     blcm.createClassification(concept);

After creating the classification, you call RegistryObject.addClassification to add the classification to the object.

object.addClassification(classification);

To add multiple classifications, you can create a Collection, add the classification to the Collection, and call RegistryObject.addClassifications to add the Collection to the object.

Adding Classifications: Example

For an example of adding classifications to an object, see JAXRPublishObject.java in the directory <INSTALL>/registry/samples/publish-object/src. This example creates an organization and adds a number of objects to it.

ProcedureTo Run the JAXRPublishObject Example

Steps
  1. Go to the directory <INSTALL>/registry/samples/publish-object.

  2. Type the following command:


    asant run