In the first two parts of the "API"-mini-story, I have shown how to use the API to find composites, display component states, invoke services and lastly find them back via CompositeInstanceFilter.
Another way of finding instances (just by UUID, that is conversation ID) is by querying composite sensor values - the guys that I talked about in this entry.
One of the sensors we declared was on the inbound service operation for BamOrderBookingComposite, and after firing yielded the following information:
-> Sensor: OrderProcessingStart data: Order 900.
So how to query by this info with the API? Create a sensor filter, set it on the composite instance filter, and use the good old Locator api.
ListsFilterList = new ArrayList ();
SensorFilter sFilter =
new SensorFilter("OrderProcessingStart" /* sensorname */,
Sensor.SensorDataType.STRING /* type */,
Operator.EQUALS /* operator for comparison */,
"Order 900");
sFilterList.add(sFilter);
filter = new CompositeInstanceFilter();
filter.setSensorFilter(sFilterList);
filter.setCompositeDN(getOrderBookingCompositeUri(null));
obInstances = findCompositeLoc.getCompositeInstances(filter);
// we should find one instance
boolean foundInstance = false;
for (CompositeInstance instance : obInstances)
{
if (instance.getConversationId().equals(uuid))
{
foundInstance = true;
break;
}
}
if (!foundInstance)
throw new Exception ("Could not find composite instance with id: " +
uuid + " and sensorfilter: " + sFilter);