dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40668
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20662: Reporting rate summary, removed performance bottleneck, moved query out of loop
------------------------------------------------------------
revno: 20662
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-13 09:21:44 +0200
message:
Reporting rate summary, removed performance bottleneck, moved query out of loop
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.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/main/resources/META-INF/dhis/beans.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/common/IdentifiableObjectManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java 2015-10-08 14:29:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java 2015-10-13 07:21:44 +0000
@@ -118,6 +118,8 @@
<T extends NameableObject> Map<String, T> getIdMapNoAcl( Class<T> clazz, NameableProperty property );
<T extends IdentifiableObject> List<T> getObjects( Class<T> clazz, IdentifiableProperty property, Collection<String> identifiers );
+
+ <T extends IdentifiableObject> List<T> getObjects( Class<T> clazz, Collection<Integer> identifiers );
<T extends IdentifiableObject> T getObject( Class<T> clazz, IdentifiableProperty property, String id );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java 2015-10-08 14:29:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java 2015-10-13 07:21:44 +0000
@@ -769,6 +769,20 @@
return null;
}
+
+ @Override
+ @SuppressWarnings( "unchecked" )
+ public <T extends IdentifiableObject> List<T> getObjects( Class<T> clazz, Collection<Integer> identifiers )
+ {
+ GenericIdentifiableObjectStore<T> store = (GenericIdentifiableObjectStore<T>) getIdentifiableObjectStore( clazz );
+
+ if ( store == null )
+ {
+ return null;
+ }
+
+ return store.getById( identifiers );
+ }
@Override
@SuppressWarnings( "unchecked" )
=== 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 2015-10-12 09:16:42 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java 2015-10-13 07:21:44 +0000
@@ -37,6 +37,7 @@
import java.util.Map;
import java.util.Set;
+import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.completeness.DataSetCompletenessResult;
import org.hisp.dhis.completeness.DataSetCompletenessService;
import org.hisp.dhis.completeness.DataSetCompletenessStore;
@@ -44,7 +45,6 @@
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -70,13 +70,6 @@
this.organisationUnitService = organisationUnitService;
}
- private OrganisationUnitGroupService organisationUnitGroupService;
-
- public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
- {
- this.organisationUnitGroupService = organisationUnitGroupService;
- }
-
private DataSetService dataSetService;
public void setDataSetService( DataSetService dataSetService )
@@ -97,6 +90,13 @@
{
this.completenessStore = completenessStore;
}
+
+ private IdentifiableObjectManager idObjectManager;
+
+ public void setIdObjectManager( IdentifiableObjectManager idObjectManager )
+ {
+ this.idObjectManager = idObjectManager;
+ }
// -------------------------------------------------------------------------
// DataSetCompletenessService implementation
@@ -127,6 +127,8 @@
final List<DataSet> dataSets = dataSetService.getAllDataSets();
+ final Set<OrganisationUnitGroup> groups = groupIds != null ? Sets.newHashSet( idObjectManager.getObjects( OrganisationUnitGroup.class, groupIds ) ) : null;
+
final List<DataSetCompletenessResult> results = new ArrayList<>();
for ( final DataSet dataSet : dataSets )
@@ -134,7 +136,7 @@
final List<Integer> periodsBetweenDates = getIdentifiers(
periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() ) );
- final Set<Integer> relevantSources = getRelevantSources( dataSet, children, groupIds );
+ final Set<Integer> relevantSources = getRelevantSources( dataSet, children, groups );
final DataSetCompletenessResult result = new DataSetCompletenessResult();
@@ -169,10 +171,12 @@
final List<Integer> periodsBetweenDates = getIdentifiers(
periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() ) );
- final List<DataSetCompletenessResult> results = new ArrayList<>();
-
final Map<Integer, OrganisationUnit> orgUnits = Maps.uniqueIndex( organisationUnitService.getOrganisationUnits( organisationUnitIds ), OrganisationUnit::getId );
+ final Set<OrganisationUnitGroup> groups = groupIds != null ? Sets.newHashSet( idObjectManager.getObjects( OrganisationUnitGroup.class, groupIds ) ) : null;
+
+ final List<DataSetCompletenessResult> results = new ArrayList<>();
+
for ( final Integer unitId : organisationUnitIds )
{
final OrganisationUnit unit = orgUnits.get( unitId );
@@ -180,7 +184,7 @@
final Set<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren(
unit.getId() );
- final Set<Integer> relevantSources = getRelevantSources( dataSet, children, groupIds );
+ final Set<Integer> relevantSources = getRelevantSources( dataSet, children, groups );
final DataSetCompletenessResult result = getDataSetCompleteness( period, periodsBetweenDates, unit, relevantSources, dataSet );
@@ -219,15 +223,14 @@
return result;
}
- private Set<Integer> getRelevantSources( DataSet dataSet, Set<Integer> sources, Set<Integer> groupIds )
+ private Set<Integer> getRelevantSources( DataSet dataSet, Set<Integer> sources, Set<OrganisationUnitGroup> groups )
{
Set<Integer> dataSetSources = new HashSet<>( getIdentifiers( dataSet.getSources() ) );
- if ( groupIds != null )
+ if ( groups != null )
{
- for ( Integer groupId : groupIds )
+ for ( OrganisationUnitGroup group : groups )
{
- OrganisationUnitGroup group = organisationUnitGroupService.getOrganisationUnitGroup( groupId );
List<Integer> ids = getIdentifiers( group.getMembers() );
dataSetSources.retainAll( ids );
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2015-10-03 11:09:07 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2015-10-13 07:21:44 +0000
@@ -81,10 +81,10 @@
<bean id="compulsoryDataCompletenessService" class="org.hisp.dhis.completeness.impl.CompulsoryDataSetCompletenessService">
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
<property name="completenessStore" ref="org.hisp.dhis.completeness.DataSetCompletenessStore" />
+ <property name="idObjectManager" ref="org.hisp.dhis.common.IdentifiableObjectManager" />
</bean>
<bean id="registrationDataCompletenessService" class="org.hisp.dhis.completeness.impl.RegistrationDataSetCompletenessService"