← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19904: remove InputType from Forms, use ValueType instead

 

------------------------------------------------------------
revno: 19904
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-08-31 15:23:12 +0700
message:
  remove InputType from Forms, use ValueType instead
removed:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/InputType.java
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Field.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Form.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java	2015-08-18 21:26:15 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java	2015-08-31 08:23:12 +0000
@@ -297,7 +297,7 @@
             attributesToDXF( ADXConstants.CATOPTCOMBO, categoryCombo, dvAttributes, dataElementIdScheme );
         }
         // if dataelement type is string we need to pick out the 'annotation' element
-        if ( dataElement.getType().equals( DataElement.VALUE_TYPE_STRING ) )
+        if ( dataElement.getValueType().isText() )
         {
             adxReader.moveToStartElement( ADXConstants.ANNOTATION, ADXConstants.DATAVALUE );
             if ( adxReader.isStartElement( ADXConstants.ANNOTATION ) )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java	2015-07-04 16:43:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java	2015-08-31 08:23:12 +0000
@@ -28,14 +28,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.hisp.dhis.common.NameableObjectUtils;
+import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -51,10 +45,16 @@
 import org.hisp.dhis.webapi.webdomain.form.Field;
 import org.hisp.dhis.webapi.webdomain.form.Form;
 import org.hisp.dhis.webapi.webdomain.form.Group;
-import org.hisp.dhis.webapi.webdomain.form.InputType;
 import org.springframework.util.Assert;
 import org.springframework.util.StringUtils;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -208,12 +208,12 @@
             dataElements.add( programStageDataElement.getDataElement() );
         }
 
-        return inputFromDataElements( dataElements, new ArrayList<DataElementOperand>() );
+        return inputFromDataElements( dataElements, new ArrayList<>() );
     }
 
     private static List<Field> inputFromDataElements( List<DataElement> dataElements )
     {
-        return inputFromDataElements( dataElements, new ArrayList<DataElementOperand>() );
+        return inputFromDataElements( dataElements, new ArrayList<>() );
     }
 
     private static List<Field> inputFromDataElements( List<DataElement> dataElements,
@@ -223,8 +223,7 @@
 
         for ( DataElement dataElement : dataElements )
         {
-            for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo()
-                .getSortedOptionCombos() )
+            for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() )
             {
                 if ( !isDisabled( dataElement, categoryOptionCombo, greyedFields ) )
                 {
@@ -271,66 +270,9 @@
         return false;
     }
 
-    private static InputType inputTypeFromDataElement( DataElement dataElement )
+    private static ValueType inputTypeFromDataElement( DataElement dataElement )
     {
-        // TODO harmonize / use map
-
-        if ( DataElement.VALUE_TYPE_STRING.equals( dataElement.getType() ) )
-        {
-            if ( DataElement.VALUE_TYPE_TEXT.equals( dataElement.getTextType() ) )
-            {
-                return InputType.TEXT;
-            }
-            if ( DataElement.VALUE_TYPE_LONG_TEXT.equals( dataElement.getTextType() ) )
-            {
-                return InputType.LONG_TEXT;
-            }
-        }
-        else if ( DataElement.VALUE_TYPE_INT.equals( dataElement.getType() ) )
-        {
-            if ( DataElement.VALUE_TYPE_NUMBER.equals( dataElement.getNumberType() ) )
-            {
-                return InputType.NUMBER;
-            }
-            else if ( DataElement.VALUE_TYPE_INT.equals( dataElement.getNumberType() ) )
-            {
-                return InputType.INTEGER;
-            }
-            else if ( DataElement.VALUE_TYPE_POSITIVE_INT.equals( dataElement.getNumberType() ) )
-            {
-                return InputType.INTEGER_POSITIVE;
-            }
-            else if ( DataElement.VALUE_TYPE_ZERO_OR_POSITIVE_INT.equals( dataElement.getNumberType() ) )
-            {
-                return InputType.INTEGER_ZERO_OR_POSITIVE;
-            }
-            else if ( DataElement.VALUE_TYPE_NEGATIVE_INT.equals( dataElement.getNumberType() ) )
-            {
-                return InputType.INTEGER_NEGATIVE;
-            }
-            else if ( DataElement.VALUE_TYPE_UNIT_INTERVAL.equals( dataElement.getNumberType() ) )
-            {
-                return InputType.UNIT_INTERVAL;
-            }
-            else if ( DataElement.VALUE_TYPE_PERCENTAGE.equals( dataElement.getNumberType() ) )
-            {
-                return InputType.PERCENTAGE;
-            }
-        }
-        else if ( DataElement.VALUE_TYPE_BOOL.equals( dataElement.getType() ) )
-        {
-            return InputType.BOOLEAN;
-        }
-        else if ( DataElement.VALUE_TYPE_TRUE_ONLY.equals( dataElement.getType() ) )
-        {
-            return InputType.TRUE_ONLY;
-        }
-        else if ( DataElement.VALUE_TYPE_DATE.equals( dataElement.getType() ) )
-        {
-            return InputType.DATE;
-        }
-
-        return null;
+        return dataElement.getValueType();
     }
 
     public static void fillWithDataValues( Form form, Collection<DataValue> dataValues )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Field.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Field.java	2015-02-12 08:42:09 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Field.java	2015-08-31 08:23:12 +0000
@@ -32,6 +32,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.ValueType;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -46,10 +47,10 @@
     private String categoryOptionCombo;
 
     private String value;
-    
+
     private String comment;
 
-    private InputType type;
+    private ValueType type;
 
     private String optionSet;
 
@@ -119,12 +120,12 @@
 
     @JsonProperty
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public InputType getType()
+    public ValueType getType()
     {
         return type;
     }
 
-    public void setType( InputType type )
+    public void setType( ValueType type )
     {
         this.type = type;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Form.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Form.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/Form.java	2015-08-31 08:23:12 +0000
@@ -28,18 +28,17 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.DxfNamespaces;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.hisp.dhis.common.DxfNamespaces;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -49,11 +48,11 @@
     private String label;
 
     private String subtitle;
-        
+
     private List<Group> groups = new ArrayList<>();
 
     private Map<String, Object> options = new HashMap<>();
-    
+
     public Form()
     {
     }
@@ -76,12 +75,12 @@
     {
         return subtitle;
     }
-    
+
     public void setSubtitle( String subtitle )
     {
         this.subtitle = subtitle;
     }
-    
+
     @JsonProperty( value = "groups" )
     @JacksonXmlElementWrapper( localName = "groups", namespace = DxfNamespaces.DXF_2_0 )
     @JacksonXmlProperty( localName = "group", namespace = DxfNamespaces.DXF_2_0 )
@@ -106,7 +105,7 @@
     {
         this.options = options;
     }
-    
+
     @Override
     public String toString()
     {

=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/InputType.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/InputType.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/webdomain/form/InputType.java	1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
-package org.hisp.dhis.webapi.webdomain.form;
-
-/*
- * Copyright (c) 2004-2015, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public enum InputType
-{
-    TEXT,
-    LONG_TEXT,
-    BOOLEAN,
-    TRUE_ONLY,
-    DATE,
-    NUMBER,
-    INTEGER,
-    INTEGER_POSITIVE,
-    INTEGER_NEGATIVE,
-    INTEGER_ZERO_OR_POSITIVE,
-    NEGATIVE_INTEGER,
-    UNIT_INTERVAL,
-    PERCENTAGE
-}