Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
286 views

uCMDB Java API nested query results

Hi

 

I'm trying to achieve the following with the uCMDB Java API.

I have CIs related by CICollection->Node->Interface

I'm trying to write code to get for each CI collection, nodes and interfaces. I know how to get CICollection->Node with the help of the Ucmdb_JSdk_CreateAndExecViewEx.html example (node-ip Address) but i can't figure out how i should go to the next level

 

Help is much appriciated!

Mick

0 Likes
2 Replies
Highlighted
Super Contributor.
Super Contributor.

Re: uCMDB Java API nested query results

Hi,

at first you need to create TQL CICollection->Node->Interface in your code or in UCMDB and execute it.

And then you just need to iterate result Topology:

 

Topology viewTopology = viewResult.topology();

Collection<TopologyCI> ciCollectionTopology = viewTopology.getCIsByName("ci_collection")

for (TopologyCI topologyCI: ciCollectionTopology) {

for (TopologyRelation ciCollectionMembershipNode : topologyCI..getOutgoingRelations())

TopologyCI nodeCI = ciCollectionMembershipNode.getEnd2CI();

....

}

 

 

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: uCMDB Java API nested query results

Thanks Dmitry

I got that working.

I'm  having an issue with creating the adhoc query. I have the following relationships:

CICollection
      ->Interface
      ->Node
               ->Interface.

here is a snipipt of my code:

QueryNode CiCollectionQueryNode = queryDefinition.addNode(CiCollectionNodeName).ofType(CiCollectionNodeName).queryProperty("display_label");
QueryNode NodeQueryNode = queryDefinition.addNode(Node).ofType(Node).queryProperty("display_label");
QueryNode InterfaceQueryNode = queryDefinition.addNode(Interface).ofType(Interface).queryProperty("display_label");
CiCollectionQueryNode.linkedTo(NodeQueryNode).withLinkOfType("usage").atLeast(1);
CiCollectionQueryNode.linkedTo(InterfaceQueryNode).withLinkOfType("composition").atLeast(0);
NodeQueryNode.linkedTo(InterfaceQueryNode).withLinkOfType("composition").atLeast(0);
Topology topology = queryService.executeQuery(queryDefinition)

 

This line seems to be giving me an issue:

CiCollectionQueryNode.linkedTo(InterfaceQueryNode).withLinkOfType("composition").atLeast(0);

when add this i don't get any results for interfaces at all. If i ommit this, all the interfaces get returned in the query.

Any tips?

Cheers

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.