← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20771: Attribute. Removed value type OPTION_SET. Value set is no longer a value, rather the attribute an...

 

------------------------------------------------------------
revno: 20771
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-10-19 16:51:03 +0200
message:
  Attribute. Removed value type OPTION_SET. Value set is no longer a value, rather the attribute and data element value type will be derived from the option set if present.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataElement.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStageDataElement.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.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/ValueType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java	2015-10-19 10:28:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java	2015-10-19 14:51:03 +0000
@@ -59,7 +59,6 @@
     INTEGER_NEGATIVE( Integer.class ),
     INTEGER_ZERO_OR_POSITIVE( Integer.class ),
     TRACKER_ASSOCIATE( TrackedEntityInstance.class ),
-    OPTION_SET( String.class ),
     USERNAME( String.class ),
     FILE_RESOURCE( String.class ),
     COORDINATE( String.class);

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java	2015-09-28 19:06:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java	2015-10-19 14:51:03 +0000
@@ -542,7 +542,7 @@
 
             inputHtml += "</select>";
         }
-        else if ( ValueType.OPTION_SET == attribute.getValueType() )
+        else if ( attribute.hasOptionSet() )
         {
             inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">";
             inputHtml += "<option value=\"\" selected>" + i18n.getString( "no_value" ) + "</option>";

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java	2015-10-14 02:31:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java	2015-10-19 14:51:03 +0000
@@ -181,10 +181,13 @@
         executeSql( "update trackedentityattribute set valuetype='BOOLEAN' where valuetype='bool'" );
         executeSql( "update trackedentityattribute set valuetype='TRUE_ONLY' where valuetype='trueOnly'" );
         executeSql( "update trackedentityattribute set valuetype='DATE' where valuetype='date'" );
-        executeSql( "update trackedentityattribute set valuetype='OPTION_SET' where valuetype='optionSet'" );
+        executeSql( "update trackedentityattribute set valuetype='TEXT' where valuetype='optionSet'" );
+        executeSql( "update trackedentityattribute set valuetype='TEXT' where valuetype='OPTION_SET'" );
         executeSql( "update trackedentityattribute set valuetype='TRACKER_ASSOCIATE' where valuetype='trackerAssociate'" );
         executeSql( "update trackedentityattribute set valuetype='USERNAME' where valuetype='users'" );
         executeSql( "update trackedentityattribute set valuetype='TEXT' where valuetype is null" );
+        
+        executeSql( "update optionset set valuetype='TEXT' where valuetype is null" );
     }
 
     private void upgradeProgramStageDataElements()

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java	2015-10-02 09:07:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java	2015-10-19 14:51:03 +0000
@@ -292,7 +292,7 @@
                 return "Value is not pointing to a valid username for attribute " + trackedEntityAttribute.getUid();
             }
         }
-        else if ( ValueType.OPTION_SET == valueType && !trackedEntityAttribute.isValidOptionValue( value ) )
+        else if ( trackedEntityAttribute.hasOptionSet() && !trackedEntityAttribute.isValidOptionValue( value ) )
         {
             return "Value is not pointing to a valid option for attribute " + trackedEntityAttribute.getUid();
         }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataElement.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataElement.java	2015-09-21 09:24:27 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/DataElement.java	2015-10-19 14:51:03 +0000
@@ -65,8 +65,6 @@
 
     public static final String TYPE_DATE = "date";
 
-    public static final String TYPE_OPTION_SET = "optionSet";
-
     public static final String TYPE_TRACKER_ASSOCIATE = "trackerAssociate";
 
     public static final String TYPE_USERS = "users";
@@ -107,10 +105,6 @@
         {
             this.setType( TYPE_STRING );
         }
