|
An operation that determines the presence of a Managed Object based on certain properties in the database and recovers the same from the database is called Searching and Retrieving of Managed Objects.
TopoAPI provides a number of methods for this functionality.
Searching for Managed Objects in the Database
During the operation of searching for Managed Objects in the database, only the keys of the Managed Object would be returned. This operations involves searching of Managed Objects in the database and returns a value which indicates the presence or absence of the Managed Object in the database.
A list of the functionality and the methods to perform the same are listed here:
| Functionality |
Method Provided |
|---|---|
|
Searching for Managed Objects based on specific criteria (matching all the criteria listed) |
|
|
Searching for Managed Objects based on specific criteria (option for returning the object keys either matching all the criteria or matching any of the criteria) |
|
|
Checking for the presence of a Managed Object in the database (returns only a boolean value) |
Sample code snippets are given here illustrating the usage of these methods:
Using isManagedObjectPresent(String)
|
{ topo.isManagedObjectPresent(objA) ..
System.out.println("isManagedObjectPresent "+topo.isManagedObjectPresent(objA)); .. } |
Using getObjectNamesWithProps(Properties)
|
Properties p = new Properties (); p.put ("name","s*"); p.put ("type","Windows"); Vector v = topoApi.getObjectNamesWithProps(p); |
Using getObjectNamesWithProps(Properties,boolean)
|
Properties p = new Properties (); p.put ("type", "Windows"); p.put ("ipAddress", "192.168.4.*"); Vector v = topoApi.getObjectNamesWithProps(p,false); |
Here, if the second argument specified is true, then keys are returned for objects that match any of the given criteria. If the argument specified is false, then keys are returned for objects which match all of the specified criteria.
|
|
Note: You can use wild card characters to search for Managed Objects in the database. You can refer to the section Match Criteria Patterns to get to know all the wild card characters that can be used in NMS. |
Retrieving Managed Objects from the Database
The objects that have been checked into the database can be fetched by using methods available in the TopoAPI. Here, the Managed Object matching the object key would be returned.
A list of functionality and methods used for the same are specified here:
| Functionality |
Method Provided |
|---|---|
|
Retrieving names of all Managed Objects from the database. |
getCompleteList() This method returns a Vector containing the names of all the ManagedObjects in the database. |
|
Retrieves a Managed Object from the database by specifying the object key |
|
|
Retrieves a Network Object from the database |
|
|
Retrieves a Node Object from the database |
|
|
Retrieves an Interface Object from the database |
Sample code snippets are provided here which illustrate the usage of these methods:
Using getByName(String)
|
.. { Managed Object mobj = topo.getByName(objA); // where topo is the handle to TopoAPI and objA is the key of the object to be fetched from the database .. } |
Using getNet(String)
|
.. { Network net = topo.getNet(netA); // where topo is the handle to TopoAPI and netA is the key of the network object to be fetched from the database .. } |
Using getNode(String)
|
.. { Node n = topo.getNode(nodeA); // where topo is the handle to TopoAPI and nodeA is the key of the node object to be fetched from the database .. } |
Using getInterface(String)
|
.. { IpAddress ip = topo.getInterface(ipA); // where topo is the handle to TopoAPI and ipA is the key of the Interface object to be fetched from the database .. } |
All the above methods mentioned for retrieving Managed Objects from the database would return a null, if the specified Managed Object is not present in the database.
|