dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #06506
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2074: Removed unused code
------------------------------------------------------------
revno: 2074
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Sun 2010-07-04 10:53:02 +0200
message:
Removed unused code
modified:
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/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-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/MemoryAggregationCache.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/MemoryAggregationCache.java 2010-06-17 22:42:56 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/cache/MemoryAggregationCache.java 2010-07-04 08:53:02 +0000
@@ -32,7 +32,6 @@
import java.util.HashMap;
import java.util.Map;
-import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -40,7 +39,6 @@
/**
* @author Lars Helge Overland
- * @version $Id: MemoryAggregationCache.java 4646 2008-02-26 14:54:29Z larshelg $
*/
public class MemoryAggregationCache
implements AggregationCache
@@ -51,14 +49,10 @@
// Cache
// -------------------------------------------------------------------------
- private final ThreadLocal<OrganisationUnitHierarchy> latestHierarchyCache = new ThreadLocal<OrganisationUnitHierarchy>();
-
- private final ThreadLocal<Map<String, Collection<OrganisationUnitHierarchy>>> hierarchyCache = new ThreadLocal<Map<String,Collection<OrganisationUnitHierarchy>>>();
-
- private final ThreadLocal<Map<String, Collection<Integer>>> childrenCache = new ThreadLocal<Map<String,Collection<Integer>>>();
-
private final ThreadLocal<Map<String, Collection<Integer>>> intersectingPeriodCache = new ThreadLocal<Map<String,Collection<Integer>>>();
+ private final ThreadLocal<Map<String, Collection<Integer>>> periodsBetweenDatesCache = new ThreadLocal<Map<String,Collection<Integer>>>();
+
private final ThreadLocal<Map<String, Period>> periodCache = new ThreadLocal<Map<String,Period>>();
private final ThreadLocal<Map<String, Integer>> organisationUnitLevelCache = new ThreadLocal<Map<String, Integer>>();
@@ -109,6 +103,30 @@
return periods;
}
+ public Collection<Integer> getPeriodsBetweenDates( final Date startDate, final Date endDate )
+ {
+ final String key = startDate.toString() + SEPARATOR + endDate.toString();
+
+ Map<String, Collection<Integer>> cache = periodsBetweenDatesCache.get();
+
+ Collection<Integer> periods = null;
+
+ if ( cache != null && ( periods = cache.get( key ) ) != null )
+ {
+ return periods;
+ }
+
+ periods = ConversionUtils.getIdentifiers( Period.class, periodService.getPeriodsBetweenDates( startDate, endDate ) );
+
+ cache = ( cache == null ) ? new HashMap<String, Collection<Integer>>() : cache;
+
+ cache.put( key, periods );
+
+ periodsBetweenDatesCache.set( cache );
+
+ return periods;
+ }
+
public Period getPeriod( final int id )
{
final String key = String.valueOf( id );
@@ -159,10 +177,9 @@
public void clearCache()
{
- latestHierarchyCache.remove();
- hierarchyCache.remove();
- childrenCache.remove();
intersectingPeriodCache.remove();
+ periodsBetweenDatesCache.remove();
periodCache.remove();
+ organisationUnitLevelCache.remove();
}
}