dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33931
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17383: Added missing support for attribute option combos in datavalue audit
------------------------------------------------------------
revno: 17383
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-11-07 17:03:49 +0100
message:
Added missing support for attribute option combos in datavalue audit
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAudit.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.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/TableAlteror.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/GetHistoryAction.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/datavalue/DataValueAudit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAudit.java 2014-07-10 15:06:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAudit.java 2014-11-07 16:03:49 +0000
@@ -58,6 +58,8 @@
private OrganisationUnit organisationUnit;
private DataElementCategoryOptionCombo categoryOptionCombo;
+
+ private DataElementCategoryOptionCombo attributeOptionCombo;
private AuditType auditType;
@@ -75,6 +77,7 @@
this.period = dataValue.getPeriod();
this.organisationUnit = dataValue.getSource();
this.categoryOptionCombo = dataValue.getCategoryOptionCombo();
+ this.attributeOptionCombo = dataValue.getAttributeOptionCombo();
this.value = value;
this.modifiedBy = modifiedBy;
@@ -166,6 +169,16 @@
this.categoryOptionCombo = categoryOptionCombo;
}
+ public DataElementCategoryOptionCombo getAttributeOptionCombo()
+ {
+ return attributeOptionCombo;
+ }
+
+ public void setAttributeOptionCombo( DataElementCategoryOptionCombo attributeOptionCombo )
+ {
+ this.attributeOptionCombo = attributeOptionCombo;
+ }
+
public AuditType getAuditType()
{
return auditType;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java 2014-07-08 17:16:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java 2014-11-07 16:03:49 +0000
@@ -68,12 +68,13 @@
* @param period the Period of the DataValueAudits.
* @param organisationUnit the OrganisationUnit of the DataValueAudits.
* @param categoryOptionCombo the DataElementCategoryOptionCombo of the DataValueAudits.
+ * @param attributeOptionCombo the attribute option combo.
* @return a collection of DataValueAudits which matches the given DataElement, Period,
* OrganisationUnit and DataElementCategoryOptionCombo, or an empty collection if
* there are not matches.
*/
- Collection<DataValueAudit> getDataValueAudits( DataElement dataElement,
- Period period, OrganisationUnit organisationUnit, DataElementCategoryOptionCombo categoryOptionCombo );
+ Collection<DataValueAudit> getDataValueAudits( DataElement dataElement, Period period, OrganisationUnit organisationUnit,
+ DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo );
/**
* Deletes a DataValueAudit.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java 2014-07-09 13:43:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java 2014-11-07 16:03:49 +0000
@@ -69,12 +69,13 @@
* @param period the Period of the DataValueAudits.
* @param organisationUnit the OrganisationUnit of the DataValueAudits.
* @param categoryOptionCombo the DataElementCategoryOptionCombo of the DataValueAudits.
+ * @param attributeOptionCombo the attribute option combo.
* @return a collection of DataValueAudits which match the given DataElement, Period,
* OrganisationUnit and DataElementCategoryOptionCombo, or an empty collection
* if no DataValueAudits match.
*/
- Collection<DataValueAudit> getDataValueAudits( DataElement dataElement,
- Period period, OrganisationUnit organisationUnit, DataElementCategoryOptionCombo categoryOptionCombo );
+ Collection<DataValueAudit> getDataValueAudits( DataElement dataElement, Period period, OrganisationUnit organisationUnit,
+ DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo );
/**
* Deletes a DataValueAudit.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java 2014-07-09 13:43:43 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java 2014-11-07 16:03:49 +0000
@@ -79,9 +79,9 @@
@Override
public Collection<DataValueAudit> getDataValueAudits( DataElement dataElement, Period period,
- OrganisationUnit organisationUnit, DataElementCategoryOptionCombo categoryOptionCombo )
+ OrganisationUnit organisationUnit, DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo )
{
- return dataValueAuditStore.getDataValueAudits( dataElement, period, organisationUnit, categoryOptionCombo );
+ return dataValueAuditStore.getDataValueAudits( dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo );
}
@Override
=== 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 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java 2014-11-07 16:03:49 +0000
@@ -88,13 +88,13 @@
public Collection<DataValueAudit> getDataValueAudits( DataValue dataValue )
{
return getDataValueAudits( dataValue.getDataElement(), dataValue.getPeriod(),
- dataValue.getSource(), dataValue.getCategoryOptionCombo() );
+ dataValue.getSource(), dataValue.getCategoryOptionCombo(), dataValue.getAttributeOptionCombo() );
}
@Override
@SuppressWarnings("unchecked")
public Collection<DataValueAudit> getDataValueAudits( DataElement dataElement, Period period,
- OrganisationUnit organisationUnit, DataElementCategoryOptionCombo categoryOptionCombo )
+ OrganisationUnit organisationUnit, DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo )
{
Session session = sessionFactory.getCurrentSession();
@@ -110,6 +110,7 @@
.add( Restrictions.eq( "period", storedPeriod ) )
.add( Restrictions.eq( "organisationUnit", organisationUnit ) )
.add( Restrictions.eq( "categoryOptionCombo", categoryOptionCombo ) )
+ .add( Restrictions.eq( "attributeOptionCombo", attributeOptionCombo ) )
.addOrder( Order.desc( "timestamp" ) );
return criteria.list();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-10-26 19:03:48 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2014-11-07 16:03:49 +0000
@@ -79,6 +79,7 @@
public void execute()
{
int defaultCategoryComboId = getDefaultCategoryCombo();
+ int defaultOptionComboId = getDefaultOptionCombo();
// ---------------------------------------------------------------------
// Drop outdated tables
@@ -130,6 +131,7 @@
executeSql( "DROP TABLE validationrulegroupuserrolestoalert" );
executeSql( "DROP TABLE expressionoptioncombo" );
executeSql( "DROP TABLE orgunitgroupdatasets" );
+ executeSql( "DROP TABLE datavalue_audit" );
executeSql( "ALTER TABLE categoryoptioncombo drop column userid" );
executeSql( "ALTER TABLE categoryoptioncombo drop column publicaccess" );
executeSql( "ALTER TABLE dataelementcategoryoption drop column categoryid" );
@@ -766,6 +768,11 @@
executeSql( "alter table datavalue alter column value type varchar(50000)" );
executeSql( "alter table datavalue alter column comment type varchar(50000)" );
executeSql( "alter table datavalueaudit alter column value type varchar(50000)" );
+
+ executeSql( "update datavalueaudit set attributeoptioncomboid = " + defaultOptionComboId + " where attributeoptioncomboid is null" );
+ System.out.println("SQL " + "update datavalueaudit set attributeoptioncomboid = " + defaultOptionComboId + " where attributeoptioncomboid is null");
+
+ executeSql( "alter table datavalueaudit alter column attributeoptioncomboid set not null;" );
upgradeDataValuesWithAttributeOptionCombo();
upgradeCompleteDataSetRegistrationsWithAttributeOptionCombo();
@@ -792,20 +799,14 @@
int optionComboId = getDefaultOptionCombo();
- executeSql( "alter table datavalue_audit drop constraint fk_datavalueaudit_datavalue;" );
-
executeSql( "alter table datavalue drop constraint datavalue_pkey;" );
executeSql( "alter table datavalue add column attributeoptioncomboid integer;" );
- executeSql( "update datavalue set attributeoptioncomboid = " + optionComboId
- + " where attributeoptioncomboid is null;" );
+ executeSql( "update datavalue set attributeoptioncomboid = " + optionComboId + " where attributeoptioncomboid is null;" );
executeSql( "alter table datavalue alter column attributeoptioncomboid set not null;" );
executeSql( "alter table datavalue add constraint fk_datavalue_attributeoptioncomboid foreign key (attributeoptioncomboid) references categoryoptioncombo (categoryoptioncomboid) match simple;" );
executeSql( "alter table datavalue add constraint datavalue_pkey primary key(dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid);" );
- executeSql( "alter table datavalue_audit add constraint fk_datavalueaudit_datavalue foreign key (dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid) "
- + "references datavalue (dataelementid, periodid, sourceid, categoryoptioncomboid, attributeoptioncomboid) match simple;" );
-
log.info( "Data value table upgraded with attributeoptioncomboid column" );
}
=== 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 2014-09-19 17:13:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValueAudit.hbm.xml 2014-11-07 16:03:49 +0000
@@ -11,16 +11,19 @@
</id>
<many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" column="dataelementid"
- foreign-key="fk_datavalueaudit_dataelementid" not-null="true"/>
+ foreign-key="fk_datavalueaudit_dataelementid" not-null="true"/>
<many-to-one name="period" class="org.hisp.dhis.period.Period" column="periodid"
- foreign-key="fk_datavalueaudit_periodid" not-null="true"/>
+ foreign-key="fk_datavalueaudit_periodid" not-null="true"/>
<many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid"
- foreign-key="fk_datavalueaudit_organisationunitid" not-null="true"/>
-
- <many-to-one name="categoryOptionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo"
- column="categoryoptioncomboid" foreign-key="fk_datavalueaudit_categoryoptioncomboid" not-null="true"/>
+ foreign-key="fk_datavalueaudit_organisationunitid" not-null="true"/>
+
+ <many-to-one name="categoryOptionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" column="categoryoptioncomboid"
+ foreign-key="fk_datavalueaudit_categoryoptioncomboid" not-null="true"/>
+
+ <many-to-one name="attributeOptionCombo" class="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" column="attributeoptioncomboid"
+ foreign-key="fk_datavalueaudit_attributeoptioncomboid"/>
<property name="value" length="50000" />
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java 2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java 2014-11-07 16:03:49 +0000
@@ -260,7 +260,7 @@
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( ServletActionContext.getResponse(), cc, cp );
- dataValueAudits = dataValueAuditService.getDataValueAudits( dataElement, period, organisationUnit, categoryOptionCombo );
+ dataValueAudits = dataValueAuditService.getDataValueAudits( dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo );
dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo );