← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16353: reflect changes made to option data model in the web api

 

------------------------------------------------------------
revno: 16353
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-08-08 15:10:50 +0200
message:
  reflect changes made to option data model in the web api
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.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/trackedentity/TrackedEntityAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java	2014-07-02 12:11:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java	2014-08-08 13:10:50 +0000
@@ -33,6 +33,7 @@
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
 import org.hisp.dhis.common.BaseDimensionalObject;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
@@ -40,6 +41,7 @@
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.common.view.WithoutOrganisationUnitsView;
+import org.hisp.dhis.option.Option;
 import org.hisp.dhis.option.OptionSet;
 
 /**
@@ -93,9 +95,9 @@
     private Boolean displayInListNoProgram = false;
 
     private Integer sortOrderInListNoProgram;
-    
+
     private Boolean confidential = false;
-    
+
     private Boolean unique = false;
 
     // For Local ID type
@@ -113,8 +115,8 @@
         setAutoFields();
     }
 
-    public TrackedEntityAttribute( String name, String description, String valueType,
-        Boolean inherit, Boolean displayOnVisitSchedule )
+    public TrackedEntityAttribute( String name, String description, String valueType, Boolean inherit,
+        Boolean displayOnVisitSchedule )
     {
         this.name = name;
         this.description = description;
@@ -181,7 +183,7 @@
     }
 
     @JsonProperty( "trackedEntityAttributeGroup" )
-    @JsonView( { DetailedView.class  } )
+    @JsonView( { DetailedView.class } )
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JacksonXmlProperty( localName = "trackedEntityAttributeGroup", namespace = DxfNamespaces.DXF_2_0 )
     public TrackedEntityAttributeGroup getAttributeGroup()
@@ -325,7 +327,7 @@
     {
         this.confidential = confidential;
     }
-    
+
     // -------------------------------------------------------------------------
     // Static methods
     // -------------------------------------------------------------------------
@@ -354,4 +356,17 @@
             programScope = trackedEntityAttribute.getProgramScope();
         }
     }
+
+    public Boolean isValidOptionValue( String value )
+    {
+        for ( Option option : this.getOptionSet().getOptions() )
+        {
+            if ( option.getCode().equals( value ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java	2014-07-18 14:27:18 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java	2014-08-08 13:10:50 +0000
@@ -513,7 +513,7 @@
                 importConflicts.add( new ImportConflict( "Attribute.value", "Value is not pointing to a valid username for attribute: " + attribute ) );
             }
         }
-        else if ( TrackedEntityAttribute.TYPE_OPTION_SET.equals( teAttribute.getValueType() ) && !teAttribute.getOptionSet().getOptions().contains( attribute.getValue() ) )
+        else if ( TrackedEntityAttribute.TYPE_OPTION_SET.equals( teAttribute.getValueType() ) && !teAttribute.isValidOptionValue( attribute.getValue() ) )
         {
             importConflicts.add( new ImportConflict( "Attribute.value", "Value is not pointing to a valid option for attribute: " + attribute ) );
         }