← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14220: Data entry by-passing sharing acl for data sets - controlled through user roles. Sorting of roles...

 

------------------------------------------------------------
revno: 14220
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-03-14 11:15:34 +0100
message:
  Data entry by-passing sharing acl for data sets - controlled through user roles. Sorting of roles in update user.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.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-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2013-12-13 16:50:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2014-03-14 10:15:34 +0000
@@ -177,6 +177,15 @@
     List<T> getByUid( Collection<String> uids );
 
     /**
+     * Retrieves a list of objects referenced by the given List of uids. 
+     * Bypasses the ACL system.
+     *
+     * @param uids a List of uids.
+     * @return a list of objects.
+     */
+    List<T> getByUidNoAcl( Collection<String> uids );
+
+    /**
      * Returns all objects that are equal to or newer than given date.
      *
      * @param created Date to compare with.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java	2014-01-02 13:36:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java	2014-03-14 10:15:34 +0000
@@ -244,6 +244,14 @@
     List<DataSet> getDataSetsByUid( Collection<String> uids );
 
     /**
+     * Returns a list of data sets with the given uids. Bypasses the ACL system.
+     *
+     * @param uids the collection of uids.
+     * @return a list of data sets.
+     */
+    List<DataSet> getDataSetsByUidNoAcl( Collection<String> uids );
+
+    /**
      * Returns a collection of data elements associated with the given
      * corresponding data set.
      *

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java	2014-02-12 14:22:58 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java	2014-03-14 10:15:34 +0000
@@ -639,6 +639,27 @@
         return list;
     }
 
+    @Override
+    public List<T> getByUidNoAcl( Collection<String> uids )
+    {
+        List<T> list = new ArrayList<T>();
+
+        if ( uids != null )
+        {
+            for ( String uid : uids )
+            {
+                T object = getByUidNoAcl( uid );
+
+                if ( object != null )
+                {
+                    list.add( object );
+                }
+            }
+        }
+
+        return list;
+    }
+
     //----------------------------------------------------------------------------------------------------------------
     // No ACL (unfiltered methods)
     //----------------------------------------------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2014-01-02 13:36:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2014-03-14 10:15:34 +0000
@@ -358,6 +358,11 @@
     {
         return dataSetStore.getByUid( uids );
     }
+    
+    public List<DataSet> getDataSetsByUidNoAcl( Collection<String> uids )
+    {
+        return dataSetStore.getByUidNoAcl( uids );
+    }
 
     public Collection<DataElement> getDataElements( DataSet dataSet )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2014-03-05 14:22:19 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2014-03-14 10:15:34 +0000
@@ -187,10 +187,8 @@
     public int countGetTrackedEntityInstancesByOrgUnitProgram( OrganisationUnit organisationUnit, Program program )
     {
         String sql = "select count(p.trackedentityinstanceid) from trackedentityinstance p join programinstance pi on p.trackedentityinstanceid=pi.trackedentityinstanceid "
-            + "where p.organisationunitid="
-            + organisationUnit.getId()
-            + " and pi.programid="
-            + program.getId()
+            + "where p.organisationunitid=" + organisationUnit.getId()
+            + " and pi.programid=" + program.getId()
             + " and pi.status=" + ProgramInstance.STATUS_ACTIVE;
 
         return jdbcTemplate.queryForObject( sql, Integer.class );

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2014-02-25 05:51:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2014-03-14 10:15:34 +0000
@@ -241,7 +241,7 @@
 
         organisationUnitAssociationSetMap = organisationUnitSet.getOrganisationUnitAssociationSetMap();
 
-        dataSets = new ArrayList<DataSet>( dataSetService.getDataSetsByUid( organisationUnitSet.getDistinctDataSets() ) );
+        dataSets = new ArrayList<DataSet>( dataSetService.getDataSetsByUidNoAcl( organisationUnitSet.getDistinctDataSets() ) );
 
         Set<DataElementCategoryCombo> categoryComboSet = new HashSet<DataElementCategoryCombo>();
         Set<DataElementCategory> categorySet = new HashSet<DataElementCategory>();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java	2014-01-22 12:50:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java	2014-03-14 10:15:34 +0000
@@ -42,6 +42,7 @@
 import org.hisp.dhis.attribute.Attribute;
 import org.hisp.dhis.attribute.AttributeService;
 import org.hisp.dhis.attribute.comparator.AttributeSortOrderComparator;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.i18n.I18nService;
 import org.hisp.dhis.i18n.locale.LocaleManager;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
@@ -136,9 +137,9 @@
         return userCredentials;
     }
 
-    private Collection<UserAuthorityGroup> userAuthorityGroups;
+    private List<UserAuthorityGroup> userAuthorityGroups;
 
-    public Collection<UserAuthorityGroup> getUserAuthorityGroups()
+    public List<UserAuthorityGroup> getUserAuthorityGroups()
     {
         return userAuthorityGroups;
     }
@@ -236,6 +237,8 @@
             currentLocale = LocaleManager.DHIS_STANDARD_LOCALE;
         }
 
+        Collections.sort( userAuthorityGroups, IdentifiableObjectNameComparator.INSTANCE );
+        
         attributes = new ArrayList<Attribute>( attributeService.getUserAttributes() );
         Collections.sort( attributes, AttributeSortOrderComparator.INSTANCE );