dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31258
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15913: Added created property to DataValue. Run resources/sql/datavalue-add-created-field.sql to update db.
------------------------------------------------------------
revno: 15913
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-06-30 15:54:03 +0200
message:
Added created property to DataValue. Run resources/sql/datavalue-add-created-field.sql to update db.
added:
resources/sql/datavalue-add-created-field.sql
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandler.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/DataValueRowMapper.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/datavalue/DataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2014-06-27 16:34:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2014-06-30 13:54:03 +0000
@@ -69,6 +69,8 @@
private String storedBy;
+ private Date created;
+
private Date lastUpdated;
private String comment;
@@ -304,6 +306,16 @@
this.storedBy = storedBy;
}
+ public Date getCreated()
+ {
+ return created;
+ }
+
+ public void setCreated( Date created )
+ {
+ this.created = created;
+ }
+
public Date getLastUpdated()
{
return lastUpdated;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2014-06-23 08:05:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2014-06-30 13:54:03 +0000
@@ -123,6 +123,8 @@
dataValue.setAttributeOptionCombo( categoryService.getDefaultDataElementCategoryOptionCombo() );
}
+ dataValue.setCreated( new Date() );
+
dataValueStore.addDataValue( dataValue );
return true;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml 2014-06-27 16:27:09 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml 2014-06-30 13:54:03 +0000
@@ -17,9 +17,9 @@
<property name="value" length="255" />
<property name="storedBy" column="storedby" length="100" />
-<!--
- <property name="timestamp" column="lastupdated" type="timestamp" />
--->
+
+ <property name="created" column="created" type="timestamp" />
+
<property name="lastUpdated" column="lastupdated" type="timestamp" />
<property name="comment" length="360" />
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java 2014-06-30 13:54:03 +0000
@@ -56,6 +56,8 @@
protected String storedBy;
+ protected String created;
+
protected String lastUpdated;
protected String comment;
@@ -153,6 +155,16 @@
this.storedBy = storedBy;
}
+ public String getCreated()
+ {
+ return created;
+ }
+
+ public void setCreated( String created )
+ {
+ this.created = created;
+ }
+
@JsonProperty
@JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2014-06-27 16:27:09 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2014-06-30 13:54:03 +0000
@@ -546,6 +546,7 @@
internalValue.setStoredBy( dataValue.getStoredBy() );
}
+ internalValue.setCreated( parseDate( dataValue.getCreated() ) );
internalValue.setLastUpdated( parseDate( dataValue.getLastUpdated() ) );
internalValue.setComment( trimToNull( dataValue.getComment() ) );
internalValue.setFollowup( dataValue.getFollowup() );
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandler.java 2014-06-27 16:27:09 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandler.java 2014-06-30 13:54:03 +0000
@@ -106,6 +106,7 @@
statementBuilder.setColumn( "attributeoptioncomboid" );
statementBuilder.setColumn( "value" );
statementBuilder.setColumn( "storedby" );
+ statementBuilder.setColumn( "created ");
statementBuilder.setColumn( "lastupdated" );
statementBuilder.setColumn( "comment" );
statementBuilder.setColumn( "followup" );
@@ -120,6 +121,7 @@
statementBuilder.setValue( value.getAttributeOptionCombo().getId() );
statementBuilder.setValue( value.getValue() );
statementBuilder.setValue( value.getStoredBy() );
+ statementBuilder.setValue( getLongDateString( value.getCreated() ) );
statementBuilder.setValue( getLongDateString( value.getLastUpdated() ) );
statementBuilder.setValue( value.getComment() );
statementBuilder.setValue( value.isFollowup() );
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/DataValueRowMapper.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/DataValueRowMapper.java 2014-06-27 16:27:09 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/DataValueRowMapper.java 2014-06-30 13:54:03 +0000
@@ -55,16 +55,17 @@
dataValue.setAttributeOptionCombo( new DataElementCategoryOptionCombo() );
dataValue.setSource( new OrganisationUnit() );
dataValue.setPeriod( new Period() );
-
- dataValue.getDataElement().setId( resultSet.getInt( 1 ) );
- dataValue.getPeriod().setId( resultSet.getInt( 2 ) );
- dataValue.getSource().setId( resultSet.getInt( 3 ) );
- dataValue.getCategoryOptionCombo().setId( resultSet.getInt( 4 ) );
- dataValue.setValue( resultSet.getString( 5 ) );
- dataValue.setStoredBy( resultSet.getString( 6 ) );
- dataValue.setLastUpdated( resultSet.getDate( 7 ) );
- dataValue.setComment( resultSet.getString( 8 ) );
-
+
+ dataValue.getDataElement().setId( resultSet.getInt( "dataelementid" ) );
+ dataValue.getPeriod().setId( resultSet.getInt( "periodid" ) );
+ dataValue.getSource().setId( resultSet.getInt( "sourceid" ) );
+ dataValue.getCategoryOptionCombo().setId( resultSet.getInt( "categoryoptioncomboid" ) );
+ dataValue.setValue( resultSet.getString( "value" ) );
+ dataValue.setStoredBy( resultSet.getString( "storedby" ) );
+ dataValue.setCreated( resultSet.getDate( "created" ) );
+ dataValue.setLastUpdated( resultSet.getDate( "lastupdated" ) );
+ dataValue.setComment( resultSet.getString( "comment" ) );
+
return dataValue;
}
=== added file 'resources/sql/datavalue-add-created-field.sql'
--- resources/sql/datavalue-add-created-field.sql 1970-01-01 00:00:00 +0000
+++ resources/sql/datavalue-add-created-field.sql 2014-06-30 13:54:03 +0000
@@ -0,0 +1,10 @@
+-- Update script for datavalue table for addition of the created column
+-- If no created column exists in datavalue, the column in created
+-- For each row: if created field is null, set value from lastupdated
+
+ALTER TABLE datavalue ADD COLUMN created timestamp without time zone;
+
+UPDATE datavalue
+SET created = lastupdated
+WHERE created IS NULL
+AND lastupdated IS NOT NULL;