4.1

Table Of Contents
if (parentType.equals("Planet")) {
if (relationName.equals("OrbitingMoons")) {
Planet parentPlanet =
SolarSystemRepository.getUniqueInstance().getPlanetById(parentId);
if (parentPlanet != null) {
return parentPlanet.getMoons();
}
return null;
}
else {
throw new IndexOutOfBoundsException("Unknown relation name: "
+ relationName);
}
}
else {
return null;
}
}
You defined methods in the IPluginFactory implementation to find objects in the plugged-in technology that
relate to other objects by a certain relation type.
What to do next
Discover whether an object relates to any child objects by a given type of relation.
Discover Whether an Object has Children of a Given Relation Type
You implement the IPluginFactory.hasChildrenInRelation() method to discover whether an object relates
to any children by a given type of relation.
You can implement an if-else statement in the hasChildrenInRelation() method to check for child objects
that relate to a parent by a certain relation type. For example, you can implement a function that uses the
hasChildrenInRelation() method in the solar system example to check whether a Planet object has any moons.
The possible return values of the hasChildrenInRelation() method are Yes, No, and Unknown. If you do not
implement the hasChildrenInRelation() method, it returns Unknown.
Prerequisites
n
Set up the factory implementation class.
n
Create a public constructor that implements the IPluginFactory interface.
Procedure
u
Declare the IPluginFactory.hasChildrenInRelation() method to discover whether an object has any
children of a certain relation type.
The SolarSystemFactory example does not fully implement the hasChildrenInRelation() method and
returns unknown in all cases.
public HasChildrenResult hasChildrenInRelation(String parentType,
String parentId, String relationName) {
return HasChildrenResult.Unknown;
}
You called the IPluginFactory.hasChildrenInRelation() method to discover whether an object has any
children of a certain relation type.
vCenter Orchestrator Developer's Guide
162 VMware, Inc.