dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41666
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21243: rename all audits timestamp -> created
------------------------------------------------------------
revno: 21243
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-12-01 11:59:42 +0700
message:
rename all audits timestamp -> created
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAudit.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAudit.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAudit.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/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java
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/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueAuditStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueAuditStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValueAudit.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentitydatavalue/hibernate/TrackedEntityDataValueAudit.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueAuditServiceTest.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm
--
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/DataValueAudit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAudit.java 2015-11-27 05:26:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAudit.java 2015-12-01 04:59:42 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.period.Period;
import java.util.Date;
+import java.util.Objects;
/**
* @author Quang Nguyen
@@ -52,7 +53,7 @@
private String modifiedBy;
- private Date timestamp;
+ private Date created;
private DataElement dataElement;
@@ -74,7 +75,7 @@
{
}
- public DataValueAudit( DataValue dataValue, String value, String modifiedBy, Date timestamp, AuditType auditType )
+ public DataValueAudit( DataValue dataValue, String value, String modifiedBy, AuditType auditType )
{
this.dataElement = dataValue.getDataElement();
this.period = dataValue.getPeriod();
@@ -82,12 +83,45 @@
this.categoryOptionCombo = dataValue.getCategoryOptionCombo();
this.attributeOptionCombo = dataValue.getAttributeOptionCombo();
+ this.created = new Date();
this.value = value;
this.modifiedBy = modifiedBy;
- this.timestamp = timestamp;
this.auditType = auditType;
}
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash( id, value, modifiedBy, created, dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo, auditType );
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+
+ if ( obj == null || getClass() != obj.getClass() )
+ {
+ return false;
+ }
+
+ final DataValueAudit other = (DataValueAudit) obj;
+
+ return Objects.equals( this.id, other.id )
+ && Objects.equals( this.value, other.value )
+ && Objects.equals( this.modifiedBy, other.modifiedBy )
+ && Objects.equals( this.created, other.created )
+ && Objects.equals( this.dataElement, other.dataElement )
+ && Objects.equals( this.period, other.period )
+ && Objects.equals( this.organisationUnit, other.organisationUnit )
+ && Objects.equals( this.categoryOptionCombo, other.categoryOptionCombo )
+ && Objects.equals( this.attributeOptionCombo, other.attributeOptionCombo )
+ && Objects.equals( this.auditType, other.auditType );
+ }
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -128,14 +162,14 @@
@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public Date getTimestamp()
+ public Date getCreated()
{
- return timestamp;
+ return created;
}
- public void setTimestamp( Date timestamp )
+ public void setCreated( Date created )
{
- this.timestamp = timestamp;
+ this.created = created;
}
@JsonProperty
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAudit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAudit.java 2015-11-30 03:11:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAudit.java 2015-12-01 04:59:42 +0000
@@ -53,7 +53,7 @@
private TrackedEntityInstance entityInstance;
- private Date timestamp;
+ private Date created;
private String value;
@@ -70,7 +70,7 @@
this.attribute = trackedEntityAttributeValue.getAttribute();
this.entityInstance = trackedEntityAttributeValue.getEntityInstance();
- this.timestamp = new Date();
+ this.created = new Date();
this.value = value;
this.modifiedBy = modifiedBy;
this.auditType = auditType;
@@ -79,7 +79,7 @@
@Override
public int hashCode()
{
- return Objects.hash( attribute, entityInstance, timestamp, value, modifiedBy, auditType );
+ return Objects.hash( attribute, entityInstance, created, value, modifiedBy, auditType );
}
@Override
@@ -99,7 +99,7 @@
return Objects.equals( this.attribute, other.attribute )
&& Objects.equals( this.entityInstance, other.entityInstance )
- && Objects.equals( this.timestamp, other.timestamp )
+ && Objects.equals( this.created, other.created )
&& Objects.equals( this.value, other.value )
&& Objects.equals( this.modifiedBy, other.modifiedBy )
&& Objects.equals( this.auditType, other.auditType );
@@ -141,14 +141,14 @@
@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public Date getTimestamp()
+ public Date getCreated()
{
- return timestamp;
+ return created;
}
- public void setTimestamp( Date timestamp )
+ public void setCreated( Date created )
{
- this.timestamp = timestamp;
+ this.created = created;
}
@JsonProperty
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAudit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAudit.java 2015-11-30 03:11:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAudit.java 2015-12-01 04:59:42 +0000
@@ -53,7 +53,7 @@
private ProgramStageInstance programStageInstance;
- private Date timestamp;
+ private Date created;
private String value;
@@ -77,7 +77,7 @@
this.programStageInstance = trackedEntityDataValue.getProgramStageInstance();
this.providedElsewhere = trackedEntityDataValue.getProvidedElsewhere();
- this.timestamp = new Date();
+ this.created = new Date();
this.value = value;
this.modifiedBy = modifiedBy;
this.auditType = auditType;
@@ -86,7 +86,7 @@
@Override
public int hashCode()
{
- return Objects.hash( dataElement, programStageInstance, timestamp, value, providedElsewhere, modifiedBy, auditType );
+ return Objects.hash( dataElement, programStageInstance, created, value, providedElsewhere, modifiedBy, auditType );
}
@Override
@@ -106,7 +106,7 @@
return Objects.equals( this.dataElement, other.dataElement )
&& Objects.equals( this.programStageInstance, other.programStageInstance )
- && Objects.equals( this.timestamp, other.timestamp )
+ && Objects.equals( this.created, other.created )
&& Objects.equals( this.value, other.value )
&& Objects.equals( this.providedElsewhere, other.providedElsewhere )
&& Objects.equals( this.modifiedBy, other.modifiedBy )
@@ -153,14 +153,14 @@
@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public Date getTimestamp()
+ public Date getCreated()
{
- return timestamp;
+ return created;
}
- public void setTimestamp( Date timestamp )
+ public void setCreated( Date created )
{
- this.timestamp = timestamp;
+ this.created = created;
}
@JsonProperty
=== 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 2015-11-17 08:32:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2015-12-01 04:59:42 +0000
@@ -167,8 +167,7 @@
}
else if ( dataValueIsValid( dataValue.getValue(), dataValue.getDataElement() ) == null )
{
- DataValueAudit dataValueAudit = new DataValueAudit( dataValue, dataValue.getAuditValue(),
- dataValue.getStoredBy(), new Date(), AuditType.UPDATE );
+ DataValueAudit dataValueAudit = new DataValueAudit( dataValue, dataValue.getAuditValue(), dataValue.getStoredBy(), AuditType.UPDATE );
dataValueAuditService.addDataValueAudit( dataValueAudit );
dataValueStore.updateDataValue( dataValue );
@@ -179,8 +178,7 @@
@Transactional
public void deleteDataValue( DataValue dataValue )
{
- DataValueAudit dataValueAudit = new DataValueAudit( dataValue, dataValue.getAuditValue(),
- currentUserService.getCurrentUsername(), new Date(), AuditType.DELETE );
+ DataValueAudit dataValueAudit = new DataValueAudit( dataValue, dataValue.getAuditValue(), currentUserService.getCurrentUsername(), AuditType.DELETE );
dataValueAuditService.addDataValueAudit( dataValueAudit );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java 2015-11-30 05:36:05 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java 2015-12-01 04:59:42 +0000
@@ -172,7 +172,7 @@
criteria.add( Restrictions.eq( "auditType", auditType ) );
}
- criteria.addOrder( Order.desc( "timestamp" ) );
+ criteria.addOrder( Order.desc( "created" ) );
return criteria;
}
=== 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-11-18 04:39:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-12-01 04:59:42 +0000
@@ -75,6 +75,7 @@
updateFeatureTypes();
updateValidationRuleEnums();
updateProgramStatus();
+ updateAuditTimestamps();
executeSql( "ALTER TABLE program ALTER COLUMN \"type\" TYPE varchar(255);" );
executeSql( "update program set \"type\"='WITH_REGISTRATION' where type='1' or type='2'" );
@@ -89,6 +90,13 @@
// Supportive methods
// -------------------------------------------------------------------------
+ private void updateAuditTimestamps()
+ {
+ executeSql( "alter table datavalueaudit rename column timestamp to created" );
+ executeSql( "alter table trackedentitydatavalueaudit rename column timestamp to created" );
+ executeSql( "alter table trackedentityattributevalueaudit rename column timestamp to created" );
+ }
+
private void updateProgramStatus()
{
executeSql( "alter table programinstance alter column status type varchar(50)" );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueAuditStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueAuditStore.java 2015-11-30 05:36:05 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueAuditStore.java 2015-12-01 04:59:42 +0000
@@ -110,7 +110,7 @@
criteria.add( Restrictions.eq( "auditType", auditType ) );
}
- criteria.addOrder( Order.desc( "timestamp" ) );
+ criteria.addOrder( Order.desc( "created" ) );
return criteria;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueAuditStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueAuditStore.java 2015-11-30 05:36:05 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueAuditStore.java 2015-12-01 04:59:42 +0000
@@ -111,7 +111,7 @@
criteria.add( Restrictions.eq( "auditType", auditType ) );
}
- criteria.addOrder( Order.desc( "timestamp" ) );
+ criteria.addOrder( Order.desc( "created" ) );
return criteria;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueStore.java 2015-11-27 08:42:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueStore.java 2015-12-01 04:59:42 +0000
@@ -119,6 +119,7 @@
criteria.add( Restrictions.in( "dataElement", dataElements ) );
criteria.add( Restrictions.eq( "programInstance.entityInstance", entityInstance ) );
criteria.add( Restrictions.between( "programStageInstance.executionDate", startDate, endDate ) );
+
return criteria.list();
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml 2015-11-27 08:42:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml 2015-12-01 04:59:42 +0000
@@ -27,7 +27,7 @@
<property name="value" length="50000" />
- <property name="timestamp" column="timestamp" type="timestamp" not-null="true" index="id_datavalueaudit_timestamp" />
+ <property name="created" column="created" type="timestamp" not-null="true" index="id_datavalueaudit_created" />
<property name="modifiedBy" column="modifiedby" length="100" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValueAudit.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValueAudit.hbm.xml 2015-11-30 02:50:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValueAudit.hbm.xml 2015-12-01 04:59:42 +0000
@@ -18,7 +18,7 @@
<property name="value" length="50000" />
- <property name="timestamp" type="timestamp" />
+ <property name="created" type="timestamp" />
<property name="modifiedBy" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentitydatavalue/hibernate/TrackedEntityDataValueAudit.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentitydatavalue/hibernate/TrackedEntityDataValueAudit.hbm.xml 2015-11-27 15:24:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentitydatavalue/hibernate/TrackedEntityDataValueAudit.hbm.xml 2015-12-01 04:59:42 +0000
@@ -18,7 +18,7 @@
<property name="value" length="50000" />
- <property name="timestamp" type="timestamp" />
+ <property name="created" type="timestamp" />
<property name="providedElsewhere" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueAuditServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueAuditServiceTest.java 2015-11-27 09:47:05 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueAuditServiceTest.java 2015-12-01 04:59:42 +0000
@@ -41,7 +41,6 @@
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.Date;
import java.util.List;
import static org.junit.Assert.assertNotNull;
@@ -172,12 +171,8 @@
@Test
public void testAddDataValueAudit()
{
- Date now = new Date();
-
- DataValueAudit dataValueAuditA = new DataValueAudit( dataValueA, dataValueA.getValue(), dataValueA.getStoredBy(),
- now, AuditType.UPDATE );
- DataValueAudit dataValueAuditB = new DataValueAudit( dataValueB, dataValueB.getValue(), dataValueB.getStoredBy(),
- now, AuditType.UPDATE );
+ DataValueAudit dataValueAuditA = new DataValueAudit( dataValueA, dataValueA.getValue(), dataValueA.getStoredBy(), AuditType.UPDATE );
+ DataValueAudit dataValueAuditB = new DataValueAudit( dataValueB, dataValueB.getValue(), dataValueB.getStoredBy(), AuditType.UPDATE );
dataValueAuditService.addDataValueAudit( dataValueAuditA );
dataValueAuditService.addDataValueAudit( dataValueAuditB );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm 2014-09-25 17:23:42 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm 2015-12-01 04:59:42 +0000
@@ -108,7 +108,7 @@
#foreach( $dataValueAudit in $dataValueAudits )
<tr>
<td>
- $format.formatDateTime( $dataValueAudit.timestamp )
+ $format.formatDateTime( $dataValueAudit.created )
</td>
<td>
#if( $dataValueAudit.modifiedBy )