dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #06623
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1839: Minor fix
------------------------------------------------------------
revno: 1839
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Sun 2010-07-11 08:34:50 +0200
message:
Minor fix
modified:
dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/cache/MemoryAggregationCache.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-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/cache/MemoryAggregationCache.java'
--- dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/cache/MemoryAggregationCache.java 2010-07-10 14:50:48 +0000
+++ dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/cache/MemoryAggregationCache.java 2010-07-11 06:34:50 +0000
@@ -27,7 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -41,6 +40,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.system.util.ConversionUtils;
/**
* @author Lars Helge Overland
@@ -51,7 +51,7 @@
{
private OrganisationUnitHierarchy hierarchyCache = null;
private Map<String, Period> periodCache = new HashMap<String, Period>();
- private Map<String, Collection<Integer>> periodIdCache = new HashMap<String, Collection<Integer>>();
+ private Map<String, Collection<Integer>> intersectingPeriodsCache = new HashMap<String, Collection<Integer>>();
private static final String SEPARATOR = "-";
@@ -118,23 +118,16 @@
{
String key = startDate.toString() + SEPARATOR + endDate.toString();
- Collection<Integer> periodIds = periodIdCache.get( key );
+ Collection<Integer> periodIds = intersectingPeriodsCache.get( key );
if ( periodIds != null )
{
return periodIds;
}
- Collection<Period> periods = periodService.getIntersectingPeriods( startDate, endDate );
-
- periodIds = new ArrayList<Integer>();
-
- for ( Period period : periods )
- {
- periodIds.add( period.getId() );
- }
-
- periodIdCache.put( key, periodIds );
+ periodIds = ConversionUtils.getIdentifiers( Period.class, periodService.getIntersectingPeriods( startDate, endDate ) );
+
+ intersectingPeriodsCache.put( key, periodIds );
return periodIds;
}
@@ -148,6 +141,6 @@
{
hierarchyCache = null;
periodCache.clear();
- periodIdCache.clear();
+ intersectingPeriodsCache.clear();
}
}