dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #01975
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 644: Implemented required assignment to compulsory group sets when adding new org units.
------------------------------------------------------------
revno: 644
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-09-09 05:20:14 +0200
message:
Implemented required assignment to compulsory group sets when adding new org units.
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AssignOrganisationUnitToGroupsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetCompulsoryGroupSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/assignToCompulsoryGroupSetForm.vm
modified:
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/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/org/hisp/dhis/oum/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.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-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 2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java 2009-09-09 03:20:14 +0000
@@ -146,6 +146,17 @@
}
// -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Integer organisationUnitId;
+
+ public Integer getOrganisationUnitId()
+ {
+ return organisationUnitId;
+ }
+
+ // -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -192,7 +203,7 @@
organisationUnit.setUrl( url );
organisationUnit.setParent( parent );
- organisationUnitService.addOrganisationUnit( organisationUnit );
+ organisationUnitId = organisationUnitService.addOrganisationUnit( organisationUnit );
return SUCCESS;
}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AssignOrganisationUnitToGroupsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AssignOrganisationUnitToGroupsAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AssignOrganisationUnitToGroupsAction.java 2009-09-09 03:20:14 +0000
@@ -0,0 +1,76 @@
+package org.hisp.dhis.oum.action.organisationunit;
+
+import java.util.Collection;
+
+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.system.util.ConversionUtils;
+
+import com.opensymphony.xwork2.Action;
+
+public class AssignOrganisationUnitToGroupsAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ private OrganisationUnitGroupService organisationUnitGroupService;
+
+ public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+ {
+ this.organisationUnitGroupService = organisationUnitGroupService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private Integer organisationUnitId;
+
+ public Integer getOrganisationUnitId()
+ {
+ return organisationUnitId;
+ }
+
+ public void setOrganisationUnitId( Integer organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+ private Collection<String> organisationUnitGroupId;
+
+ public void setOrganisationUnitGroupId( Collection<String> organisationUnitGroupId )
+ {
+ this.organisationUnitGroupId = organisationUnitGroupId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ for ( Integer id : ConversionUtils.getIntegerCollection( organisationUnitGroupId ) )
+ {
+ OrganisationUnitGroup group = organisationUnitGroupService.getOrganisationUnitGroup( id );
+
+ group.getMembers().add( unit );
+
+ organisationUnitGroupService.updateOrganisationUnitGroup( group );
+ }
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetCompulsoryGroupSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetCompulsoryGroupSetAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetCompulsoryGroupSetAction.java 2009-09-09 03:20:14 +0000
@@ -0,0 +1,74 @@
+package org.hisp.dhis.oum.action.organisationunit;
+
+import java.util.Collection;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetCompulsoryGroupSetAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private OrganisationUnitGroupService organisationUnitGroupService;
+
+ public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+ {
+ this.organisationUnitGroupService = organisationUnitGroupService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer organisationUnitId;
+
+ public void setOrganisationUnitId( Integer organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private OrganisationUnitGroupSet groupSet;
+
+ public OrganisationUnitGroupSet getGroupSet()
+ {
+ return groupSet;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ Collection<OrganisationUnitGroupSet> groupSets = organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSetsNotAssignedTo( unit );
+
+ if ( groupSets != null && groupSets.size() > 0 )
+ {
+ groupSet = groupSets.iterator().next();
+
+ return INPUT;
+ }
+
+ return SUCCESS;
+ }
+}
=== 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 2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2009-09-09 03:20:14 +0000
@@ -34,7 +34,8 @@
</bean>
<bean id="org.hisp.dhis.oum.action.organisationunit.AddOrganisationUnitAction"
- class="org.hisp.dhis.oum.action.organisationunit.AddOrganisationUnitAction" scope="prototype">
+ class="org.hisp.dhis.oum.action.organisationunit.AddOrganisationUnitAction"
+ scope="prototype">
<property name="organisationUnitService">
<ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
</property>
@@ -43,6 +44,28 @@
</property>
</bean>
+ <bean id="org.hisp.dhis.oum.action.organisationunit.GetCompulsoryGroupSetAction"
+ class="org.hisp.dhis.oum.action.organisationunit.GetCompulsoryGroupSetAction"
+ scope="prototype">
+ <property name="organisationUnitService">
+ <ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ </property>
+ <property name="organisationUnitGroupService">
+ <ref bean="org.hisp.dhis.organisationunit.OrganisationUnitGroupService"/>
+ </property>
+ </bean>
+
+ <bean id="org.hisp.dhis.oum.action.organisationunit.AssignOrganisationUnitToGroupsAction"
+ class="org.hisp.dhis.oum.action.organisationunit.AssignOrganisationUnitToGroupsAction"
+ scope="prototype">
+ <property name="organisationUnitService">
+ <ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ </property>
+ <property name="organisationUnitGroupService">
+ <ref bean="org.hisp.dhis.organisationunit.OrganisationUnitGroupService"/>
+ </property>
+ </bean>
+
<bean id="org.hisp.dhis.oum.action.organisationunit.UpdateOrganisationUnitAction"
class="org.hisp.dhis.oum.action.organisationunit.UpdateOrganisationUnitAction"
scope="prototype">
@@ -59,11 +82,11 @@
</property>
</bean>
- <bean id="org.hisp.dhis.oum.action.organisationunit.PrepareAddOrganisationUnitAction"
+ <bean id="org.hisp.dhis.oum.action.organisationunit.PrepareAddOrganisationUnitAction"
class="org.hisp.dhis.oum.action.organisationunit.PrepareAddOrganisationUnitAction"
- scope="prototype">
+ scope="prototype">
</bean>
-
+
<!-- OrganisationUnitGroup -->
<bean id="org.hisp.dhis.oum.action.organisationunitgroup.GetOrganisationUnitGroupListAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/org/hisp/dhis/oum/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/org/hisp/dhis/oum/i18n_module.properties 2009-06-25 11:18:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/org/hisp/dhis/oum/i18n_module.properties 2009-09-09 03:20:14 +0000
@@ -109,3 +109,6 @@
longitude = Longitude
type = Type
polygon_coordinates = Polygon coordinates
+assign_to_compulsory_group_set = Assign to compulsory organisation unit group set
+organisation_unit_group_set = Organisation unit group set
+
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml 2009-08-20 08:30:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml 2009-09-09 03:20:14 +0000
@@ -43,10 +43,20 @@
</action>
<action name="addOrganisationUnit" class="org.hisp.dhis.oum.action.organisationunit.AddOrganisationUnitAction">
+ <result name="success" type="chain">getCompulsoryGroupSet</result>
+ <param name="requiredAuthorities">F_ORGANISATIONUNIT_ADD</param>
+ </action>
+
+ <action name="getCompulsoryGroupSet" class="org.hisp.dhis.oum.action.organisationunit.GetCompulsoryGroupSetAction">
<result name="success" type="redirect">organisationUnit.action</result>
- <param name="requiredAuthorities">F_ORGANISATIONUNIT_ADD</param>
- </action>
-
+ <result name="input" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-maintenance-organisationunit/assignToCompulsoryGroupSetForm.vm</param>
+ </action>
+
+ <action name="assignOrganisationUnitToGroups" class="org.hisp.dhis.oum.action.organisationunit.AssignOrganisationUnitToGroupsAction">
+ <result name="success" type="chain">getCompulsoryGroupSet</result>
+ </action>
+
<action name="showUpdateOrganisationUnitForm" class="org.hisp.dhis.oum.action.organisationunit.GetOrganisationUnitAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm</param>
@@ -65,7 +75,7 @@
<param name="onExceptionReturn">plainTextError</param>
<param name="requiredAuthorities">F_ORGANISATIONUNIT_DELETE</param>
</action>
-
+
<!-- OrganisationUnitGroup -->
<action name="organisationUnitGroup" class="org.hisp.dhis.oum.action.organisationunitgroup.GetOrganisationUnitGroupListAction">
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/assignToCompulsoryGroupSetForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/assignToCompulsoryGroupSetForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/assignToCompulsoryGroupSetForm.vm 2009-09-09 03:20:14 +0000
@@ -0,0 +1,20 @@
+
+<h3>$i18n.getString( "assign_to_compulsory_group_set" )</h3>
+
+<p>$i18n.getString( "organisation_unit_group_set" ): $groupSet.name</p>
+
+<form id="assignForm" action="assignOrganisationUnitToGroups.action" method="post">
+
+<p>
+ <select id="organisationUnitGroupId" name="organisationUnitGroupId" size="14" style="width:300px"#if( !$groupSet.exclusive ) multiple#end>
+ #foreach ( $group in $groupSet.organisationUnitGroups )
+ <option value="$group.id">$group.name</option>
+ #end
+ </select>
+</p>
+
+<p><input type="submit" value="$i18n.getString( "save" )" style="width:150px"></p>
+
+<input type="hidden" name="organisationUnitId" value="$organisationUnitId">
+
+</form>
\ No newline at end of file