VMware Cloud Community
admin
Immortal
Immortal

finding all child objects of type X for give parent P

How can we find all child objects of type X for give parent P?

Server object supports only two find methods:

1)FindForType

2)FindAllforType

I have implemnted findRelation method in Factory and how can I use that "findRealtion" method through in-build Server object.

Reply
0 Kudos
1 Reply
sanchezs
VMware Employee
VMware Employee

Hi,

The short answer is that you can't do it directly. The idea is that the parent P, as scripting object, should declare the corresponding methods to retrieve the specific child objects X, Y and X to be used directly from scripting: P.getChildrenX(), P.getChildrenY() and P.getChildrenZ(). And then your findRelation method implementation could be based on those methods.

But in case you implemented the findRelation first and you don't want to declare those methods on your objects, then you could adapt your implementation of the findAll(String type, String query) method to accept as a query the parent object P (a string representation with the type and the id basically) and then from that point you can invoke your findRelation(...) method. And you can access to it from scripting with Server.findAllForType(type of X, string representation of P).

Nevertheless, it's recommended to provide a rich API for your plug-in objects, as it will be better for the final users.

I hope it helps.

Sergio

Reply
0 Kudos