← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19962: Removed ValueType getFromAttribute

 

------------------------------------------------------------
revno: 19962
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-09-03 12:21:08 +0200
message:
  Removed ValueType getFromAttribute
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.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-09-03 09:36:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java	2015-09-03 10:21:08 +0000
@@ -28,13 +28,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.google.common.collect.Lists;
+import java.util.Date;
+import java.util.List;
+
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityInstance;
 
-import java.util.Date;
-import java.util.List;
+import com.google.common.collect.Lists;
 
 /**
  * @author Lars Helge Overland
@@ -195,34 +195,4 @@
 
         return ValueType.TEXT; // Fall back
     }
-
-    /**
-     * TODO replace string value type on attribute with ValueType and remove
-     * this method.
-     */
-    public static ValueType getFromAttribute( TrackedEntityAttribute attribute )
-    {
-        if ( TrackedEntityAttribute.TYPE_NUMBER.equals( attribute.getValueType() ) || DataElement.VALUE_TYPE_INT.equals( attribute.getValueType() ) )
-        {
-            return ValueType.NUMBER;
-        }
-        else if ( TrackedEntityAttribute.TYPE_BOOL.equals( attribute.getValueType() ) || TrackedEntityAttribute.TYPE_TRUE_ONLY.equals( attribute.getValueType() ) )
-        {
-            return ValueType.BOOLEAN;
-        }
-        else if ( TrackedEntityAttribute.TYPE_DATE.equals( attribute.getValueType() ) )
-        {
-            return ValueType.DATE;
-        }
-        else if ( TrackedEntityAttribute.TYPE_TRACKER_ASSOCIATE.equals( attribute.getValueType() ) )
-        {
-            return ValueType.TRACKER_ASSOCIATE;
-        }
-        else if ( TrackedEntityAttribute.TYPE_USERS.equals( attribute.getValueType() ) )
-        {
-            return ValueType.USERNAME;
-        }
-
-        return ValueType.TEXT; // Fall back
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2015-09-01 09:22:27 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2015-09-03 10:21:08 +0000
@@ -289,10 +289,9 @@
 
         for ( TrackedEntityAttribute attribute : table.getProgram().getTrackedEntityAttributes() )
         {
-            ValueType valueType = ValueType.getFromAttribute( attribute );
-            String dataType = getColumnType( valueType );
+            String dataType = getColumnType( attribute.getValueType() );
             String dataClause = attribute.isNumericType() ? numericClause : attribute.isDateType() ? dateClause : "";
-            String select = getSelectClause( valueType );
+            String select = getSelectClause( attribute.getValueType() );
 
             String sql = "(select " + select + " from trackedentityattributevalue where trackedentityinstanceid=pi.trackedentityinstanceid " + 
                 "and trackedentityattributeid=" + attribute.getId() + dataClause + ") as " + quote( attribute.getUid() );
@@ -304,7 +303,7 @@
         for ( TrackedEntityAttribute attribute : table.getProgram().getTrackedEntityAttributesWithLegendSet() )
         {
             String column = quote( attribute.getUid() + PartitionUtils.SEP + attribute.getLegendSet().getUid() );
-            String select = getSelectClause( ValueType.getFromAttribute( attribute ) );
+            String select = getSelectClause( attribute.getValueType() );
             
             String sql = "(select l.uid from maplegend l inner join maplegendsetmaplegend lsl on l.maplegendid=lsl.maplegendid " +
                 "inner join trackedentityattributevalue av on l.startvalue <= " + select + " and l.endvalue > " + select + " " +