=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java 2015-12-01 17:19:15 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java 2015-12-16 13:23:46 +0000 @@ -42,6 +42,7 @@ import org.hisp.dhis.trackedentity.TrackedEntityInstance; import java.io.Serializable; +import java.util.Date; /** * TODO index on attribute and instance @@ -61,6 +62,10 @@ private TrackedEntityInstance entityInstance; + private Date created; + + private Date lastUpdated; + private String encryptedValue; private String plainValue; @@ -68,7 +73,7 @@ /** * This value is only used to store values from setValue when we don't know * if attribute is set or not. - */ + */ private String value; @@ -86,14 +91,25 @@ setEntityInstance( entityInstance ); } - public TrackedEntityAttributeValue( TrackedEntityAttribute attribute, TrackedEntityInstance entityInstance, - String value ) + public TrackedEntityAttributeValue( TrackedEntityAttribute attribute, TrackedEntityInstance entityInstance, String value ) { setAttribute( attribute ); setEntityInstance( entityInstance ); setValue( value ); } + public void setAutoFields() + { + Date date = new Date(); + + if ( created == null ) + { + created = date; + } + + setLastUpdated( date ); + } + // ------------------------------------------------------------------------- // hashCode and equals // ------------------------------------------------------------------------- @@ -178,11 +194,35 @@ // Getters and setters // ------------------------------------------------------------------------- + @JsonProperty + @JacksonXmlProperty( isAttribute = true ) + public Date getCreated() + { + return created; + } + + public void setCreated( Date created ) + { + this.created = created; + } + + @JsonProperty + @JacksonXmlProperty( isAttribute = true ) + public Date getLastUpdated() + { + return lastUpdated; + } + + public void setLastUpdated( Date lastUpdated ) + { + this.lastUpdated = lastUpdated; + } + /** - * Retrieves the encrypted value if the attribute is confidential. If the + * Retrieves the encrypted value if the attribute is confidential. If the * value is not confidential, returns old value. Should be null unless it was * confidential at an earlier stage. - * + * * @return String with decrypted value or null. */ @JsonIgnore @@ -197,10 +237,10 @@ } /** - * Retrieves the plain-text value is the attribute isn't confidential. If - * the value is confidential, this value should be null, unless it was + * Retrieves the plain-text value is the attribute isn't confidential. If + * the value is confidential, this value should be null, unless it was * non-confidential at an earlier stage. - * + * * @return String with plain-text value or null. */ @JsonIgnore @@ -215,9 +255,9 @@ } /** - * Returns the encrypted or the plain-text value, based on the attribute's + * Returns the encrypted or the plain-text value, based on the attribute's * confidential value. - * + * * @return String with value, either plain-text or decrypted. */ @JsonProperty @@ -229,10 +269,10 @@ } /** - * Since we never can be 100% certain Attribute is not null, we store the - * value in a temporary variable. The getEncrypted and getPlaintext methods + * Since we never can be 100% certain Attribute is not null, we store the + * value in a temporary variable. The getEncrypted and getPlaintext methods * will handle this value when requested. - * + * * @param value the value to be stored */ public void setValue( String value ) === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-12-16 12:46:52 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-12-16 13:23:46 +0000 @@ -136,6 +136,8 @@ executeSql( "alter table trackedentitydatavalue drop column timestamp" ); executeSql( "alter table trackedentityattributevalueaudit rename column timestamp to created" ); + executeSql( "update trackedentityattributevalue set created=now() where created is null" ); + executeSql( "update trackedentityattributevalue set lastupdated=now() where lastupdated is null" ); } private void updateProgramStatus() === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/DefaultTrackedEntityAttributeValueService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/DefaultTrackedEntityAttributeValueService.java 2015-11-30 02:50:28 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/DefaultTrackedEntityAttributeValueService.java 2015-12-16 13:23:46 +0000 @@ -111,6 +111,8 @@ @Override public void addTrackedEntityAttributeValue( TrackedEntityAttributeValue attributeValue ) { + attributeValue.setAutoFields(); + if ( attributeValue.getValue() != null ) { attributeValueStore.saveVoid( attributeValue ); @@ -120,6 +122,8 @@ @Override public void updateTrackedEntityAttributeValue( TrackedEntityAttributeValue attributeValue ) { + attributeValue.setAutoFields(); + if ( StringUtils.isEmpty( attributeValue.getValue() ) ) { attributeValueStore.delete( attributeValue ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValue.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValue.hbm.xml 2015-12-01 16:23:47 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValue.hbm.xml 2015-12-16 13:23:46 +0000 @@ -13,6 +13,10 @@ foreign-key="fk_attributevalue_trackedentityattributeid" /> + + + + === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Coordinate.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Coordinate.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Coordinate.java 2015-12-16 13:23:46 +0000 @@ -55,7 +55,7 @@ } @JsonProperty( required = true ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true ) + @JacksonXmlProperty( isAttribute = true ) public Double getLatitude() { return latitude; @@ -67,7 +67,7 @@ } @JsonProperty( required = true ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true ) + @JacksonXmlProperty( isAttribute = true ) public Double getLongitude() { return longitude; === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2015-12-16 12:46:52 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2015-12-16 13:23:46 +0000 @@ -251,6 +251,8 @@ String valueType = rowSet.getString( "ta_valuetype" ); Attribute attribute = new Attribute(); + attribute.setCreated( DateUtils.getLongGmtDateString( rowSet.getDate( "pav_created" ) ) ); + attribute.setLastUpdated( DateUtils.getLongGmtDateString( rowSet.getDate( "pav_lastupdated" ) ) ); attribute.setValue( rowSet.getString( "pav_value" ) ); attribute.setDisplayName( rowSet.getString( "ta_name" ) ); attribute.setValueType( valueType != null ? ValueType.valueOf( valueType.toUpperCase() ) : null ); @@ -495,7 +497,7 @@ private String getAttributeValueQuery() { - String sql = "select pav.trackedentityinstanceid as pav_id, pav.value as pav_value, ta.uid as ta_uid, ta.name as ta_name, ta.valuetype as ta_valuetype " + String sql = "select pav.trackedentityinstanceid as pav_id, pav.created as pav_created, pav.lastupdated as pav_lastupdated, pav.value as pav_value, ta.uid as ta_uid, ta.name as ta_name, ta.valuetype as ta_valuetype " + "from trackedentityattributevalue pav " + "inner join trackedentityattribute ta on pav.trackedentityattributeid=ta.trackedentityattributeid "; === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2015-12-16 08:59:10 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2015-12-16 13:23:46 +0000 @@ -44,6 +44,7 @@ import org.hisp.dhis.relationship.RelationshipService; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.system.callable.IdentifiableObjectCallable; +import org.hisp.dhis.system.util.DateUtils; import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; @@ -180,6 +181,8 @@ { Attribute attribute = new Attribute(); + attribute.setCreated( DateUtils.getLongGmtDateString( attributeValue.getCreated() ) ); + attribute.setLastUpdated( DateUtils.getLongGmtDateString( attributeValue.getLastUpdated() ) ); attribute.setDisplayName( attributeValue.getAttribute().getDisplayName() ); attribute.setAttribute( attributeValue.getAttribute().getUid() ); attribute.setValueType( attributeValue.getAttribute().getValueType() ); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Attribute.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Attribute.java 2015-09-13 21:54:23 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Attribute.java 2015-12-16 13:23:46 +0000 @@ -44,6 +44,10 @@ private String attribute; + private String created; + + private String lastUpdated; + private ValueType valueType; private String code; @@ -92,6 +96,30 @@ @JsonProperty @JacksonXmlProperty( isAttribute = true ) + public String getCreated() + { + return created; + } + + public void setCreated( String created ) + { + this.created = created; + } + + @JsonProperty + @JacksonXmlProperty( isAttribute = true ) + public String getLastUpdated() + { + return lastUpdated; + } + + public void setLastUpdated( String lastUpdated ) + { + this.lastUpdated = lastUpdated; + } + + @JsonProperty + @JacksonXmlProperty( isAttribute = true ) public ValueType getValueType() { return valueType;