← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18469: Query item, code health, using OptionSet object instead of string id

 

------------------------------------------------------------
revno: 18469
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-03 17:54:51 +0100
message:
  Query item, code health, using OptionSet object instead of string id
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.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/QueryItem.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java	2015-03-03 16:42:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java	2015-03-03 16:54:51 +0000
@@ -33,6 +33,7 @@
 import java.util.List;
 
 import org.hisp.dhis.legend.LegendSet;
+import org.hisp.dhis.option.OptionSet;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.util.ObjectUtils;
 
@@ -52,7 +53,7 @@
     
     private String valueType;
     
-    private String optionSet;
+    private OptionSet optionSet;
 
     // -------------------------------------------------------------------------
     // Constructors
@@ -63,7 +64,7 @@
         this.item = item;
     }
 
-    public QueryItem( NameableObject item, LegendSet legendSet, String valueType, String optionSet )
+    public QueryItem( NameableObject item, LegendSet legendSet, String valueType, OptionSet optionSet )
     {
         this.item = item;
         this.legendSet = legendSet;
@@ -71,7 +72,7 @@
         this.optionSet = optionSet;
     }
     
-    public QueryItem( NameableObject item, QueryOperator operator, String filter, String valueType, String optionSet )
+    public QueryItem( NameableObject item, QueryOperator operator, String filter, String valueType, OptionSet optionSet )
     {
         this.item = item;
         this.valueType = valueType;
@@ -124,6 +125,11 @@
         return legendSet != null ? legendSet.getUid() : null;
     }
     
+    public String getOptionSetUid()
+    {
+        return optionSet != null ? optionSet.getUid() : null;
+    }
+    
     public boolean hasFilter()
     {
         return filters != null && !filters.isEmpty();
@@ -135,7 +141,7 @@
         
         for ( TrackedEntityAttribute attribute : attributes )
         {
-            queryItems.add( new QueryItem( attribute, attribute.getLegendSet(), attribute.getValueType(), attribute.hasOptionSet() ? attribute.getOptionSet().getUid() : null ) );
+            queryItems.add( new QueryItem( attribute, attribute.getLegendSet(), attribute.getValueType(), attribute.hasOptionSet() ? attribute.getOptionSet() : null ) );
         }
         
         return queryItems;
@@ -224,12 +230,12 @@
         this.valueType = valueType;
     }
 
-    public String getOptionSet()
+    public OptionSet getOptionSet()
     {
         return optionSet;
     }
 
-    public void setOptionSet( String optionSet )
+    public void setOptionSet( OptionSet optionSet )
     {
         this.optionSet = optionSet;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-03-03 16:42:44 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-03-03 16:54:51 +0000
@@ -183,7 +183,7 @@
         {
             String legendSet = item.hasLegendSet() ? item.getLegendSet().getUid() : null;
             
-            grid.addHeader( new GridHeader( item.getItem().getUid(), item.getItem().getName(), item.getTypeAsString(), false, true, item.getOptionSet(), legendSet ) );
+            grid.addHeader( new GridHeader( item.getItem().getUid(), item.getItem().getName(), item.getTypeAsString(), false, true, item.getOptionSetUid(), legendSet ) );
         }
 
         grid.addHeader( new GridHeader( "value", "Value", Double.class.getName(), false, false ) );
@@ -292,7 +292,7 @@
 
         for ( QueryItem item : params.getItems() )
         {
-            grid.addHeader( new GridHeader( item.getItem().getUid(), item.getItem().getName(), item.getTypeAsString(), false, true, item.getOptionSet(), item.getLegendSetUid() ) );
+            grid.addHeader( new GridHeader( item.getItem().getUid(), item.getItem().getName(), item.getTypeAsString(), false, true, item.getOptionSetUid(), item.getLegendSetUid() ) );
         }
 
         // ---------------------------------------------------------------------
@@ -672,14 +672,14 @@
 
         if ( de != null ) //TODO check if part of program
         {
-            return new QueryItem( de, legendSet, de.getType(), de.hasOptionSet() ? de.getOptionSet().getUid() : null );
+            return new QueryItem( de, legendSet, de.getType(), de.getOptionSet() );
         }
 
         TrackedEntityAttribute at = attributeService.getTrackedEntityAttribute( item );
 
         if ( at != null )
         {
-            return new QueryItem( at, legendSet, at.getValueType(), at.hasOptionSet() ? at.getOptionSet().getUid() : null );
+            return new QueryItem( at, legendSet, at.getValueType(), at.getOptionSet() );
         }
 
         throw new IllegalQueryException( "Item identifier does not reference any data element or attribute part of the program: " + item );

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2015-02-25 15:59:31 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2015-03-03 16:54:51 +0000
@@ -490,7 +490,7 @@
             throw new IllegalQueryException( "Attribute does not exist: " + item );
         }
         
-        return new QueryItem( at, null, at.getValueType(), at.hasOptionSet() ? at.getOptionSet().getUid() : null );
+        return new QueryItem( at, null, at.getValueType(), at.getOptionSet() );
     }
     
     /**