dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40621
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20625: Reporting rate summary. Improved performance. Fetching org units with query instead of one by one...
------------------------------------------------------------
revno: 20625
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-10-12 11:16:42 +0200
message:
Reporting rate summary. Improved performance. Fetching org units with query instead of one by one with transactional get.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.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/common/GenericIdentifiableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2015-10-08 14:12:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2015-10-12 09:16:42 +0000
@@ -185,6 +185,14 @@
int getCountLikeName( String name );
/**
+ * Retrieves a list of objects referenced by the given collection of ids.
+ *
+ * @param uids a collection of ids.
+ * @return a list of objects.
+ */
+ List<T> getById( Collection<Integer> ids );
+
+ /**
* Retrieves a list of objects referenced by the given collection of uids.
*
* @param uids a collection of uids.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2015-10-08 14:12:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2015-10-12 09:16:42 +0000
@@ -425,6 +425,18 @@
@Override
@SuppressWarnings( "unchecked" )
+ public List<T> getById( Collection<Integer> ids )
+ {
+ if ( ids == null ||ids.isEmpty() )
+ {
+ return new ArrayList<>();
+ }
+
+ return getSharingCriteria().add( Restrictions.in( "id", ids ) ).list();
+ }
+
+ @Override
+ @SuppressWarnings( "unchecked" )
public List<T> getByUid( Collection<String> uids )
{
if ( uids == null || uids.isEmpty() )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2015-10-08 14:29:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2015-10-12 09:16:42 +0000
@@ -197,18 +197,9 @@
}
@Override
- public List<OrganisationUnit> getOrganisationUnits( final Collection<Integer> identifiers )
+ public List<OrganisationUnit> getOrganisationUnits( Collection<Integer> identifiers )
{
- List<OrganisationUnit> objects = getAllOrganisationUnits();
-
- return identifiers == null ? objects : FilterUtils.filter( objects, new Filter<OrganisationUnit>()
- {
- @Override
- public boolean retain( OrganisationUnit object )
- {
- return identifiers.contains( object.getId() );
- }
- } );
+ return i18n( i18nService, organisationUnitStore.getById( identifiers ) );
}
@Override
=== 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-03 11:09:07 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java 2015-10-12 09:16:42 +0000
@@ -34,6 +34,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.hisp.dhis.completeness.DataSetCompletenessResult;
@@ -49,6 +50,7 @@
import org.hisp.dhis.period.PeriodService;
import org.springframework.transaction.annotation.Transactional;
+import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
@@ -168,10 +170,12 @@
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 );
+
for ( final Integer unitId : organisationUnitIds )
{
- final OrganisationUnit unit = organisationUnitService.getOrganisationUnit( unitId );
+ final OrganisationUnit unit = orgUnits.get( unitId );
final Set<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren(
unit.getId() );