← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10203: fixed bugs with program meta-data

 

------------------------------------------------------------
revno: 10203
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-14 16:06:32 +0700
message:
  fixed bugs with program meta-data
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetProgramMetaDataAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm


--
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-api/src/main/java/org/hisp/dhis/program/ProgramService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java	2013-02-20 08:38:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java	2013-03-14 09:06:32 +0000
@@ -27,11 +27,11 @@
 
 package org.hisp.dhis.program;
 
-import java.util.Collection;
-
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.validation.ValidationCriteria;
 
+import java.util.Collection;
+
 /**
  * @author Abyot Asalefew
  * @version $Id$
@@ -53,15 +53,17 @@
     Collection<Program> getAllPrograms();
 
     Collection<Program> getPrograms( OrganisationUnit organisationUnit );
-    
+
     Collection<Program> getProgramsByCurrentUser();
 
+    Collection<Program> getProgramsByCurrentUser( int type );
+
     Collection<Program> getPrograms( ValidationCriteria validationCriteria );
 
     Collection<Program> getPrograms( int type );
-    
+
     Collection<Program> getPrograms( int type, OrganisationUnit orgunit );
-    
+
     Program getProgram( String uid );
 
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStore.java	2013-02-19 06:54:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStore.java	2013-03-14 09:06:32 +0000
@@ -27,14 +27,13 @@
 
 package org.hisp.dhis.program;
 
-import java.util.Collection;
-
 import org.hisp.dhis.common.GenericNameableObjectStore;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 
+import java.util.Collection;
+
 /**
  * @author Chau Thu Tran
- * 
  * @version $Id: ProgramStore.java Dec 14, 2011 9:22:17 AM $
  */
 public interface ProgramStore
@@ -43,8 +42,10 @@
     String ID = ProgramStore.class.getName();
 
     Collection<Program> getByType( int type );
-    
+
     Collection<Program> get( int type, OrganisationUnit orgunit );
-    
+
     Collection<Program> getByCurrentUser();
+
+    Collection<Program> getByCurrentUser( int type );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java	2013-02-20 08:38:11 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java	2013-03-14 09:06:32 +0000
@@ -27,17 +27,17 @@
 
 package org.hisp.dhis.program;
 
-import static org.hisp.dhis.i18n.I18nUtils.i18n;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
 import org.hisp.dhis.i18n.I18nService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.validation.ValidationCriteria;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.hisp.dhis.i18n.I18nUtils.i18n;
+
 /**
  * @author Abyot Asalefew
  * @version $Id$
@@ -110,7 +110,7 @@
             }
         }
 
-        return i18n( i18nService, programs);
+        return i18n( i18nService, programs );
     }
 
     public Collection<Program> getPrograms( ValidationCriteria validationCriteria )
@@ -125,7 +125,7 @@
             }
         }
 
-        return i18n( i18nService, programs);
+        return i18n( i18nService, programs );
     }
 
     public Collection<Program> getPrograms( int type )
@@ -142,7 +142,13 @@
     {
         return i18n( i18nService, programStore.getByCurrentUser() );
     }
-    
+
+    @Override
+    public Collection<Program> getProgramsByCurrentUser( int type )
+    {
+        return i18n( i18nService, programStore.getByCurrentUser( type ) );
+    }
+
     public Program getProgram( String uid )
     {
         return i18n( i18nService, programStore.getByUid( uid ) );

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java	2013-03-14 07:36:22 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java	2013-03-14 09:06:32 +0000
@@ -27,10 +27,6 @@
 
 package org.hisp.dhis.program.hibernate;
 
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
 import org.hibernate.Criteria;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
@@ -42,9 +38,12 @@
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.user.UserService;
 
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * @author Chau Thu Tran
- * 
  * @version $Id: HibernateProgramStore.java Dec 14, 2011 9:24:21 AM $
  */
 public class HibernateProgramStore
@@ -73,14 +72,14 @@
     // Implemented methods
     // -------------------------------------------------------------------------
 
-    @SuppressWarnings( "unchecked" )
+    @SuppressWarnings("unchecked")
     @Override
     public Collection<Program> getByType( int type )
     {
         return getCriteria( Restrictions.eq( "type", type ) ).list();
     }
 
-    @SuppressWarnings( "unchecked" )
+    @SuppressWarnings("unchecked")
     @Override
     public Collection<Program> get( int type, OrganisationUnit organisationUnit )
     {
@@ -115,4 +114,29 @@
         }
         return programs;
     }
+
+    @Override
+    public Collection<Program> getByCurrentUser( int type )
+    {
+        Collection<Program> programs = new HashSet<Program>();
+
+        if ( !currentUserService.currentUserIsSuper() )
+        {
+            Set<UserAuthorityGroup> userRoles = userService.getUserCredentials( currentUserService.getCurrentUser() )
+                .getUserAuthorityGroups();
+
+            for ( Program program : getByType( type ) )
+            {
+                if ( CollectionUtils.intersection( program.getUserRoles(), userRoles ).size() > 0 )
+                {
+                    programs.add( program );
+                }
+            }
+        }
+        else
+        {
+            programs = getAll();
+        }
+        return programs;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetProgramMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetProgramMetaDataAction.java	2013-02-19 04:01:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetProgramMetaDataAction.java	2013-03-14 09:06:32 +0000
@@ -92,7 +92,7 @@
     @Override
     public String execute() throws Exception
     {
-        programs = new ArrayList<Program>( programService.getPrograms( programType ) );
+        programs = new ArrayList<Program>( programService.getProgramsByCurrentUser( programType ) );
 
         for ( Program program : programs )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm	2013-03-13 18:38:19 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm	2013-03-14 09:06:32 +0000
@@ -1,5 +1,5 @@
 CACHE MANIFEST
-# 2.11-SNAPSHOT V30
+# 2.11-SNAPSHOT V31
 NETWORK:
 *
 CACHE: