← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18720: Add/edit org unit. Get org unit groups and data set no ACL.

 

------------------------------------------------------------
revno: 18720
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-03-27 18:33:25 +0100
message:
  Add/edit org unit. Get org unit groups and data set no ACL.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/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-api/src/main/java/org/hisp/dhis/common/GenericStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java	2015-02-17 07:22:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java	2015-03-27 17:33:25 +0000
@@ -74,6 +74,14 @@
      * @return the object identified by the given identifier.
      */
     T get( int id );
+    
+    /**
+     * Retrieves the object with the given identifier. Bypasses the ACL solution.
+     * 
+     * @param id the object identifier.
+     * @return the object identified by the given identifier.
+     */
+    T getNoAcl( int id );
 
     /**
      * Retrieves the object with the given identifier, assuming it exists.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java	2015-03-26 16:20:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java	2015-03-27 17:33:25 +0000
@@ -146,6 +146,8 @@
     // -------------------------------------------------------------------------
 
     <T extends IdentifiableObject> T getNoAcl( Class<T> clazz, String uid );
+    
+    <T extends IdentifiableObject> T getNoAcl( Class<T> clazz, int id );
 
     <T extends IdentifiableObject> void updateNoAcl( T object );
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2015-03-26 16:20:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2015-03-27 17:33:25 +0000
@@ -883,6 +883,20 @@
 
         return (T) store.getByUidNoAcl( uid );
     }
+    
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public <T extends IdentifiableObject> T getNoAcl( Class<T> clazz, int id )
+    {
+        GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
+
+        if ( store == null )
+        {
+            return null;
+        }
+
+        return (T) store.getNoAcl( id );
+    }
 
     @Override
     public <T extends IdentifiableObject> void updateNoAcl( T object )

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2015-03-18 20:13:23 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2015-03-27 17:33:25 +0000
@@ -415,6 +415,13 @@
 
     @Override
     @SuppressWarnings( "unchecked" )
+    public final T getNoAcl( int id )
+    {
+        return (T) sessionFactory.getCurrentSession().get( getClazz(), id );
+    }
+    
+    @Override
+    @SuppressWarnings( "unchecked" )
     public final T load( int id )
     {
         T object = (T) sessionFactory.getCurrentSession().load( getClazz(), id );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java	2015-03-11 11:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java	2015-03-27 17:33:25 +0000
@@ -37,10 +37,9 @@
 import org.hisp.dhis.calendar.CalendarService;
 import org.hisp.dhis.calendar.DateTimeUnit;
 import org.hisp.dhis.common.IdentifiableObjectManager;
-import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.system.util.AttributeUtils;
@@ -59,19 +58,17 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    @Autowired
     private OrganisationUnitService organisationUnitService;
 
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
-    private OrganisationUnitGroupService organisationUnitGroupService;
-
-    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
-    {
-        this.organisationUnitGroupService = organisationUnitGroupService;
-    }
+    @Autowired
+    private AttributeService attributeService;
+
+    @Autowired
+    private IdentifiableObjectManager manager;
+
+    @Autowired
+    private CalendarService calendarService;
 
     private OrganisationUnitSelectionManager selectionManager;
 
@@ -80,31 +77,6 @@
         this.selectionManager = selectionManager;
     }
 
-    private DataSetService dataSetService;
-
-    public void setDataSetService( DataSetService dataSetService )
-    {
-        this.dataSetService = dataSetService;
-    }
-
-    private AttributeService attributeService;
-
-    public void setAttributeService( AttributeService attributeService )
-    {
-        this.attributeService = attributeService;
-    }
-
-    private IdentifiableObjectManager manager;
-
-    @Autowired
-    public void setManager( IdentifiableObjectManager manager )
-    {
-        this.manager = manager;
-    }
-
-    @Autowired
-    private CalendarService calendarService;
-
     // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------
@@ -303,13 +275,12 @@
 
         for ( String id : dataSets )
         {
-            organisationUnit.addDataSet( dataSetService.getDataSet( Integer.parseInt( id ) ) );
+            organisationUnit.addDataSet( manager.getNoAcl( DataSet.class, Integer.parseInt( id ) ) );
         }
 
         for ( String id : selectedGroups )
         {
-            OrganisationUnitGroup group = organisationUnitGroupService
-                .getOrganisationUnitGroup( Integer.parseInt( id ) );
+            OrganisationUnitGroup group = manager.getNoAcl( OrganisationUnitGroup.class, Integer.parseInt( id ) );
 
             if ( group != null )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java	2015-03-11 11:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java	2015-03-27 17:33:25 +0000
@@ -43,10 +43,8 @@
 import org.hisp.dhis.calendar.DateTimeUnit;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.system.util.AttributeUtils;
@@ -65,43 +63,16 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    @Autowired
     private OrganisationUnitService organisationUnitService;
 
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-
-    private OrganisationUnitGroupService organisationUnitGroupService;
-
-    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
-    {
-        this.organisationUnitGroupService = organisationUnitGroupService;
-    }
-
-    private DataSetService dataSetService;
-
-    public void setDataSetService( DataSetService dataSetService )
-    {
-        this.dataSetService = dataSetService;
-    }
-
+    @Autowired
     private AttributeService attributeService;
 
-    public void setAttributeService( AttributeService attributeService )
-    {
-        this.attributeService = attributeService;
-    }
-
+    @Autowired
     private IdentifiableObjectManager manager;
 
     @Autowired
-    public void setManager( IdentifiableObjectManager manager )
-    {
-        this.manager = manager;
-    }
-
-    @Autowired
     private CalendarService calendarService;
 
     // -------------------------------------------------------------------------
@@ -322,7 +293,7 @@
 
         for ( String id : dataSets )
         {
-            sets.add( dataSetService.getDataSet( Integer.parseInt( id ) ) );
+            sets.add( manager.getNoAcl( DataSet.class, Integer.parseInt( id ) ) );
         }
 
         organisationUnit.updateDataSets( sets );
@@ -331,12 +302,12 @@
 
         for ( int i = 0; i < orgUnitGroupSets.size(); i++ )
         {
-            OrganisationUnitGroupSet groupSet = organisationUnitGroupService.getOrganisationUnitGroupSet( Integer
+            OrganisationUnitGroupSet groupSet = manager.getNoAcl( OrganisationUnitGroupSet.class, Integer
                 .parseInt( orgUnitGroupSets.get( i ) ) );
 
             OrganisationUnitGroup oldGroup = groupSet.getGroup( organisationUnit );
 
-            OrganisationUnitGroup newGroup = organisationUnitGroupService.getOrganisationUnitGroup( Integer
+            OrganisationUnitGroup newGroup = manager.getNoAcl( OrganisationUnitGroup.class, Integer
                 .parseInt( orgUnitGroups.get( i ) ) );
 
             if ( oldGroup != null && oldGroup.getMembers().remove( organisationUnit ) )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml	2014-12-04 06:39:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml	2015-03-27 17:33:25 +0000
@@ -22,11 +22,7 @@
 
   <bean id="org.hisp.dhis.oum.action.organisationunit.AddOrganisationUnitAction" class="org.hisp.dhis.oum.action.organisationunit.AddOrganisationUnitAction"
     scope="prototype">
-    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-    <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
-    <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
     <property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-    <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
   </bean>
 
   <bean id="org.hisp.dhis.oum.action.organisationunit.GetCompulsoryGroupSetAction" class="org.hisp.dhis.oum.action.organisationunit.GetCompulsoryGroupSetAction"
@@ -42,12 +38,7 @@
   </bean>
 
   <bean id="org.hisp.dhis.oum.action.organisationunit.UpdateOrganisationUnitAction" class="org.hisp.dhis.oum.action.organisationunit.UpdateOrganisationUnitAction"
-    scope="prototype">
-    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-    <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
-    <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
-    <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
-  </bean>
+    scope="prototype" />
 
   <bean id="org.hisp.dhis.oum.action.organisationunit.RemoveOrganisationUnitAction" class="org.hisp.dhis.oum.action.organisationunit.RemoveOrganisationUnitAction"
     scope="prototype">