← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1734: Commit DataValueAudit function even fix bug in data entry module.

 

------------------------------------------------------------
revno: 1734
committer: Quang <Quang@Quang-PC>
branch nick: dhis2
timestamp: Mon 2010-04-05 21:15:54 +0700
message:
  Commit DataValueAudit function even fix bug in data entry module.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAudit.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.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	2010-04-03 12:56:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAudit.java	2010-04-05 14:15:54 +0000
@@ -27,14 +27,106 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Date;
+
 /**
  * @author Quang Nguyen
  * @version Mar 30, 2010 9:13:36 PM
  */
+
 public class DataValueAudit
-    extends DataValue
 {
+    private int id;
+
+    private DataValue dataValue;
+
+    private String value;
+
+    private String storedBy;
+
+    private Date timeStamp;
+
+    private String comment;
+
+    // -------------------------------------------------------------------------
+    // Constructors
+    // -------------------------------------------------------------------------
     public DataValueAudit()
     {
-    }
+
+    }
+
+    public DataValueAudit( DataValue dataValue, String value, String storedBy, Date timeStamp, String comment )
+    {
+        this.dataValue = dataValue;
+        this.value = value;
+        this.storedBy = storedBy;
+        this.timeStamp = timeStamp;
+        this.comment = comment;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters and setters
+    // -------------------------------------------------------------------------
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    public DataValue getDataValue()
+    {
+        return dataValue;
+    }
+
+    public void setDataValue( DataValue dataValue )
+    {
+        this.dataValue = dataValue;
+    }
+
+    public String getValue()
+    {
+        return value;
+    }
+
+    public void setValue( String value )
+    {
+        this.value = value;
+    }
+
+    public String getStoredBy()
+    {
+        return storedBy;
+    }
+
+    public void setStoredBy( String storedBy )
+    {
+        this.storedBy = storedBy;
+    }
+
+    public Date getTimeStamp()
+    {
+        return timeStamp;
+    }
+
+    public void setTimeStamp( Date timeStamp )
+    {
+        this.timeStamp = timeStamp;
+    }
+
+    public String getComment()
+    {
+        return comment;
+    }
+
+    public void setComment( String comment )
+    {
+        this.comment = comment;
+    }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java	2010-04-03 12:56:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java	2010-04-05 14:15:54 +0000
@@ -79,7 +79,7 @@
     {
         this.periodStore = periodStore;
     }
-
+    
     // -------------------------------------------------------------------------
     // Support methods for reloading periods
     // -------------------------------------------------------------------------
@@ -135,7 +135,11 @@
     public void deleteDataValue( DataValue dataValue )
     {
         Session session = sessionFactory.getCurrentSession();
-
+        
+        Query queryAudit = session.createQuery( "delete DataValueAudit where dataValue = :dataValue" );
+        queryAudit.setEntity( "dataValue", dataValue );
+        queryAudit.executeUpdate();
+        
         session.delete( dataValue );
     }
 
@@ -143,6 +147,10 @@
     {
         Session session = sessionFactory.getCurrentSession();
 
+        Query queryAudit = session.createQuery( "delete DataValueAudit where dataValue.source = :source" );
+        queryAudit.setEntity( "source", source );
+        queryAudit.executeUpdate();
+        
         Query query = session.createQuery( "delete DataValue where source = :source" );
         query.setEntity( "source", source );
 
@@ -153,6 +161,10 @@
     {
         Session session = sessionFactory.getCurrentSession();
 
+        Query queryAudit = session.createQuery( "delete DataValueAudit where dataValue.dataElement = :dataElement" );
+        queryAudit.setEntity( "dataElement", dataElement );
+        queryAudit.executeUpdate();
+        
         Query query = session.createQuery( "delete DataValue where dataElement = :dataElement" );
         query.setEntity( "dataElement", dataElement );
 

=== 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	2010-04-03 12:56:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml	2010-04-05 14:15:54 +0000
@@ -3,26 +3,20 @@
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>
 
 <hibernate-mapping>
-	 <class name="org.hisp.dhis.datavalue.DataValueAudit" table="datavalueaudit">
-    <composite-id>
-      <key-many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement"
-          column="dataelementid" foreign-key="fk_datavalue_dataelementid"/>
-      <key-many-to-one name="period" class="org.hisp.dhis.period.Period" 
-          column="periodid" foreign-key="fk_datavalue_periodid"/>
-      <!--
-        The source relationship is made not lazy so that Hibernate won't put a
-        proxy on the reference which cannot be casted to the desired subclass.
-      -->
-      <key-many-to-one name="source" class="org.hisp.dhis.source.Source" lazy="false"
-          column="sourceid" foreign-key="fk_datavalue_sourceid"/>
-        <key-many-to-one name="optionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" 
-          column="categoryoptioncomboid" foreign-key="fk_datavalue_categoryoptioncomboid"/>
-        
-    </composite-id>
-    <property name="value"/>
-    <property name="storedBy" column="storedby" length="31"/>
-    <property name="timestamp" column="lastupdated" type="date"/>
-    <property name="comment" length="360"/>
-    <property name="followup"/>
-  </class>
+	<class name="org.hisp.dhis.datavalue.DataValueAudit" table="datavalueaudit">
+		<id name="id">
+			<generator class="native" />
+		</id>
+		<many-to-one name="dataValue" class="org.hisp.dhis.datavalue.DataValue" 
+			cascade="delete">
+			<column name="dataelementid" />
+			<column name="periodid" />
+			<column name="sourceid" />
+			<column name="categoryoptioncomboid" />
+		</many-to-one>
+		<property name="value"/>
+		<property name="storedBy" column="storedby" length="31"/>
+		<property name="timeStamp" column="lastupdated" type="date"/>
+		<property name="comment" length="360"/>
+	</class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java	2010-04-02 02:43:38 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java	2010-04-05 14:15:54 +0000
@@ -199,7 +199,7 @@
         {
             LOG.debug( "Updating DataValue, value added/changed" );
             
-            DataValueAudit audit = new DataValueAudit(dataValue, dataValue.getValue(), storedBy, new Date(), value);
+            DataValueAudit audit = new DataValueAudit(dataValue, dataValue.getValue(), storedBy, new Date(), "");
             
             dataValue.setValue( value );
             dataValue.setTimestamp( new Date() );

=== 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	2010-04-02 02:43:38 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2010-04-05 14:15:54 +0000
@@ -101,8 +101,7 @@
 				<p>
 					$encoder.htmlEncode( $i18n.getString( "on" ) ) $eachDataValueAudit.timeStamp, 
 					$eachDataValueAudit.storedBy 
-					$encoder.htmlEncode( $i18n.getString( "change_from" ) ) $eachDataValueAudit.value 
-					$encoder.htmlEncode( $i18n.getString( "to" ) ) $eachDataValueAudit.comment.
+					$encoder.htmlEncode( $i18n.getString( "change_from" ) ) $eachDataValueAudit.value.
 				</p>
 			#end					
         </td>