Finding objects by external identifier is similar to finding objects by classification. You first find the classification scheme, then create an ExternalIdentifier object to be used as an argument to the BusinessQueryManagerImpl.findObjects method or another finder method.
The following code fragment finds all registry objects that contain the Sun Microsystems stock ticker symbol as an external identifier. You need to create an external classification scheme named NASDAQ for this example to work. See Adding External Identifiers to Objects for details on how to perform this task.
The collection of external identifiers is supplied as the next-to-last argument of the findObjects method.
String schemeId = "urn:devguide:samples:ClassificationScheme:NASDAQ"; ClassificationScheme cScheme = (ClassificationScheme) bqm.getRegistryObject(schemeId); ExternalIdentifier extId = blcm.createExternalIdentifier(cScheme, "%Sun%", "SUNW"); Collection extIds = new ArrayList(); extIds.add(extId); // perform search BulkResponse response = bqm.findObjects("RegistryObject", null, null, null, null, extIds, null); Collection objects = response.getCollection();
For an example of finding objects by external identifier, see JAXRSearchByExternalIdentifier.java in the directory install/registry-samples/search-external-identifier/src, which searches for objects that use the NASDAQ classification scheme.
To obtain results from this example, first run the publish-object example described in Adding Classifications: Example.
Go to the directory install/registry-samples/search-external-identifier.
Type the following command:
Ant-base/ant run |
The output of the run target looks something like this:
run: [java] Query URL is http://localhost:6480/soar/registry/soap [java] Publish URL is http://localhost:6480/soar/registry/soap [java] Created connection to registry [java] Got registry service, query manager, and lifecycle manager [java] Searching by external identifier with name=%Sun% and value=SUNW in scheme NASDAQ [java] Object type is Organization [java] Object name: GenericOrg [java] Object description: Generic organization [java] Object identifier: urn:uuid:f23cffcd-23d2-4171-ba41-f2d1547158f8 [java] External identifier name is Sun [java] External identifier value is SUNW [java] External identifier classification scheme is NASDAQ [java] --- |