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 and Using Classification Schemes and Concepts. 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 QueryManager.getRegistryObject method to find the classification scheme, specifying the unique identifier of the scheme as the argument. For example, the following code fragment searches for the classification scheme that is named AssociationType, using the value defined in CanonicalConstants:
String schemeId = CanonicalConstants.CANONICAL_CLASSIFICATION_SCHEME_ID_AssociationType; ClassificationScheme cScheme = (ClassificationScheme) bqm.getRegistryObject(schemeId);
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 LifeCycleManager.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.
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 named GenericOrg and adds a number of objects to it.