← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17415: add new property to idObject, haveUniqueCode (default true), useful in cases where the code is no...

 

------------------------------------------------------------
revno: 17415
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-11-11 12:39:03 +0545
message:
  add new property to idObject, haveUniqueCode (default true), useful in cases where the code is not a unique code (i.e for Option), updated ObjectBridge to only match on code if code is unique
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/Option.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.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/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java	2014-11-11 06:54:03 +0000
@@ -231,6 +231,12 @@
     }
 
     @Override
+    public boolean haveUniqueCode()
+    {
+        return true;
+    }
+
+    @Override
     public boolean isAutoGenerated()
     {
         return false;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObject.java	2014-11-11 06:54:03 +0000
@@ -60,6 +60,8 @@
 
     boolean haveUniqueNames();
 
+    boolean haveUniqueCode();
+
     boolean isAutoGenerated();
 
     String getPublicAccess();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/Option.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/Option.java	2014-09-12 08:50:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/Option.java	2014-11-11 06:54:03 +0000
@@ -51,4 +51,10 @@
         this.name = name;
         this.code = code;
     }
+
+    @Override
+    public boolean haveUniqueCode()
+    {
+        return false;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2014-10-19 08:42:32 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2014-11-11 06:54:03 +0000
@@ -506,7 +506,7 @@
                 }
             }
 
-            if ( identifiableObject.getCode() != null )
+            if ( identifiableObject.haveUniqueCode() && identifiableObject.getCode() != null )
             {
                 Map<String, IdentifiableObject> map = codeMap.get( identifiableObject.getClass() );