added Java API call to serach for objects using custom filters
authorVictor Kirhenshtein <victor@netxms.org>
Sat, 10 Oct 2015 07:10:26 +0000 (10:10 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Sat, 10 Oct 2015 07:10:26 +0000 (10:10 +0300)
src/java/client/netxms-base/pom.xml
src/java/client/netxms-client/pom.xml
src/java/client/netxms-client/src/main/java/org/netxms/client/NXCSession.java

index d49b5e5..33c0ce8 100644 (file)
@@ -5,7 +5,7 @@
   <groupId>org.netxms</groupId>
   <artifactId>netxms-base</artifactId>
   <packaging>bundle</packaging>
-  <version>2.0-SNAPSHOT</version>
+  <version>2.0-RC2</version>
   <name>netxms-base</name>
   <description>NetXMS base classes and commonly used utility code</description>
   <url>http://www.netxms.org</url>
index 41455f6..75990b0 100644 (file)
@@ -5,7 +5,7 @@
   <groupId>org.netxms</groupId>
   <artifactId>netxms-client</artifactId>
   <packaging>bundle</packaging>
-  <version>2.0-SNAPSHOT</version>
+  <version>2.0-RC2</version>
   <name>netxms-client</name>
   <description>NetXMS client library - complete JAVA API</description>
   <url>http://www.netxms.org</url>
index c8e837d..f41aa4b 100644 (file)
@@ -2522,6 +2522,51 @@ public class NXCSession
       }
       return result;
    }
+   
+   /**
+    * Generic object find using filter. WIll return first object matching given filter.
+    * 
+    * @param filter
+    * @return first matching object or null
+    */
+   public AbstractObject findObject(ObjectFilter filter)
+   {
+      AbstractObject result = null;
+      synchronized(objectList)
+      {
+         for(AbstractObject object : objectList.values())
+         {
+            if (filter.filter(object))
+            {
+               result = object;
+               break;
+            }
+         }
+      }
+      return result;
+   }
+
+   /**
+    * Find all objects matching given filter.
+    * 
+    * @param filter
+    * @return list of matching objects (empty list if nothing found)
+    */
+   public List<AbstractObject> filterObjects(ObjectFilter filter)
+   {
+      List<AbstractObject> result = new ArrayList<AbstractObject>();
+      synchronized(objectList)
+      {
+         for(AbstractObject object : objectList.values())
+         {
+            if (filter.filter(object))
+            {
+               result.add(object);
+            }
+         }
+      }
+      return result;
+   }
 
    /**
     * Get list of top-level objects matching given class filter. Class filter