← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14693: DataApprovalLevel, caching

 

------------------------------------------------------------
revno: 14693
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-06 11:32:37 +0200
message:
  DataApprovalLevel, caching
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java
  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/org/hisp/dhis/dataapproval/hibernate/DataApprovalLevel.hbm.xml
  dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.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/dataapproval/DefaultDataApprovalLevelService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java	2014-04-04 16:47:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java	2014-04-06 09:32:37 +0000
@@ -130,7 +130,7 @@
             for ( OrganisationUnit orgUnit : user.getOrganisationUnits() )
             {
                 int orgUnitLevel = orgUnit.getLevel() != 0 ?
-                        orgUnit.getLevel() : organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getUid() );
+                    orgUnit.getLevel() : organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getUid() );
 
                 userOrgUnitLevels.add( orgUnitLevel );
             }
@@ -142,7 +142,7 @@
             for ( DataApprovalLevel approvalLevel : getAllDataApprovalLevels() )
             {
                 Boolean canReadThisLevel = ( securityService.canRead( approvalLevel ) &&
-                        ( approvalLevel.getCategoryOptionGroupSet() == null || securityService.canRead( approvalLevel.getCategoryOptionGroupSet() ) ) );
+                    ( !approvalLevel.hasCategoryOptionGroupSet() || securityService.canRead( approvalLevel.getCategoryOptionGroupSet() ) ) );
 
                 //
                 // Test using assignedAtLevel and approvableAtLevel values from the previous (higher) level:
@@ -150,7 +150,7 @@
                 Boolean addBecauseOfPreviousLevel = false;
 
                 if ( canReadThisLevel && ( approvableAtLevel // Approve at previous higher level implies unapprove at current level.
-                        || ( assignedAtLevel && mayAcceptAtLowerLevels ) ) ) // Assigned at previous level and mayAcceptAtLowerLevels means may accept here.
+                    || ( assignedAtLevel && mayAcceptAtLowerLevels ) ) ) // Assigned at previous level and mayAcceptAtLowerLevels means may accept here.
                 {
                     addBecauseOfPreviousLevel = true;
                 }
@@ -174,7 +174,6 @@
                 {
                     userDataApprovalLevels.add( approvalLevel );
                 }
-
             }
         }
 
@@ -201,7 +200,7 @@
         DataApprovalLevel next = dataApprovalLevels.get( index + 1 );
 
         if ( test.getOrgUnitLevel() == next.getOrgUnitLevel()
-                && test.getCategoryOptionGroupSet() != null )
+            && test.getCategoryOptionGroupSet() != null )
         {
             return true;
         }
@@ -226,7 +225,7 @@
         DataApprovalLevel previous = dataApprovalLevels.get( index - 1 );
 
         if ( test.getOrgUnitLevel() == previous.getOrgUnitLevel()
-                && previous.getCategoryOptionGroupSet() != null )
+            && previous.getCategoryOptionGroupSet() != null )
         {
             return true;
         }
@@ -259,7 +258,7 @@
         for ( DataApprovalLevel dataApprovalLevel : dataApprovalLevels )
         {
             if ( level.getOrgUnitLevel() == dataApprovalLevel.getOrgUnitLevel()
-                    && level.getCategoryOptionGroupSet() == dataApprovalLevel.getCategoryOptionGroupSet() )
+                && level.getCategoryOptionGroupSet() == dataApprovalLevel.getCategoryOptionGroupSet() )
             {
                 return true;
             }

=== 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	2014-04-04 03:49:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2014-04-06 09:32:37 +0000
@@ -75,6 +75,7 @@
   <bean id="org.hisp.dhis.dataapproval.DataApprovalLevelStore" class="org.hisp.dhis.dataapproval.hibernate.HibernateDataApprovalLevelStore">
     <property name="clazz" value="org.hisp.dhis.dataapproval.DataApprovalLevel" />
     <property name="sessionFactory" ref="sessionFactory" />
+    <property name="cacheable" value="true" />
   </bean>
 
     <bean id="org.hisp.dhis.filter.MetaDataFilterStore" class="org.hisp.dhis.metadatafilter.hibernate.HibernateMetaDataFilterStore">

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataapproval/hibernate/DataApprovalLevel.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataapproval/hibernate/DataApprovalLevel.hbm.xml	2014-04-04 17:20:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataapproval/hibernate/DataApprovalLevel.hbm.xml	2014-04-06 09:32:37 +0000
@@ -7,6 +7,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.dataapproval.DataApprovalLevel" table="dataapprovallevel">
 
+    <cache usage="read-write" />
+    
     <id name="id" column="dataapprovallevelid">
       <generator class="native" />
     </id>
@@ -27,6 +29,7 @@
     <property name="publicAccess" length="8" />
 
     <set name="userGroupAccesses" table="dataapprovallevelusergroupaccesses">
+      <cache usage="read-write" />
       <key column="dataapprovallevelid" />
       <many-to-many class="org.hisp.dhis.user.UserGroupAccess" column="usergroupaccessid" unique="true" />
     </set>

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2014-03-31 13:40:09 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2014-04-06 09:32:37 +0000
@@ -123,6 +123,8 @@
   <cache name="org.hisp.dhis.option.OptionSet" maxElementsInMemory="50" />
 
   <cache name="org.hisp.dhis.dataset.LockException" maxElementsInMemory="1000" />
+  
+  <cache name="org.hisp.dhis.dataapproval.DataApprovalLevel" maxElementsInMemory="20" />
 
   <cache name="org.hisp.dhis.filter.MetaDataFilter" maxElementsInMemory="100" />
 
@@ -345,6 +347,8 @@
   <cache name="org.hisp.dhis.option.OptionSet.options" maxElementsInMemory="2000" />
 
   <cache name="org.hisp.dhis.option.OptionSet.userGroupAccesses" maxElementsInMemory="200" />
+  
+  <cache name="org.hisp.dhis.dataapproval.DataApprovalLevel.userGroupAccesses" maxElementsInMemory="500" />
 
   <cache name="org.hisp.dhis.interpretation.Interpretation.userGroupAccesses" maxElementsInMemory="200" />