← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3727: updated getOrganisationUnitGroupSets ajax action

 

------------------------------------------------------------
revno: 3727
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-24 13:00:34 +0200
message:
  updated getOrganisationUnitGroupSets ajax action
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroupSets.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitGroupSetsAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserGroupsAction.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-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroupSets.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroupSets.vm	2011-04-28 15:43:17 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitGroupSets.vm	2011-05-24 11:00:34 +0000
@@ -6,4 +6,9 @@
     "name": "$!encoder.jsonEncode( ${groupSet.name} )"
   }#if( $velocityCount < $size ),#end    
 #end
-] }
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitGroupSetsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitGroupSetsAction.java	2011-04-28 15:43:17 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitGroupSetsAction.java	2011-05-24 11:00:34 +0000
@@ -1,13 +1,5 @@
 package org.hisp.dhis.commons.action;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
-
-import com.opensymphony.xwork2.Action;
-
 /*
  * Copyright (c) 2004-2010, University of Oslo
  * All rights reserved.
@@ -34,11 +26,22 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupSetNameComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.system.util.IdentifiableObjectUtils;
+
 /**
  * @author Jan Henrik Overland
  */
 public class GetOrganisationUnitGroupSetsAction
-    implements Action
+    extends ActionPagingSupport<OrganisationUnitGroupSet>
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -52,9 +55,16 @@
     }
 
     // -------------------------------------------------------------------------
-    // Output
+    // Input & Output
     // -------------------------------------------------------------------------
 
+    private String key;
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+
     private List<OrganisationUnitGroupSet> organisationUnitGroupSets;
 
     public List<OrganisationUnitGroupSet> getOrganisationUnitGroupSets()
@@ -62,12 +72,30 @@
         return organisationUnitGroupSets;
     }
 
+    // -------------------------------------------------------------------------
+    // Action Implementation
+    // -------------------------------------------------------------------------
+
     @Override
     public String execute()
         throws Exception
     {
-        organisationUnitGroupSets = new ArrayList<OrganisationUnitGroupSet>( organisationUnitGroupService
-            .getAllOrganisationUnitGroupSets() );
+        organisationUnitGroupSets = new ArrayList<OrganisationUnitGroupSet>(
+            organisationUnitGroupService.getAllOrganisationUnitGroupSets() );
+
+        if ( key != null )
+        {
+            organisationUnitGroupSets = IdentifiableObjectUtils.filterNameByKey( organisationUnitGroupSets, key, true );
+        }
+
+        Collections.sort( organisationUnitGroupSets, new OrganisationUnitGroupSetNameComparator() );
+
+        if ( usePaging )
+        {
+            this.paging = createPaging( organisationUnitGroupSets.size() );
+
+            organisationUnitGroupSets = organisationUnitGroupSets.subList( paging.getStartPos(), paging.getEndPos() );
+        }
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserGroupsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserGroupsAction.java	2011-05-24 10:18:10 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetUserGroupsAction.java	2011-05-24 11:00:34 +0000
@@ -30,7 +30,6 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.ListIterator;
 
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.system.util.IdentifiableObjectUtils;