← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16516: Removed PeriodCache bean, replaced by internal cache in PeriodType

 

------------------------------------------------------------
revno: 16516
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-08-26 10:46:50 +0200
message:
  Removed PeriodCache bean, replaced by internal cache in PeriodType
removed:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/cache/
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/cache/PeriodCache.java
modified:
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java
  dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java
  dhis-2/dhis-support/dhis-support-system/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-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java	2014-08-26 07:44:39 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java	2014-08-26 08:46:50 +0000
@@ -142,14 +142,7 @@
     {
         this.sqlViewService = sqlViewService;
     }
-    
-    private PeriodCache periodCache;
-
-    public void setPeriodCache( PeriodCache periodCache )
-    {
-        this.periodCache = periodCache;
-    }
-    
+        
     // -------------------------------------------------------------------------
     // OrganisationUnitStructure
     // -------------------------------------------------------------------------
@@ -461,8 +454,8 @@
             values.add( day.getStartDate() );
 
             for ( PeriodType periodType : periodTypes )
-            {                
-                values.add( periodCache.getIsoPeriod( periodType, day.getStartDate(), calendar ) );
+            {
+                values.add( periodType.createPeriod( day.getStartDate(), calendar ).getIsoDate() );
             }
 
             batchArgs.add( values.toArray() );
@@ -506,8 +499,8 @@
             for ( PeriodType periodType : PeriodType.PERIOD_TYPES )
             {
                 if ( rowType.getFrequencyOrder() <= periodType.getFrequencyOrder() )
-                {
-                    values.add( periodCache.getIsoPeriod( periodType, startDate, calendar ) );
+                {                    
+                    values.add( periodType.createPeriod( startDate, calendar ).getIsoDate() );
                 }
                 else
                 {

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2014-08-24 21:04:36 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2014-08-26 08:46:50 +0000
@@ -18,7 +18,6 @@
     <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     <property name="sqlViewService" ref="org.hisp.dhis.sqlview.SqlViewService" />
-    <property name="periodCache" ref="periodCache" />
   </bean>
   
   <!-- Data integrity -->

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java	2014-08-24 21:24:08 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java	2014-08-26 08:46:50 +0000
@@ -69,9 +69,6 @@
     @Autowired
     private JdbcTemplate jdbcTemplate;
     
-    @Autowired
-    private PeriodCache periodCache;
-    
     //--------------------------------------------------------------------------
     // DataValueSetStore implementation
     //--------------------------------------------------------------------------
@@ -143,7 +140,7 @@
                 PeriodType pt = PeriodType.getPeriodTypeByName( rs.getString( "ptname" ) );
 
                 dataValue.setDataElement( rs.getString( "deuid" ) );
-                dataValue.setPeriod( periodCache.getIsoPeriod( pt, rs.getDate( "pestart" ), calendar ) );
+                dataValue.setPeriod( pt.createPeriod( rs.getDate( "pestart" ), calendar ).getIsoDate() );
                 dataValue.setOrgUnit( rs.getString( "ouuid" ) );
                 dataValue.setCategoryOptionCombo( rs.getString( "cocuid" ) );
                 dataValue.setAttributeOptionCombo( rs.getString( "aocuid" ) );

=== removed directory 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/cache'
=== removed file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/cache/PeriodCache.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/cache/PeriodCache.java	2014-08-26 07:49:22 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/cache/PeriodCache.java	1970-01-01 00:00:00 +0000
@@ -1,78 +0,0 @@
-package org.hisp.dhis.system.cache;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.Date;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-
-import javax.annotation.PostConstruct;
-
-import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.period.PeriodType;
-
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-
-/**
- * @author Lars Helge Overland
- */
-public class PeriodCache
-{
-    private Cache<String, String> periodCache;
-    
-    /**
-     * TODO: In Spring 4 replace with org.springframework.cache.guava.GuavaCacheManager.
-     */
-    @PostConstruct
-    public void init()
-    {
-        periodCache = CacheBuilder.newBuilder().maximumSize( 30000 ).build();
-    }
-    
-    public String getIsoPeriod( final PeriodType periodType, final Date startDate, final Calendar calendar )
-    {
-        try
-        {
-            String key = calendar.name() + periodType.getName() + String.valueOf( startDate.getTime() );
-            
-            return periodCache.get( key, new Callable<String>() 
-            {                
-                public String call()
-                {
-                    return periodType.createPeriod( startDate, calendar ).getIsoDate();
-                }
-            } );
-        }
-        catch ( ExecutionException ex )
-        {
-            throw new RuntimeException( ex );
-        }
-    }
-}

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml	2014-08-24 21:04:36 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml	2014-08-26 08:46:50 +0000
@@ -33,6 +33,4 @@
 
   <bean id="debugger" class="org.hisp.dhis.system.debug.DebuggerImpl" />
   
-  <bean id="periodCache" class="org.hisp.dhis.system.cache.PeriodCache" />
-
 </beans>