dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31528
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16076: Including created field in data value set
------------------------------------------------------------
revno: 16076
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-07-10 16:16:24 +0200
message:
Including created field in data value set
modified:
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/SpringDataValueSetStore.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/StreamingJsonDataValue.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/datavalue/DataValue.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java 2014-06-30 13:54:03 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java 2014-07-10 14:16:24 +0000
@@ -155,6 +155,9 @@
this.storedBy = storedBy;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public String getCreated()
{
return created;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java 2014-07-07 15:02:50 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java 2014-07-10 14:16:24 +0000
@@ -28,7 +28,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.csvreader.CsvWriter;
+import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
+import static org.hisp.dhis.system.util.DateUtils.getMediumDateString;
+import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
+
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Set;
+
import org.amplecode.staxwax.factory.XMLFactory;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
@@ -36,23 +45,13 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.system.util.StreamUtils;
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormatter;
-import org.joda.time.format.ISODateTimeFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Set;
-
-import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
-import static org.hisp.dhis.system.util.DateUtils.getMediumDateString;
-import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
+import com.csvreader.CsvWriter;
/**
* @author Lars Helge Overland
@@ -107,7 +106,6 @@
Set<DataElement> dataElements, Set<Period> periods, Set<OrganisationUnit> orgUnits, DataValueSet dataValueSet )
{
SqlRowSet rowSet = jdbcTemplate.queryForRowSet( getDataValueSql( dataElements, periods, orgUnits ) );
- DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
dataValueSet.setDataSet( dataSet != null ? dataSet.getUid() : null );
dataValueSet.setCompleteDate( getMediumDateString( completeDate ) );
@@ -128,15 +126,8 @@
dataValue.setCategoryOptionCombo( rowSet.getString( "cocuid" ) );
dataValue.setValue( rowSet.getString( "value" ) );
dataValue.setStoredBy( rowSet.getString( "storedby" ) );
-
- java.sql.Date lastUpdated = rowSet.getDate( "lastupdated" );
-
- if ( lastUpdated != null )
- {
- DateTime dt = new DateTime( lastUpdated );
- dataValue.setLastUpdated( fmt.print( dt ) );
- }
-
+ dataValue.setCreated( DateUtils.getLongDateString( rowSet.getDate( "created" ) ) );
+ dataValue.setLastUpdated( DateUtils.getLongDateString( rowSet.getDate( "lastupdated" ) ) );
dataValue.setComment( rowSet.getString( "comment" ) );
dataValue.setFollowup( rowSet.getBoolean( "followup" ) );
dataValue.close();
@@ -148,7 +139,7 @@
private String getDataValueSql( Collection<DataElement> dataElements, Collection<Period> periods, Collection<OrganisationUnit> orgUnits )
{
return
- "select de.uid as deuid, pe.startdate, pt.name, ou.uid as ouuid, coc.uid as cocuid, dv.value, dv.storedby, dv.lastupdated, dv.comment, dv.followup " +
+ "select de.uid as deuid, pe.startdate, pt.name, ou.uid as ouuid, coc.uid as cocuid, dv.value, dv.storedby, dv.created, dv.lastupdated, dv.comment, dv.followup " +
"from datavalue dv " +
"join dataelement de on (dv.dataelementid=de.dataelementid) " +
"join period pe on (dv.periodid=pe.periodid) " +
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/StreamingJsonDataValue.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/StreamingJsonDataValue.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/StreamingJsonDataValue.java 2014-07-10 14:16:24 +0000
@@ -91,6 +91,12 @@
}
@Override
+ public void setCreated( String created )
+ {
+ writeObjectField( "created", created );
+ }
+
+ @Override
public void setLastUpdated( String lastUpdated )
{
writeObjectField( "lastUpdated", lastUpdated );