The hasChildrenInRelation operation checks whether a given relation type has any children.

In some cases, objects are most easily located through their relationships with other objects. You can obtain all the objects that relate to another object by a given relation by calling the findRelation operation on that object. The findRelation operation finds only the relatives of a known object. The hasChildrenInRelation operation checks for the presence of objects that present a given relation property. hasChildrenInRelation checks for the presence of objects that are children of other objects and are related to their parents by a given relation type. For example, a snapshot of a virtual machine is a child of the original virtual machine. Checking for all virtual machines that are children of other virtual machines enables you to identify all snapshots.

Knowing how a child is related to its parent is useful if you develop tree viewers to view the objects in the library. The hasChildrenInRelation operation is declared as follows.

public int hasChildrenInRelation(String parentType, String parentId, String relation, String username, String password);

Type

Value

Description

String

parentType

Type of parent object. You can narrow the search by specifying the parent type, which limits the result to children related by the given relation to parents of a given parent type.

This value can be null, in which case hasChildrenInRelation checks for child objects related by the specified relation type to all types of parent.

String

parentId

ID of a particular parent object.

Specifying the parentId allows you to check for children related by a given relation to a particular parent. This check is useful if a particular parent has large numbers of children that are related to it by different relation types. The findRelation operation returns all of that parent's children, regardless of the relation type.hasChildrenInRelation checks for the presence of only the children related by the desired relation type.

This value can be null if you call hasChildrenInRelation on the root object of the hierarchy of objects.

String

relation

The type of relation by which children are related to their parents.

Relation types are specified in the vso.xml file for each plug-in.

String

username

Orchestrator user name.

String

password

Orchestrator password.

Return Value

Returns one of the following values:

1

Yes, children of the specified relation type are present

-1

No, children of the specified relation type are not present

0

Unknown, or an input parameter is invalid

Related Information

For more information, see findRelation Operation.