← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20126: remove value type String constants from DataElement

 

------------------------------------------------------------
revno: 20126
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-14 17:15:27 +0700
message:
  remove value type String constants from DataElement
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ObjectMappingUtil.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14TypeHandler.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.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-08 17:04:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java	2015-09-14 10:15:27 +0000
@@ -106,73 +106,4 @@
     {
         return this == DATE || this == DATETIME;
     }
-
-    // TODO keeping this in for now, legacy reasons
-    public static ValueType getFromDataElementTypes( String type, String numberType, String textType )
-    {
-        if ( DataElement.VALUE_TYPE_STRING.equals( type ) )
-        {
-            if ( DataElement.VALUE_TYPE_LONG_TEXT.equals( textType ) )
-            {
-                return ValueType.LONG_TEXT;
-            }
-            else
-            {
-                return ValueType.TEXT;
-            }
-        }
-        else if ( DataElement.VALUE_TYPE_INT.equals( type ) )
-        {
-            if ( DataElement.VALUE_TYPE_UNIT_INTERVAL.equals( numberType ) )
-            {
-                return ValueType.UNIT_INTERVAL;
-            }
-            else if ( DataElement.VALUE_TYPE_PERCENTAGE.equals( numberType ) )
-            {
-                return ValueType.PERCENTAGE;
-            }
-            else if ( DataElement.VALUE_TYPE_INT.equals( numberType ) )
-            {
-                return ValueType.INTEGER;
-            }
-            else if ( DataElement.VALUE_TYPE_POSITIVE_INT.equals( numberType ) )
-            {
-                return ValueType.INTEGER_POSITIVE;
-            }
-            else if ( DataElement.VALUE_TYPE_ZERO_OR_POSITIVE_INT.equals( numberType ) )
-            {
-                return ValueType.INTEGER_ZERO_OR_POSITIVE;
-            }
-            else if ( DataElement.VALUE_TYPE_NEGATIVE_INT.equals( numberType ) )
-            {
-                return ValueType.INTEGER_NEGATIVE;
-            }
-            else
-            {
-                return ValueType.NUMBER;
-            }
-        }
-        else if ( DataElement.VALUE_TYPE_BOOL.equals( type ) )
-        {
-            return ValueType.BOOLEAN;
-        }
-        else if ( DataElement.VALUE_TYPE_TRUE_ONLY.equals( type ) )
-        {
-            return ValueType.TRUE_ONLY;
-        }
-        else if ( DataElement.VALUE_TYPE_DATE.equals( type ) )
-        {
-            return ValueType.DATE;
-        }
-        else if ( DataElement.VALUE_TYPE_DATETIME.equals( type ) )
-        {
-            return ValueType.DATETIME;
-        }
-        else if ( DataElement.VALUE_TYPE_USER_NAME.equals( type ) )
-        {
-            return ValueType.USERNAME;
-        }
-
-        return ValueType.TEXT; // Fall back
-    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2015-09-04 10:49:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2015-09-14 10:15:27 +0000
@@ -93,23 +93,6 @@
      */
     private static final long serialVersionUID = -7131541880444446669L;
 
-    public static final String VALUE_TYPE_INT = "int";
-    public static final String VALUE_TYPE_STRING = "string";
-    public static final String VALUE_TYPE_USER_NAME = "username";
-    public static final String VALUE_TYPE_BOOL = "bool";
-    public static final String VALUE_TYPE_TRUE_ONLY = "trueOnly";
-    public static final String VALUE_TYPE_DATE = "date";
-    public static final String VALUE_TYPE_DATETIME = "datetime";
-    public static final String VALUE_TYPE_UNIT_INTERVAL = "unitInterval";
-    public static final String VALUE_TYPE_PERCENTAGE = "percentage";
-
-    public static final String VALUE_TYPE_NUMBER = "number";
-    public static final String VALUE_TYPE_POSITIVE_INT = "posInt";
-    public static final String VALUE_TYPE_NEGATIVE_INT = "negInt";
-    public static final String VALUE_TYPE_ZERO_OR_POSITIVE_INT = "zeroPositiveInt";
-    public static final String VALUE_TYPE_TEXT = "text";
-    public static final String VALUE_TYPE_LONG_TEXT = "longText";
-
     public static final String AGGREGATION_OPERATOR_SUM = "sum";
     public static final String AGGREGATION_OPERATOR_AVERAGE_SUM = "avg_sum_org_unit"; // Sum in organisation unit
     public static final String AGGREGATION_OPERATOR_AVERAGE = "avg";
@@ -560,7 +543,7 @@
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public ValueType getValueType()
     {
-        return valueType;
+        return optionSet != null ? optionSet.getValueType() : valueType;
     }
 
     public void setValueType( ValueType valueType )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java	2015-09-04 09:29:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java	2015-09-14 10:15:27 +0000
@@ -508,71 +508,6 @@
     }
 
     @Test