-        else if ( type == ValueType.OPTION_SET )
-        {
-            this.setType( TYPE_OPTION_SET );
-        }
         else if ( type == ValueType.PHONE_NUMBER )
         {
             this.setType( TYPE_PHONE_NUMBER );

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStageDataElement.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStageDataElement.java	2015-09-21 09:24:27 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStageDataElement.java	2015-10-19 14:51:03 +0000
@@ -73,8 +73,6 @@
 
     public static final String TYPE_DATE = "date";
 
-    public static final String TYPE_OPTION_SET = "optionSet";
-
     public static final String TYPE_TRACKER_ASSOCIATE = "trackerAssociate";
 
     public static final String TYPE_USERS = "users";
@@ -228,10 +226,6 @@
         {
             this.setType( TYPE_STRING );
         }
-        else if ( type == ValueType.OPTION_SET )
-        {
-            this.setType( TYPE_OPTION_SET );
-        }
         else if ( type == ValueType.PHONE_NUMBER )
         {
             this.setType( TYPE_PHONE_NUMBER );

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java	2015-10-02 11:32:31 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/PatientAttribute.java	2015-10-19 14:51:03 +0000
@@ -69,8 +69,6 @@
 
     public static final String TYPE_DATE = "date";
 
-    public static final String TYPE_OPTION_SET = "optionSet";
-
     public static final String TYPE_TRACKER_ASSOCIATE = "trackerAssociate";
 
     public static final String TYPE_USERS = "users";
@@ -166,10 +164,6 @@
         {
             this.setType( TYPE_STRING );
         }
-        else if ( type == ValueType.OPTION_SET )
-        {
-            this.setType( TYPE_OPTION_SET );
-        }
         else if ( type == ValueType.PHONE_NUMBER )
         {
             this.setType( TYPE_PHONE_NUMBER );

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java	2015-10-01 18:17:35 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java	2015-10-19 14:51:03 +0000
@@ -35,7 +35,6 @@
 import org.hisp.dhis.api.mobile.model.OptionSet;
 import org.hisp.dhis.api.mobile.model.Program;
 import org.hisp.dhis.api.mobile.model.ProgramStage;
-import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.ProgramStageDataElement;
 import org.hisp.dhis.program.ProgramStageSection;
@@ -330,7 +329,7 @@
 
         mobileAttribute.setMandatory( ppa.isMandatory() );
 
-        if ( ValueType.OPTION_SET == pa.getValueType() )
+        if ( pa.hasOptionSet() )
         {
             OptionSet optionSet = new OptionSet();
 

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java	2015-09-03 08:15:09 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java	2015-10-19 14:51:03 +0000
@@ -42,7 +42,7 @@
 
     private static final Set<ValueType> TYPES = Sets.newHashSet(
         ValueType.INTEGER, ValueType.INTEGER_POSITIVE, ValueType.INTEGER_NEGATIVE, ValueType.INTEGER_ZERO_OR_POSITIVE, ValueType.NUMBER,
-        ValueType.UNIT_INTERVAL, ValueType.PERCENTAGE, ValueType.BOOLEAN, ValueType.OPTION_SET );
+        ValueType.UNIT_INTERVAL, ValueType.PERCENTAGE, ValueType.BOOLEAN );
 
     //TODO Option set is not robust as it might contain any value type, needs to change with new Enum is in place
     @Override

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java	2015-10-08 13:50:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java	2015-10-19 14:51:03 +0000
@@ -9,6 +9,7 @@
 import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.legend.LegendService;
 import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
 import org.hisp.dhis.system.util.AttributeUtils;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
@@ -198,6 +199,8 @@
     public String execute()
         throws Exception
     {
+        OptionSet optionSet = optionService.getOptionSet( optionSetId );
+        
         TrackedEntityAttribute trackedEntityAttribute = new TrackedEntityAttribute();
 
         trackedEntityAttribute.setName( StringUtils.trimToNull( name ) );
@@ -208,6 +211,7 @@
         trackedEntityAttribute.setAggregationType( AggregationType.fromValue( aggregationType ) );
         trackedEntityAttribute.setExpression( expression );
         trackedEntityAttribute.setDisplayOnVisitSchedule( false );
+        trackedEntityAttribute.setOptionSet( optionSet );
 
         unique = unique != null;
         trackedEntityAttribute.setUnique( unique );
@@ -236,10 +240,6 @@
             trackedEntityAttribute.setOrgunitScope( orgunitScope );
             trackedEntityAttribute.setProgramScope( programScope );
         }
-        else if ( ValueType.OPTION_SET == valueType )
-        {
-            trackedEntityAttribute.setOptionSet( optionService.getOptionSet( optionSetId ) );
-        }
         else if ( ValueType.TRACKER_ASSOCIATE == valueType )
         {
             trackedEntityAttribute.setTrackedEntity( trackedEntityService.getTrackedEntity( trackedEntityId ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java	2015-09-30 07:07:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java	2015-10-19 14:51:03 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.legend.LegendService;
 import org.hisp.dhis.option.OptionService;
+import org.hisp.dhis.option.OptionSet;
 import org.hisp.dhis.system.util.AttributeUtils;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
@@ -204,6 +205,8 @@
     public String execute()
         throws Exception
     {
+        OptionSet optionSet = optionService.getOptionSet( optionSetId );
+        
         TrackedEntityAttribute trackedEntityAttribute = trackedEntityAttributeService.getTrackedEntityAttribute( id );
 
         trackedEntityAttribute.setName( StringUtils.trimToNull( name ) );
@@ -214,7 +217,7 @@
         trackedEntityAttribute.setAggregationType( AggregationType.fromValue( aggregationType ) );
         trackedEntityAttribute.setExpression( expression );
         trackedEntityAttribute.setDisplayOnVisitSchedule( false );
-        trackedEntityAttribute.setOptionSet( null );
+        trackedEntityAttribute.setOptionSet( optionSet );
 
         unique = unique != null;
         trackedEntityAttribute.setUnique( unique );
@@ -243,10 +246,6 @@
             trackedEntityAttribute.setOrgunitScope( orgunitScope );
             trackedEntityAttribute.setProgramScope( programScope );
         }
-        else if ( ValueType.OPTION_SET == valueType )
-        {
-            trackedEntityAttribute.setOptionSet( optionService.getOptionSet( optionSetId ) );
-        }
         else if ( ValueType.TRACKER_ASSOCIATE == valueType )
         {
             trackedEntityAttribute.setTrackedEntity( trackedEntityService.getTrackedEntity( trackedEntityId ) );