NetXMS Support Forum

Development => General => Topic started by: 165432896 on November 15, 2011, 02:58:52 PM

Title: How to get the "object tree" and
Post by: 165432896 on November 15, 2011, 02:58:52 PM
hi:
I am developping our own console by the client java api(version 1.1.5). my friend have been ask you the get the official java-client(nxmc),but we are incapable the read it(because we are a new hand in java) .

Back to our topic:
I want to get the "object tree" just like below:
Entire Network
  + 10.0.0.0/24
  + 10.0.1.0/24
  - 10.0.2.0/24
     + 10.2.2.3/24
     + 10.2.2.4/24

How can it come true in the official java-client(nxmc)? It that some of the existing java api for it?
Best wish!

If you a free,can you tell me how the "topological graph"(ip neighbors) come true? Is it  come true just like the  "object tree"  above
Title: Re: How to get the "object tree" and
Post by: Victor Kirhenshtein on November 15, 2011, 06:17:10 PM
Hi!

In nxmc we use Eclipse viewers, so code to got parent/child relations is actually decoupled into separate pieces. Simple code to print object tree, which you can use as an example:



private void printObject(GenericObject object, int level)
{
for(int i = 0; i < level; i++)
System.out.print(' ');
System.out.println(object.getObjectName());

for(GenericObject o : object.getChildsAsArray())
printObject(o, level + 2);
}

public void main() throws Exception
{
final NXCSession session = connect();  // obtain session somehow

session.syncObjects();

GenericObject object = session.findObjectById(1, EntireNetwork.class);

printObject(object, 0);

session.disconnect();
}


Best regards,
Victor
Title: Re: How to get the "object tree" and
Post by: 165432896 on November 17, 2011, 04:48:52 AM
Thank you very much