dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02956
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 978: Added lastUpdated element in DXF for data element, indicator, orgunit.
------------------------------------------------------------
revno: 978
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-11-04 19:24:30 +0100
message:
Added lastUpdated element in DXF for data element, indicator, orgunit.
modified:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14DateUtil.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/IndicatorConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/OrganisationUnitConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/IndicatorConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java
dhis-2/pom.xml
--
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-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14DateUtil.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14DateUtil.java 2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14DateUtil.java 2009-11-04 18:24:30 +0000
@@ -30,6 +30,8 @@
import java.util.Calendar;
import java.util.Date;
+import org.hisp.dhis.system.util.DateUtils;
+
/**
* @author Lars Helge Overland
* @version $Id$
@@ -52,4 +54,24 @@
return date;
}
+
+ public static Date getDate( String dateString )
+ {
+ if ( dateString == null || dateString.trim().length() < 10 || !DateUtils.dateIsValid( dateString.substring( 0, 10 ) ) )
+ {
+ return null;
+ }
+
+ return DateUtils.getMediumDate( dateString.substring( 0, 10 ) );
+ }
+
+ public static String getDateString( Date date )
+ {
+ if ( date == null )
+ {
+ return "";
+ }
+
+ return DateUtils.getMediumDateString( date ) + "T00:00:00";
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java 2009-11-02 15:55:44 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java 2009-11-04 18:24:30 +0000
@@ -52,6 +52,7 @@
import org.hisp.dhis.importexport.XMLConverter;
import org.hisp.dhis.importexport.analysis.ImportAnalyser;
import org.hisp.dhis.importexport.converter.AbstractDataElementConverter;
+import org.hisp.dhis.importexport.dhis14.util.Dhis14DateUtil;
import org.hisp.dhis.importexport.dhis14.util.Dhis14ObjectMappingUtil;
import org.hisp.dhis.importexport.dhis14.util.Dhis14ParsingUtils;
import org.hisp.dhis.importexport.mapping.NameMappingUtil;
@@ -181,7 +182,7 @@
writer.writeElement( FIELD_AGGREGATION_OPERATOR, convertAggregationOperatorToDhis14( object.getAggregationOperator() ) );
writer.writeElement( FIELD_SELECTED, String.valueOf( 0 ) );
writer.writeElement( FIELD_LAST_USER, String.valueOf( 1 ) );
- writer.writeElement( FIELD_LAST_UPDATED, String.valueOf( VALID_FROM ) );
+ writer.writeElement( FIELD_LAST_UPDATED, Dhis14DateUtil.getDateString( object.getLastUpdated() ) );
writer.closeElement();
@@ -212,6 +213,7 @@
element.setType( Dhis14ObjectMappingUtil.getDataElementTypeMap().get( Integer.parseInt( values.get( FIELD_DATA_TYPE ) ) ) );
element.setAggregationOperator( convertAggregationOperatorFromDhis14( values.get( FIELD_AGGREGATION_OPERATOR ) ) );
element.setSortOrder( parseInt( values.get( FIELD_SORT_ORDER ) ) );
+ element.setLastUpdated( Dhis14DateUtil.getDate( values.get( FIELD_LAST_UPDATED ) ) );
element.getCategoryCombo().setId( 1 ); //TODO hack
element.setSaved( convertBooleanFromDhis14( values.get( FIELD_SAVE_CALCULATED ) ) );
element.setExpression( new Expression( expressionMap.get( element.getId() ), null, new HashSet<DataElement>() ) );
@@ -234,6 +236,7 @@
element.setType( Dhis14ObjectMappingUtil.getDataElementTypeMap().get( Integer.parseInt( values.get( FIELD_DATA_TYPE ) ) ) );
element.setAggregationOperator( convertAggregationOperatorFromDhis14( values.get( FIELD_AGGREGATION_OPERATOR ) ) );
element.setSortOrder( parseInt( values.get( FIELD_SORT_ORDER ) ) );
+ element.setLastUpdated( Dhis14DateUtil.getDate( values.get( FIELD_LAST_UPDATED ) ) );
element.getCategoryCombo().setId( 1 ); //TODO hack
NameMappingUtil.addDataElementAggregationOperatorMapping( element.getId(), element.getAggregationOperator() );
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/IndicatorConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/IndicatorConverter.java 2009-11-02 15:55:44 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/IndicatorConverter.java 2009-11-04 18:24:30 +0000
@@ -46,6 +46,7 @@
import org.hisp.dhis.importexport.XMLConverter;
import org.hisp.dhis.importexport.analysis.ImportAnalyser;
import org.hisp.dhis.importexport.converter.AbstractIndicatorConverter;
+import org.hisp.dhis.importexport.dhis14.util.Dhis14DateUtil;
import org.hisp.dhis.importexport.dhis14.util.Dhis14ParsingUtils;
import org.hisp.dhis.importexport.mapping.NameMappingUtil;
import org.hisp.dhis.indicator.Indicator;
@@ -165,7 +166,7 @@
writer.writeElement( FIELD_DENOMINATOR_TIME_LAG, String.valueOf( 0 ) );
writer.writeElement( FIELD_DENOMINATOR_DESCRIPTION, object.getDenominatorDescription() );
writer.writeElement( FIELD_LAST_USER, String.valueOf( 1 ) );
- writer.writeElement( FIELD_LAST_UPDATED, String.valueOf( VALID_FROM ) );
+ writer.writeElement( FIELD_LAST_UPDATED, Dhis14DateUtil.getDateString( object.getLastUpdated() ) );
writer.closeElement();
}
@@ -200,6 +201,7 @@
indicator.setDenominator( convertExpressionFromDhis14( values.get( FIELD_DENOMINATOR ), dataElementMapping, 1, indicator.getName() ) );
indicator.setSortOrder( parseInt( values.get( FIELD_SORT_ORDER ) ) );
+ indicator.setLastUpdated( Dhis14DateUtil.getDate( values.get( FIELD_LAST_UPDATED ) ) );
read( indicator, GroupMemberType.NONE, params );
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/OrganisationUnitConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/OrganisationUnitConverter.java 2009-03-19 14:31:44 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/OrganisationUnitConverter.java 2009-11-04 18:24:30 +0000
@@ -41,6 +41,7 @@
import org.hisp.dhis.importexport.XMLConverter;
import org.hisp.dhis.importexport.analysis.ImportAnalyser;
import org.hisp.dhis.importexport.converter.AbstractOrganisationUnitConverter;
+import org.hisp.dhis.importexport.dhis14.util.Dhis14DateUtil;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -119,7 +120,7 @@
writer.writeElement( FIELD_ACTIVE, convertBooleanToDhis14( unit.isActive() ) );
writer.writeElement( FIELD_SELECTED, String.valueOf( 0 ) );
writer.writeElement( FIELD_LAST_USER, String.valueOf( 1 ) );
- writer.writeElement( FIELD_LAST_UPDATED, String.valueOf( VALID_FROM ) );
+ writer.writeElement( FIELD_LAST_UPDATED, Dhis14DateUtil.getDateString( unit.getLastUpdated() ) );
writer.closeElement();
}
@@ -137,6 +138,7 @@
unit.setShortName( values.get( FIELD_SHORT_NAME ) );
unit.setCode( values.get( FIELD_CODE ) );
unit.setActive( true );
+ unit.setLastUpdated( Dhis14DateUtil.getDate( values.get( FIELD_LAST_UPDATED ) ) );
read( unit, GroupMemberType.NONE, params );
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java 2009-08-12 21:06:37 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java 2009-11-04 18:24:30 +0000
@@ -43,6 +43,7 @@
import org.hisp.dhis.importexport.XMLConverter;
import org.hisp.dhis.importexport.converter.AbstractDataElementConverter;
import org.hisp.dhis.importexport.mapping.NameMappingUtil;
+import org.hisp.dhis.system.util.DateUtils;
/**
* @author Lars Helge Overland
@@ -65,6 +66,7 @@
private static final String FIELD_TYPE = "type";
private static final String FIELD_AGGREGATION_OPERATOR = "aggregationOperator";
private static final String FIELD_CATEGORY_COMBO = "categoryCombo";
+ private static final String FIELD_LAST_UPDATED = "lastUpdated";
// -------------------------------------------------------------------------
// Properties
@@ -130,6 +132,7 @@
writer.writeElement( FIELD_TYPE, element.getType() );
writer.writeElement( FIELD_AGGREGATION_OPERATOR, element.getAggregationOperator() );
writer.writeElement( FIELD_CATEGORY_COMBO, String.valueOf( element.getCategoryCombo().getId() ) );
+ writer.writeElement( FIELD_LAST_UPDATED, DateUtils.getMediumDateString( element.getLastUpdated(), EMPTY ) );
writer.closeElement();
}
@@ -160,6 +163,7 @@
element.setType( values.get( FIELD_TYPE ) );
element.setAggregationOperator( values.get( FIELD_AGGREGATION_OPERATOR ) );
element.getCategoryCombo().setId( categoryComboMapping.get( Integer.parseInt( values.get( FIELD_CATEGORY_COMBO ) ) ) );
+ element.setLastUpdated( DateUtils.getMediumDate( values.get( FIELD_LAST_UPDATED ) ) );
NameMappingUtil.addDataElementMapping( element.getId(), element.getName() );
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/IndicatorConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/IndicatorConverter.java 2009-08-12 21:06:37 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/IndicatorConverter.java 2009-11-04 18:24:30 +0000
@@ -44,6 +44,7 @@
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.system.util.DateUtils;
/**
* @author Lars Helge Overland
@@ -70,6 +71,7 @@
private static final String FIELD_DENOMINATOR = "denominator";
private static final String FIELD_DENOMINATOR_DESCRIPTION = "denominatorDescription";
private static final String FIELD_DENOMINATOR_AGGREGATION_OPERATOR = "denominatorAggregationOperator";
+ private static final String FIELD_LAST_UPDATED = "lastUpdated";
// -------------------------------------------------------------------------
// Properties
@@ -154,6 +156,7 @@
writer.writeElement( FIELD_DENOMINATOR, indicator.getDenominator() );
writer.writeElement( FIELD_DENOMINATOR_DESCRIPTION, indicator.getDenominatorDescription() );
writer.writeElement( FIELD_DENOMINATOR_AGGREGATION_OPERATOR, indicator.getDenominatorAggregationOperator() );
+ writer.writeElement( FIELD_LAST_UPDATED, DateUtils.getMediumDateString( indicator.getLastUpdated() ), EMPTY );
writer.closeElement();
}
@@ -188,6 +191,7 @@
indicator.setDenominator( expressionService.convertExpression( values.get( FIELD_DENOMINATOR ), dataElementMapping, categoryOptionComboMapping ) );
indicator.setDenominatorDescription( values.get( FIELD_DENOMINATOR_DESCRIPTION ) );
indicator.setDenominatorAggregationOperator( values.get( FIELD_DENOMINATOR_AGGREGATION_OPERATOR ) );
+ indicator.setLastUpdated( DateUtils.getMediumDate( values.get( FIELD_LAST_UPDATED ) ) );
NameMappingUtil.addIndicatorMapping( indicator.getId(), indicator.getName() );
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java 2009-08-12 21:06:37 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java 2009-11-04 18:24:30 +0000
@@ -65,6 +65,7 @@
private static final String FIELD_ACTIVE = "active";
private static final String FIELD_COMMENT = "comment";
private static final String FIELD_GEO_CODE = "geoCode";
+ private static final String FIELD_LAST_UPDATED = "lastUpdated";
// -------------------------------------------------------------------------
// Constructor
@@ -122,6 +123,7 @@
writer.writeElement( FIELD_ACTIVE, String.valueOf( unit.isActive() ) );
writer.writeElement( FIELD_COMMENT, unit.getComment() );
writer.writeElement( FIELD_GEO_CODE, unit.getGeoCode() );
+ writer.writeElement( FIELD_LAST_UPDATED, DateUtils.getMediumDateString( unit.getLastUpdated(), EMPTY ) );
writer.closeElement();
}
@@ -148,6 +150,7 @@
unit.setActive( Boolean.parseBoolean( values.get( FIELD_ACTIVE ) ) );
unit.setComment( values.get( FIELD_COMMENT ) );
unit.setGeoCode( values.get( FIELD_GEO_CODE ) );
+ unit.setLastUpdated( DateUtils.getMediumDate( values.get( FIELD_LAST_UPDATED ) ) );
NameMappingUtil.addOrganisationUnitMapping( unit.getId(), unit.getName() );
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java 2009-10-31 01:31:57 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java 2009-11-04 18:24:30 +0000
@@ -73,15 +73,26 @@
/**
* Formats a Date to the format YYYY-MM-DD.
* @param date the Date to parse.
- * @return A formatted date string.
+ * @return A formatted date string. Null if argument is null.
*/
public static String getMediumDateString( Date date )
{
final SimpleDateFormat format = new SimpleDateFormat();
- format.applyPattern( "yyyy-MM-dd" );
+ format.applyPattern( DEFAULT_DATE_FORMAT );
return date != null ? format.format( date ) : null;
}
+
+ /**
+ * Formats a Date to the format YYYY-MM-DD.
+ * @param date the Date to parse.
+ * @param defaultValue the return value if the date argument is null.
+ * @return A formatted date string. The defaultValue argument if date argument is null.
+ */
+ public static String getMediumDateString( Date date, String defaultValue )
+ {
+ return date != null ? getMediumDateString( date ) : defaultValue;
+ }
/**
* Formats the current Date to the format YYYY-MM-DD.
@@ -102,9 +113,9 @@
try
{
final SimpleDateFormat format = new SimpleDateFormat();
- format.applyPattern( "yyyy-MM-dd" );
+ format.applyPattern( DEFAULT_DATE_FORMAT );
- return dateString != null && !dateString.isEmpty() ? format.parse( dateString ) : null;
+ return dateString != null && dateIsValid( dateString ) ? format.parse( dateString ) : null;
}
catch ( ParseException ex )
{
=== modified file 'dhis-2/pom.xml'
--- dhis-2/pom.xml 2009-11-03 14:24:13 +0000
+++ dhis-2/pom.xml 2009-11-04 18:24:30 +0000
@@ -44,11 +44,13 @@
</distributionManagement>
<repositories>
+ <!--
<repository>
<id>amplecode_maven2_repo</id>
<name>AmpleCode Maven 2 repository</name>
<url>http://www.amplecode.org/maven2</url>
</repository>
+ -->
</repositories>
<issueManagement>