dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10766
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2955: Improved performance in completeness export
------------------------------------------------------------
revno: 2955
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-03-01 21:32:55 +0100
message:
Improved performance in completeness export
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceExportTest.java
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.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/completeness/DataSetCompletenessService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java 2011-02-18 20:20:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java 2011-03-01 20:32:55 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.RelativePeriods;
@@ -98,7 +99,7 @@
* @param dataSet the DataSet.
* @return a Collection of DataSetCompletenessResults.
*/
- DataSetCompletenessResult getDataSetCompleteness( Period period, Date deadline, OrganisationUnit unit, DataSet dataSet );
+ DataSetCompletenessResult getDataSetCompleteness( Period period, Date deadline, OrganisationUnit unit, OrganisationUnitHierarchy hierarchy, DataSet dataSet );
/**
* Creates an index on the aggregateddatasetcompleteness table.
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java 2011-03-01 19:44:03 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java 2011-03-01 20:32:55 +0000
@@ -50,6 +50,7 @@
import org.hisp.dhis.jdbc.batchhandler.DataSetCompletenessResultBatchHandler;
import org.hisp.dhis.options.SystemSettingManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -171,6 +172,9 @@
Collection<OrganisationUnit> units = organisationUnitService.getOrganisationUnits( organisationUnitIds );
Collection<DataSet> dataSets = dataSetService.getDataSets( dataSetIds );
+ OrganisationUnitHierarchy hierarchy = organisationUnitService.getOrganisationUnitHierarchy();
+ hierarchy.prepareChildren( units );
+
Collection<Period> intersectingPeriods = null;
Date deadline = null;
DataSetCompletenessResult result = null;
@@ -196,7 +200,7 @@
{
deadline = getDeadline( intersectingPeriod, days );
- result = getDataSetCompleteness( intersectingPeriod, deadline, unit, dataSet );
+ result = getDataSetCompleteness( intersectingPeriod, deadline, unit, hierarchy, dataSet );
aggregatedResult.incrementSources( result.getSources() );
aggregatedResult.incrementRegistrations( result.getRegistrations() );
@@ -295,9 +299,9 @@
return results;
}
- public DataSetCompletenessResult getDataSetCompleteness( Period period, Date deadline, OrganisationUnit unit, DataSet dataSet )
+ public DataSetCompletenessResult getDataSetCompleteness( Period period, Date deadline, OrganisationUnit unit, OrganisationUnitHierarchy hierarchy, DataSet dataSet )
{
- final Collection<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren( unit.getId() );
+ final Collection<Integer> children = hierarchy.getChildren( unit.getId() );
final DataSetCompletenessResult result = new DataSetCompletenessResult();
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceExportTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceExportTest.java 2011-02-03 17:03:02 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceExportTest.java 2011-03-01 20:32:55 +0000
@@ -39,6 +39,7 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
@@ -160,13 +161,15 @@
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitB, null ) );
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitA, null ) );
- DataSetCompletenessResult resultA = completenessService.getDataSetCompleteness( periodA, null, unitB, dataSetA );
- DataSetCompletenessResult resultB = completenessService.getDataSetCompleteness( periodA, null, unitC, dataSetA );
- DataSetCompletenessResult resultC = completenessService.getDataSetCompleteness( periodA, null, unitA, dataSetA );
- DataSetCompletenessResult resultD = completenessService.getDataSetCompleteness( periodB, null, unitB, dataSetA );
- DataSetCompletenessResult resultE = completenessService.getDataSetCompleteness( periodB, null, unitC, dataSetA );
- DataSetCompletenessResult resultF = completenessService.getDataSetCompleteness( periodB, null, unitA, dataSetA );
-
+ OrganisationUnitHierarchy hierarchy = organisationUnitService.getOrganisationUnitHierarchy();
+
+ DataSetCompletenessResult resultA = completenessService.getDataSetCompleteness( periodA, null, unitB, hierarchy, dataSetA );
+ DataSetCompletenessResult resultB = completenessService.getDataSetCompleteness( periodA, null, unitC, hierarchy, dataSetA );
+ DataSetCompletenessResult resultC = completenessService.getDataSetCompleteness( periodA, null, unitA, hierarchy, dataSetA );
+ DataSetCompletenessResult resultD = completenessService.getDataSetCompleteness( periodB, null, unitB, hierarchy, dataSetA );
+ DataSetCompletenessResult resultE = completenessService.getDataSetCompleteness( periodB, null, unitC, hierarchy, dataSetA );
+ DataSetCompletenessResult resultF = completenessService.getDataSetCompleteness( periodB, null, unitA, hierarchy, dataSetA );
+
assertEquals( new DataSetCompletenessResult( unitB.getName(), 1, 1, 0 ), resultA );
assertEquals( new DataSetCompletenessResult( unitC.getName(), 1, 1, 0 ), resultB );
assertEquals( new DataSetCompletenessResult( unitA.getName(), 3, 2, 0 ), resultC );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java 2011-02-18 20:20:07 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java 2011-03-01 20:32:55 +0000
@@ -42,6 +42,7 @@
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.external.location.LocationManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -383,10 +384,12 @@
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitE, onTimeA ) );
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitF, onTimeA ) );
-
- DataSetCompletenessResult resultA = completenessService.getDataSetCompleteness( periodA, tooLateA, unitB, dataSetA );
- DataSetCompletenessResult resultB = completenessService.getDataSetCompleteness( periodA, tooLateA, unitE, dataSetA );
- DataSetCompletenessResult resultC = completenessService.getDataSetCompleteness( periodA, tooLateA, unitG, dataSetA );
+
+ OrganisationUnitHierarchy hierarchy = organisationUnitService.getOrganisationUnitHierarchy();
+
+ DataSetCompletenessResult resultA = completenessService.getDataSetCompleteness( periodA, tooLateA, unitB, hierarchy, dataSetA );
+ DataSetCompletenessResult resultB = completenessService.getDataSetCompleteness( periodA, tooLateA, unitE, hierarchy, dataSetA );
+ DataSetCompletenessResult resultC = completenessService.getDataSetCompleteness( periodA, tooLateA, unitG, hierarchy, dataSetA );
DataSetCompletenessResult referenceA = new DataSetCompletenessResult( unitB.getName(), 2, 2, 2 );
DataSetCompletenessResult referenceB = new DataSetCompletenessResult( unitE.getName(), 1, 1, 1 );