dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15398
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5574: Report table testing
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 5574 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-12-23 11:50:32 +0100
message:
Report table testing
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.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/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2011-12-22 20:12:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2011-12-23 10:50:09 +0000
@@ -388,8 +388,8 @@
verify( nonEmptyLists( dataElements, indicators, dataSets ) > 0,
"Must contain dataelements, indicators or datasets" );
verify( nonEmptyLists( periods, relativePeriods ) > 0, "Must contain periods or relative periods" );
- verify( nonEmptyLists( units, relativeUnits ) > 0,
- "Must contain organisation units or relative organisation units" );
+ verify( nonEmptyLists( units, relativeUnits, organisationUnitGroups ) > 0,
+ "Must contain organisation units, relative organisation units or organisation unit groups" );
verify( !(doTotal() && regression), "Cannot have regression columns with total columns" );
verify( i18nFormat != null, "I18n format must be set" );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java 2011-09-29 07:41:04 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java 2011-12-23 10:50:09 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.system.deletion.DeletionHandler;
@@ -130,6 +131,18 @@
}
}
}
+
+ @Override
+ public void deleteOrganisationUnitGroup( OrganisationUnitGroup group )
+ {
+ for ( ReportTable reportTable : reportTableService.getAllReportTables() )
+ {
+ if ( reportTable.getOrganisationUnitGroups().remove( group ) )
+ {
+ reportTableService.updateReportTable( reportTable );
+ }
+ }
+ }
@Override
public String allowDeleteDataElementCategoryCombo( DataElementCategoryCombo categoryCombo )
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml 2011-12-22 19:59:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml 2011-12-23 10:50:09 +0000
@@ -55,11 +55,11 @@
<many-to-many column="organisationunitid" class="org.hisp.dhis.organisationunit.OrganisationUnit" foreign-key="fk_reporttable_organisationunits_organisationunitid" />
</list>
- <list name="organisationUnitGroups" table="reporttable_organisationunitgroups">
+ <list name="organisationUnitGroups" table="reporttable_orgunitgroups">
<cache usage="read-write" />
- <key column="reporttableid" foreign-key="fk_reporttable_organisationunitgroups_reporttableid" />
+ <key column="reporttableid" foreign-key="fk_reporttable_orgunitunitgroups_reporttableid" />
<list-index column="sort_order" base="0" />
- <many-to-many column="orgunitgroupid" class="org.hisp.dhis.organisationunit.OrganisationUnitGroup" foreign-key="fk_reporttable_organisationunitgroups_orgunitgroupid" />
+ <many-to-many column="orgunitgroupid" class="org.hisp.dhis.organisationunit.OrganisationUnitGroup" foreign-key="fk_reporttable_orgunitgroups_orgunitgroupid" />
</list>
<property name="doIndicators" />
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java 2011-12-22 22:18:22 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java 2011-12-23 10:50:09 +0000
@@ -59,6 +59,8 @@
import org.hisp.dhis.indicator.IndicatorType;
import org.hisp.dhis.jdbc.batchhandler.AggregatedDataValueBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.AggregatedIndicatorValueBatchHandler;
+import org.hisp.dhis.jdbc.batchhandler.AggregatedOrgUnitDataValueBatchHandler;
+import org.hisp.dhis.jdbc.batchhandler.AggregatedOrgUnitIndicatorValueBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.DataSetCompletenessResultBatchHandler;
import org.hisp.dhis.mock.MockI18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -339,6 +341,32 @@
completenessBatchHandler.addObject( new DataSetCompletenessResult( dataSetIdB, periodIdB, null, unitIdB, null, 100, 18, 18 ) );
completenessBatchHandler.flush();
+
+ BatchHandler<AggregatedDataValue> dataValueOrgUnitBatchHandler = batchHandlerFactory.createBatchHandler( AggregatedOrgUnitDataValueBatchHandler.class ).init();
+
+ dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdA, 8, unitIdA, groupIdA, 8, 11 ) );
+ dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdA, 8, unitIdA, groupIdB, 8, 12 ) );
+ dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdB, 8, unitIdA, groupIdA, 8, 13 ) );
+ dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdA, categoryOptionComboIdA, periodIdB, 8, unitIdA, groupIdB, 8, 14 ) );
+ dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdA, 8, unitIdA, groupIdA, 8, 15 ) );
+ dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdA, 8, unitIdA, groupIdB, 8, 16 ) );
+ dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdB, 8, unitIdA, groupIdA, 8, 17 ) );
+ dataValueOrgUnitBatchHandler.addObject( new AggregatedDataValue( dataElementIdB, categoryOptionComboIdA, periodIdB, 8, unitIdA, groupIdB, 8, 18 ) );
+
+ dataValueOrgUnitBatchHandler.flush();
+
+ BatchHandler<AggregatedIndicatorValue> indicatorOrgUnitValueBatchHandler = batchHandlerFactory.createBatchHandler( AggregatedOrgUnitIndicatorValueBatchHandler.class ).init();
+
+ indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdA, 8, unitIdA, groupIdA, 8, "", 1, 11, 0, 0 ) );
+ indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdA, 8, unitIdA, groupIdB, 8, "", 1, 12, 0, 0 ) );
+ indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdB, 8, unitIdA, groupIdA, 8, "", 1, 13, 0, 0 ) );
+ indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdA, periodIdB, 8, unitIdA, groupIdB, 8, "", 1, 14, 0, 0 ) );
+ indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdA, 8, unitIdA, groupIdA, 8, "", 1, 15, 0, 0 ) );
+ indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdA, 8, unitIdA, groupIdB, 8, "", 1, 16, 0, 0 ) );
+ indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdB, 8, unitIdA, groupIdA, 8, "", 1, 17, 0, 0 ) );
+ indicatorOrgUnitValueBatchHandler.addObject( new AggregatedIndicatorValue( indicatorIdB, periodIdB, 8, unitIdA, groupIdB, 8, "", 1, 18, 0, 0 ) );
+
+ indicatorOrgUnitValueBatchHandler.flush();
}
@Override
@@ -357,6 +385,30 @@
// -------------------------------------------------------------------------
@Test
+ public void testGetOrgUnitIndicatorReportTableA()
+ {
+ ReportTable reportTable = new ReportTable( "Prescriptions", false,
+ new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(),
+ groups, null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+
+ reportTable.setParentOrganisationUnit( unitA );
+
+ int id = reportTableService.saveReportTable( reportTable );
+
+ Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, null, 0 );
+
+ assertEquals( 11.0, grid.getRow( 0 ).get( 6 ) );
+ assertEquals( 13.0, grid.getRow( 0 ).get( 7 ) );
+ assertEquals( 15.0, grid.getRow( 0 ).get( 8 ) );
+ assertEquals( 17.0, grid.getRow( 0 ).get( 9 ) );
+
+ assertEquals( 12.0, grid.getRow( 1 ).get( 6 ) );
+ assertEquals( 14.0, grid.getRow( 1 ).get( 7 ) );
+ assertEquals( 16.0, grid.getRow( 1 ).get( 8 ) );
+ assertEquals( 18.0, grid.getRow( 1 ).get( 9 ) );
+ }
+
+ @Test
public void testGetIndicatorReportTableA()
{
ReportTable reportTable = new ReportTable( "Prescriptions", false,
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java 2011-08-24 12:00:26 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java 2011-12-23 10:50:09 +0000
@@ -89,7 +89,7 @@
emptyTable( "reporttable_indicators" );
emptyTable( "reporttable_periods" );
emptyTable( "reporttable_organisationunits" );
- emptyTable( "reporttable_displaycolumns" );
+ emptyTable( "reporttable_orgunitgroups" );
emptyTable( "reporttable" );
emptyTable( "datamartexportdataelements" );
@@ -152,7 +152,10 @@
dropTable( "aggregateddatavalue" );
dropTable( "aggregatedindicatorvalue" );
dropTable( "aggregateddatasetcompleteness" );
- dropTable( "datavaluecrosstab" );
+
+ dropTable( "aggregatedorgunitdatavalue" );
+ dropTable( "aggregatedorgunitindicatorvalue" );
+ dropTable( "aggregatedorgunitdatasetcompleteness" );
log.debug( "Cleared database contents" );