← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5108: Mapping uids to internal identifiers

 

------------------------------------------------------------
revno: 5108
committer: Bob Jolliffe bobjolliffe@xxxxxxxxx
branch nick: dhis2
timestamp: Thu 2011-11-03 16:01:58 +0000
message:
  Mapping uids to internal identifiers
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AbstractIdentifiableObject.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AbstractIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AbstractIdentifiableObject.java	2011-11-03 01:02:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AbstractIdentifiableObject.java	2011-11-03 16:01:58 +0000
@@ -194,6 +194,26 @@
     }
 
     /**
+     * Get a map of uids to internal identifiers
+     *
+     * @param objects the IdentifiableObjects to put in the map
+     * @return the map
+     */
+    public static Map<String, Integer> getUIDMap( Collection<? extends AbstractIdentifiableObject> objects )
+    {
+        Map<String, Integer> map = new HashMap<String, Integer>();
+        for ( IdentifiableObject object : objects )
+        {
+            String uid = object.getUid();
+            int internalId = object.getId();
+
+            map.put( uid, internalId );
+        }
+
+        return map;
+    }
+
+    /**
      * Get a map of codes to internal identifiers
      *
      * @param objects the NameableObjects to put in the map
@@ -221,6 +241,6 @@
             }
         }
         return map;
-    }
+    }    
 
 }