← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7614: Centralized period type reloading

 

------------------------------------------------------------
revno: 7614
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-07-15 18:51:06 +0200
message:
  Centralized period type reloading
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/hibernate/HibernateValidationRuleStore.java
  dhis-2/dhis-services/dhis-service-core/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-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java	2012-05-29 21:23:47 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java	2012-07-15 16:51:06 +0000
@@ -27,6 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+
 import org.hibernate.Criteria;
 import org.hibernate.Query;
 import org.hibernate.Session;
@@ -35,12 +37,10 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetStore;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.PeriodStore;
+import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.system.util.ConversionUtils;
 
-import java.util.Collection;
-
 /**
  * @author Kristian Nordal
  */
@@ -52,11 +52,11 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private PeriodStore periodStore;
+    private PeriodService periodService;
 
-    public void setPeriodStore( PeriodStore periodStore )
+    public void setPeriodService( PeriodService periodService )
     {
-        this.periodStore = periodStore;
+        this.periodService = periodService;
     }
 
     // -------------------------------------------------------------------------
@@ -66,7 +66,7 @@
     @Override
     public int save( DataSet dataSet )
     {
-        PeriodType periodType = periodStore.getPeriodType( dataSet.getPeriodType().getClass() );
+        PeriodType periodType = periodService.reloadPeriodType( dataSet.getPeriodType() );
 
         dataSet.setPeriodType( periodType );
 
@@ -76,7 +76,7 @@
     @Override
     public void update( DataSet dataSet )
     {
-        PeriodType periodType = periodStore.getPeriodType( dataSet.getPeriodType().getClass() );
+        PeriodType periodType = periodService.reloadPeriodType( dataSet.getPeriodType() );
 
         dataSet.setPeriodType( periodType );
 
@@ -86,7 +86,7 @@
     @SuppressWarnings( "unchecked" )
     public Collection<DataSet> getDataSetsByPeriodType( PeriodType periodType )
     {
-        periodType = periodStore.getPeriodType( periodType.getClass() );
+        periodType = periodService.reloadPeriodType( periodType );
 
         Session session = sessionFactory.getCurrentSession();
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/hibernate/HibernateValidationRuleStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/hibernate/HibernateValidationRuleStore.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/hibernate/HibernateValidationRuleStore.java	2012-07-15 16:51:06 +0000
@@ -33,7 +33,7 @@
 
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.period.PeriodStore;
+import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.system.util.ConversionUtils;
 import org.hisp.dhis.validation.ValidationRule;
@@ -52,11 +52,11 @@
     // Dependency
     // -------------------------------------------------------------------------
 
-    private PeriodStore periodStore;
+    private PeriodService periodService;
 
-    public void setPeriodStore( PeriodStore periodStore )
+    public void setPeriodService( PeriodService periodService )
     {
-        this.periodStore = periodStore;
+        this.periodService = periodService;
     }
 
     // -------------------------------------------------------------------------
@@ -66,7 +66,7 @@
     @Override
     public int save( ValidationRule validationRule )
     {
-        PeriodType periodType = periodStore.getPeriodType( validationRule.getPeriodType().getClass() );
+        PeriodType periodType = periodService.reloadPeriodType( validationRule.getPeriodType() );
 
         validationRule.setPeriodType( periodType );
 
@@ -76,7 +76,7 @@
     @Override
     public void update( ValidationRule validationRule )
     {
-        PeriodType periodType = periodStore.getPeriodType( validationRule.getPeriodType().getClass() );
+        PeriodType periodType = periodService.reloadPeriodType( validationRule.getPeriodType() );
 
         validationRule.setPeriodType( periodType );
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-07-01 11:33:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-07-15 16:51:06 +0000
@@ -89,7 +89,7 @@
   <bean id="org.hisp.dhis.dataset.DataSetStore" class="org.hisp.dhis.dataset.hibernate.HibernateDataSetStore">
     <property name="clazz" value="org.hisp.dhis.dataset.DataSet" />
     <property name="sessionFactory" ref="sessionFactory" />
-    <property name="periodStore" ref="org.hisp.dhis.period.PeriodStore" />
+    <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     <property name="cacheable" value="true" />
   </bean>
 
@@ -121,7 +121,7 @@
   <bean id="org.hisp.dhis.validation.ValidationRuleStore" class="org.hisp.dhis.validation.hibernate.HibernateValidationRuleStore">
     <property name="clazz" value="org.hisp.dhis.validation.ValidationRule" />
     <property name="sessionFactory" ref="sessionFactory" />
-    <property name="periodStore" ref="org.hisp.dhis.period.PeriodStore" />
+    <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     <property name="cacheable" value="true" />
   </bean>