← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21710: minor updates to audit handling

 

------------------------------------------------------------
revno: 21710
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-01-13 18:05:50 +0700
message:
  minor updates to audit handling
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValue.java
  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/trackedentitydatavalue/DefaultTrackedEntityDataValueService.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/trackedentityattributevalue/TrackedEntityAttributeValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java	2016-01-07 12:15:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java	2016-01-13 11:05:50 +0000
@@ -77,6 +77,16 @@
     private String value;
 
     // -------------------------------------------------------------------------
+    // Transient properties
+    // -------------------------------------------------------------------------
+
+    private transient boolean auditValueIsSet = false;
+
+    private transient boolean valueIsSet = false;
+
+    private transient String auditValue;
+
+    // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
 
@@ -278,6 +288,14 @@
      */
     public void setValue( String value )
     {
+        if ( !auditValueIsSet )
+        {
+            this.auditValue = valueIsSet ? this.value : value;
+            auditValueIsSet = true;
+        }
+
+        valueIsSet = true;
+
         this.value = value;
     }
 
@@ -308,4 +326,9 @@
     {
         this.entityInstance = entityInstance;
     }
-}
+
+    public String getAuditValue()
+    {
+        return auditValue;
+    }
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValue.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValue.java	2016-01-13 11:05:50 +0000
@@ -63,6 +63,16 @@
     private String storedBy;
 
     // -------------------------------------------------------------------------
+    // Transient properties
+    // -------------------------------------------------------------------------
+
+    private transient boolean auditValueIsSet = false;
+
+    private transient boolean valueIsSet = false;
+
+    private transient String auditValue;
+
+    // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
 
@@ -75,7 +85,7 @@
     {
         this.dataElement = dataElement;
         this.programStageInstance = programStageInstance;
-        this.value = value;
+        setValue( value );
     }
 
     public void setAutoFields()
@@ -215,6 +225,14 @@
 
     public void setValue( String value )
     {
+        if ( !auditValueIsSet )
+        {
+            this.auditValue = valueIsSet ? this.value : value;
+            auditValueIsSet = true;
+        }
+
+        valueIsSet = true;
+
         this.value = value;
     }
 
@@ -232,4 +250,9 @@
     {
         this.storedBy = storedBy;
     }
+
+    public String getAuditValue()
+    {
+        return auditValue;
+    }
 }

=== 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	2016-01-07 10:06:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/DefaultTrackedEntityAttributeValueService.java	2016-01-13 11:05:50 +0000
@@ -76,7 +76,7 @@
     public void deleteTrackedEntityAttributeValue( TrackedEntityAttributeValue attributeValue )
     {
         TrackedEntityAttributeValueAudit trackedEntityAttributeValueAudit = new TrackedEntityAttributeValueAudit( attributeValue,
-            attributeValue.getValue(), currentUserService.getCurrentUsername(), AuditType.DELETE );
+            attributeValue.getAuditValue(), currentUserService.getCurrentUsername(), AuditType.DELETE );
 
         trackedEntityAttributeValueAuditService.addTrackedEntityAttributeValueAudit( trackedEntityAttributeValueAudit );
         attributeValueStore.delete( attributeValue );
@@ -140,7 +140,7 @@
         else
         {
             TrackedEntityAttributeValueAudit trackedEntityAttributeValueAudit = new TrackedEntityAttributeValueAudit( attributeValue,
-                attributeValue.getValue(), currentUserService.getCurrentUsername(), AuditType.UPDATE );
+                attributeValue.getAuditValue(), currentUserService.getCurrentUsername(), AuditType.UPDATE );
 
             trackedEntityAttributeValueAuditService.addTrackedEntityAttributeValueAudit( trackedEntityAttributeValueAudit );
             attributeValueStore.update( attributeValue );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.java	2016-01-13 11:05:50 +0000
@@ -97,7 +97,8 @@
                 trackedEntityDataValue.setStoredBy( currentUserService.getCurrentUsername() );
             }
 
-            TrackedEntityDataValueAudit dataValueAudit = new TrackedEntityDataValueAudit( trackedEntityDataValue, trackedEntityDataValue.getValue(), trackedEntityDataValue.getStoredBy(), AuditType.UPDATE );
+            TrackedEntityDataValueAudit dataValueAudit = new TrackedEntityDataValueAudit( trackedEntityDataValue, trackedEntityDataValue.getAuditValue(),
+                trackedEntityDataValue.getStoredBy(), AuditType.UPDATE );
 
             dataValueAuditService.addTrackedEntityDataValueAudit( dataValueAudit );
             dataValueStore.update( trackedEntityDataValue );
@@ -107,7 +108,7 @@
     @Override
     public void deleteTrackedEntityDataValue( TrackedEntityDataValue dataValue )
     {
-        TrackedEntityDataValueAudit dataValueAudit = new TrackedEntityDataValueAudit( dataValue, dataValue.getValue(),
+        TrackedEntityDataValueAudit dataValueAudit = new TrackedEntityDataValueAudit( dataValue, dataValue.getAuditValue(),
             currentUserService.getCurrentUsername(), AuditType.DELETE );
 
         dataValueAuditService.addTrackedEntityDataValueAudit( dataValueAudit );
@@ -122,7 +123,7 @@
 
         for ( TrackedEntityDataValue dataValue : dataValues )
         {
-            TrackedEntityDataValueAudit dataValueAudit = new TrackedEntityDataValueAudit( dataValue, dataValue.getValue(), username, AuditType.DELETE );
+            TrackedEntityDataValueAudit dataValueAudit = new TrackedEntityDataValueAudit( dataValue, dataValue.getAuditValue(), username, AuditType.DELETE );
             dataValueAuditService.addTrackedEntityDataValueAudit( dataValueAudit );
         }