-    @Ignore
-    public void testNumberTypeNumber()
-    {
-        createDataElements();
-        Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
-
-        Disjunction disjunction = query.disjunction();
-        disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_NUMBER ) );
-        query.add( disjunction );
-
-        Result result = queryService.query( query );
-
-        assertEquals( 2, result.size() );
-
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghA" ) );
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghD" ) );
-    }
-
-    @Test
-    @Ignore
-    public void testNumberTypeBoolOrInt()
-    {
-        createDataElements();
-        Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
-
-        Disjunction disjunction = query.disjunction();
-        disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_BOOL ) );
-        disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_INT ) );
-        query.add( disjunction );
-
-        Result result = queryService.query( query );
-
-        assertEquals( 4, result.size() );
-
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghB" ) );
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghC" ) );
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghE" ) );
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghF" ) );
-    }
-
-    @Test
-    public void testNumberTypeBoolOrIntOrNumber()
-    {
-        createDataElements();
-        Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
-
-        Disjunction disjunction = query.disjunction();
-        disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_NUMBER ) );
-        disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_BOOL ) );
-        disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_INT ) );
-        query.add( disjunction );
-
-        Result result = queryService.query( query );
-
-        assertEquals( 6, result.size() );
-
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghA" ) );
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghB" ) );
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghC" ) );
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghD" ) );
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghE" ) );
-        assertTrue( collectionContainsUid( result.getItems(), "deabcdefghF" ) );
-    }
-
-    @Test
     public void testDoubleEqDisjunction()
     {
         createDataElements();

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java	2015-09-04 09:29:23 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java	2015-09-14 10:15:27 +0000
@@ -194,11 +194,13 @@
                 String domainType = getSafe( values, 6, DataElementDomain.AGGREGATE.getValue(), 16 );
                 object.setDomainType( DataElementDomain.fromValue( domainType ) );
 
+                /* TODO fixme
                 object.setValueType( ValueType.getFromDataElementTypes(
                     getSafe( values, 7, DataElement.VALUE_TYPE_INT, 16 ),
                     getSafe( values, 8, DataElement.VALUE_TYPE_NUMBER, 16 ),
                     getSafe( values, 9, null, 16 )
                 ) );
+                */
 
                 object.setAggregationOperator( getSafe( values, 10, DataElement.AGGREGATION_OPERATOR_SUM, 16 ) );
                 String categoryComboUid = getSafe( values, 11, null, 11 );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ObjectMappingUtil.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ObjectMappingUtil.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ObjectMappingUtil.java	2015-09-14 10:15:27 +0000
@@ -70,12 +70,14 @@
     {
         dataElementTypeMap = new HashMap<>();
 
+        /*
         dataElementTypeMap.put( 1, DataElement.VALUE_TYPE_STRING ); // Should be Date
         dataElementTypeMap.put( 2, DataElement.VALUE_TYPE_STRING );
         dataElementTypeMap.put( 3, DataElement.VALUE_TYPE_INT );
         dataElementTypeMap.put( 4, DataElement.VALUE_TYPE_STRING );
         dataElementTypeMap.put( 5, DataElement.VALUE_TYPE_BOOL );
         dataElementTypeMap.put( 6, DataElement.VALUE_TYPE_STRING ); // Should be Object
+        */
     }
 
     public static Map<Integer, PeriodType> getPeriodTypeMap()

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14TypeHandler.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14TypeHandler.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14TypeHandler.java	2015-09-14 10:15:27 +0000
@@ -31,9 +31,6 @@
 import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM;
 import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_COUNT;
 import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_SUM;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_BOOL;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_INT;
-import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_STRING;
 
 import org.hisp.dhis.datavalue.DataValue;
 
@@ -45,48 +42,48 @@
 {
     private static final String DHIS14_TRUE = "1";
     private static final String DHIS14_FALSE = "0";
-    
+
     private static final String DHIS14_AGGREGATION_OPERATOR_SUM = "Sum";
     private static final String DHIS14_AGGREGATION_OPERATOR_AVERAGE = "Avg";
     private static final String DHIS14_AGGREGATION_OPERATOR_COUNT = "Count";
-    
+
     private static final String DHIS14_TYPE_INT = "3";
     private static final String DHIS14_TYPE_STRING = "4";
     private static final String DHIS14_TYPE_BOOL = "5";
-    
+
     // -------------------------------------------------------------------------
     // Yes/No
     // -------------------------------------------------------------------------
-    
+
     public static String convertYesNoFromDhis14( Integer value )
     {
         return value != null && value.intValue() == 1 ? DataValue.TRUE : DataValue.FALSE;
     }
-    
+
     // -------------------------------------------------------------------------
     // Boolean
     // -------------------------------------------------------------------------
-    
+
     public static String convertBooleanToDhis14( boolean value )
     {
         return value ? DHIS14_TRUE : DHIS14_FALSE;
     }
-    
+
     public static String convertBooleanToDhis14( String value )
     {
         return value.equals("true") ? "1" : "0";
     }
-    
+
     public static boolean convertBooleanFromDhis14( String value )
     {
         return value.equals( DHIS14_TRUE );
     }
-    
+
 
     // -------------------------------------------------------------------------
     // Aggregation operator
     // -------------------------------------------------------------------------
-    
+
     public static String convertAggregationOperatorToDhis14( String value )
     {
         if ( value == null || value.equals( AGGREGATION_OPERATOR_SUM ) )
@@ -101,10 +98,10 @@
         {
             return DHIS14_AGGREGATION_OPERATOR_COUNT;
         }
-        
+
         return DHIS14_AGGREGATION_OPERATOR_SUM;
     }
-    
+
     public static String convertAggregationOperatorFromDhis14( String value )
     {
         if ( value == null || value.equals( DHIS14_AGGREGATION_OPERATOR_SUM ) )
@@ -113,20 +110,21 @@
         }
         if ( value.equals( DHIS14_AGGREGATION_OPERATOR_AVERAGE ) )
         {
-            return AGGREGATION_OPERATOR_AVERAGE_SUM;            
+            return AGGREGATION_OPERATOR_AVERAGE_SUM;
         }
         if ( value.equals( DHIS14_AGGREGATION_OPERATOR_COUNT ) )
         {
             return AGGREGATION_OPERATOR_COUNT;
         }
-        
+
         return AGGREGATION_OPERATOR_SUM;
     }
 
     // -------------------------------------------------------------------------
     // Type
     // -------------------------------------------------------------------------
-    
+
+    /*
     public static String convertTypeToDhis14( String value )
     {
         if ( value == null || value.equals( VALUE_TYPE_INT ) )
@@ -141,10 +139,12 @@
         {
             return DHIS14_TYPE_BOOL;
         }
-        
+
         return DHIS14_TYPE_INT;
     }
-    
+    */
+
+    /*
     public static String convertTypeFromDhis14( String value )
     {
         if ( value == null || value.equals( DHIS14_TYPE_INT ) )
@@ -159,7 +159,8 @@
         {
             return VALUE_TYPE_BOOL;
         }
-        
+
         return VALUE_TYPE_INT;
     }
+    */
 }

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java	2015-09-04 09:29:23 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java	2015-09-14 10:15:27 +0000
@@ -119,7 +119,7 @@
         sheet.addCell( new Label( column++, row, indicator.getCode(), FORMAT_TEXT ) );
         sheet.addCell( new Label( column++, row, indicator.getDescription(), FORMAT_TEXT ) );
         sheet.addCell( new Label( column++, row, getBoolean().get( indicator.isAnnualized() ), FORMAT_TEXT ) );
-        sheet.addCell( new Label( column++, row, getType().get( indicator.getIndicatorType().getName() ), FORMAT_TEXT ) );
+        // sheet.addCell( new Label( column++, row, getType().get( indicator.getIndicatorType().getName() ), FORMAT_TEXT ) );
         sheet.addCell( new Label( column++, row, indicator.getNumeratorDescription(), FORMAT_TEXT ) );
         sheet.addCell( new Label( column++, row, expressionService.getExpressionDescription( indicator.getNumerator() ), FORMAT_TEXT ) );
         sheet.addCell( new Label( column++, row, indicator.getDenominatorDescription(), FORMAT_TEXT ) );
@@ -348,6 +348,7 @@
         return map;
     }
 
+    /*
     private static Map<String, String> getType()
     {
         Map<String, String> map = new HashMap<>();
@@ -356,6 +357,7 @@
         map.put( DataElement.VALUE_TYPE_BOOL, "Yes/No" );
         return map;
     }
+    */
 
     private static Map<String, String> getAggregationOperator()
     {