dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #05270
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1730: Changed datavalueaudit hibernate mapping
------------------------------------------------------------
revno: 1730
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Sat 2010-04-03 14:56:45 +0200
message:
Changed datavalueaudit hibernate mapping
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/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml
--
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-03-31 16:21:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAudit.java 2010-04-03 12:56:45 +0000
@@ -27,106 +27,14 @@
* 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-02 02:43:38 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java 2010-04-03 12:56:45 +0000
@@ -42,7 +42,6 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueAuditStore;
import org.hisp.dhis.datavalue.DataValueStore;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodStore;
@@ -81,13 +80,6 @@
this.periodStore = periodStore;
}
- private DataValueAuditStore dataValueAuditStore;
-
- public void setDataValueAuditStore( DataValueAuditStore dataValueAuditStore )
- {
- this.dataValueAuditStore = dataValueAuditStore;
- }
-
// -------------------------------------------------------------------------
// Support methods for reloading periods
// -------------------------------------------------------------------------
@@ -143,32 +135,24 @@
public void deleteDataValue( DataValue dataValue )
{
Session session = sessionFactory.getCurrentSession();
- session.beginTransaction();
- dataValueAuditStore.deleteDataValuesByDataValue( dataValue );
+
session.delete( dataValue );
}
public int deleteDataValuesBySource( Source source )
{
Session session = sessionFactory.getCurrentSession();
- session.beginTransaction();
- 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 );
+
return query.executeUpdate();
}
public int deleteDataValuesByDataElement( DataElement dataElement )
{
Session session = sessionFactory.getCurrentSession();
- session.beginTransaction();
- 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/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2010-04-02 02:43:38 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2010-04-03 12:56:45 +0000
@@ -53,7 +53,6 @@
<property name="sessionFactory" ref="sessionFactory"/>
<property name="statementManager" ref="statementManager"/>
<property name="periodStore" ref="org.hisp.dhis.period.PeriodStore"/>
- <property name="dataValueAuditStore" ref="org.hisp.dhis.datavalue.DataValueAuditStore"/>
</bean>
<bean id="org.hisp.dhis.indicator.IndicatorStore"
=== 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 11:22:35 +0000
+++ 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
@@ -3,14 +3,26 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
- <class name="org.hisp.dhis.datavalue.DataValueAudit" table="datavalueaudit">
- <id name="id">
- <generator class="native" />
- </id>
-
- <property name="value" />
- <property name="storedBy" column="storedby" length="31" />
- <property name="timeStamp" column="lastupdated" type="date" />
- <property name="comment" length="360" />
- </class>
+ <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>
</hibernate-mapping>