dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39298
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19916: minor changes, ValueType usage
------------------------------------------------------------
revno: 19916
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-09-01 12:31:21 +0700
message:
minor changes, ValueType usage
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueDailyConverter.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/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2015-08-31 08:31:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2015-09-01 05:31:21 +0000
@@ -28,15 +28,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.dataset.DataSet.NO_EXPIRY;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+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 com.google.common.collect.Sets;
import org.hisp.dhis.analytics.AggregationType;
import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.common.BaseDimensionalObject;
@@ -59,13 +57,14 @@
import org.hisp.dhis.schema.annotation.PropertyRange;
import org.hisp.dhis.util.ObjectUtils;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-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 com.google.common.collect.Sets;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.hisp.dhis.dataset.DataSet.NO_EXPIRY;
/**
* A DataElement is a definition (meta-information about) of the entities that
@@ -250,10 +249,7 @@
}
}
- for ( DataElementGroup group : updates )
- {
- addDataElementGroup( group );
- }
+ updates.forEach( this::addDataElementGroup );
}
public void addDataSet( DataSet dataSet )
@@ -273,7 +269,7 @@
*/
public boolean isNumericType()
{
- return VALUE_TYPE_INT.equals( type );
+ return valueType.isNumeric();
}
/**
@@ -281,7 +277,8 @@
*/
public boolean isDateType()
{
- return VALUE_TYPE_DATE.equals( type ) || VALUE_TYPE_DATETIME.equals( type );
+ // TODO optimize when using persisted valueType
+ return ValueType.DATE == getValueType() || ValueType.DATETIME == getValueType();
}
/**
@@ -388,13 +385,13 @@
{
if ( dataSet.getSources().contains( unit ) )
{
- return true;
+ return true;
}
}
-
+
return false;
}
-
+
/**
* Returns the PeriodType of the DataElement, based on the PeriodType of the
* DataSet which the DataElement is associated with. If this data element has
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java 2015-09-01 05:20:38 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java 2015-09-01 05:31:21 +0000
@@ -344,7 +344,6 @@
out.write( SEPARATOR_B );
out.write( SEPARATOR_B );
}
-
else if ( ValueType.DATE == valueType || ValueType.DATETIME == valueType )
{
out.write( SEPARATOR_B );
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueDailyConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueDailyConverter.java 2015-07-08 05:02:25 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueDailyConverter.java 2015-09-01 05:31:21 +0000
@@ -40,6 +40,7 @@
import java.util.zip.ZipOutputStream;
import org.amplecode.quick.BatchHandler;
+import org.hisp.dhis.common.ValueType;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -665,12 +666,11 @@
private ZipOutputStream getCSVDataExportField( ZipOutputStream out, DeflatedDataValueDaily value )
{
-
- String dataElementType = dataElementService.getDataElement( value.getDataElementId() ).getType();
+ ValueType valueType = dataElementService.getDataElement( value.getDataElementId() ).getValueType();
try
{
- if ( dataElementType.equals( DataElement.VALUE_TYPE_STRING ) )
+ if ( valueType.isText() )
{
out.write( getCsvValue( csvEncode( value.getValue() ) ) );
out.write( SEPARATOR_B );
@@ -679,8 +679,7 @@
out.write( SEPARATOR_B );
out.write( SEPARATOR_B );
}
-
- else if ( dataElementType.equals( DataElement.VALUE_TYPE_BOOL ) )
+ else if ( ValueType.BOOLEAN == valueType )
{
out.write( SEPARATOR_B );
out.write( getCsvValue( csvEncode( Dhis14TypeHandler.convertBooleanToDhis14( value.getValue() ) ) ) );
@@ -689,14 +688,8 @@
out.write( SEPARATOR_B );
out.write( SEPARATOR_B );
}
-
- else if ( dataElementType.equals( DataElement.VALUE_TYPE_NUMBER )
- || dataElementType.equals( DataElement.VALUE_TYPE_INT )
- || dataElementType.equals( DataElement.VALUE_TYPE_NEGATIVE_INT )
- || dataElementType.equals( DataElement.VALUE_TYPE_POSITIVE_INT )
- || dataElementType.equals( DataElement.VALUE_TYPE_ZERO_OR_POSITIVE_INT ) )
+ else if ( valueType.isNumeric() )
{
-
totalEntry = new BigDecimal( "0" );
out.write( getCsvValue( value.getDay1() ) );
addTotalEntry( value.getDay1() );
@@ -765,9 +758,7 @@
out.write( getCsvValue( totalEntry + "" ) );
}
-
- else if ( dataElementType.equals( DataElement.VALUE_TYPE_DATE )
- || dataElementType.equals( DataElement.VALUE_TYPE_DATETIME ) )
+ else if ( ValueType.DATE == valueType || ValueType.DATETIME == valueType )
{
out.write( SEPARATOR_B );
out.write( SEPARATOR_B );