← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5487: minor fix

 

------------------------------------------------------------
revno: 5487
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-12-19 20:47:55 +0100
message:
  minor fix
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeTypeController.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-api/src/main/java/org/hisp/dhis/api/controller/AttributeTypeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeTypeController.java	2011-12-19 18:07:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeTypeController.java	2011-12-19 19:47:55 +0000
@@ -34,6 +34,7 @@
 import org.hisp.dhis.attribute.Attribute;
 import org.hisp.dhis.attribute.AttributeService;
 import org.hisp.dhis.attribute.Attributes;
+import org.hisp.dhis.common.Pager;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -45,6 +46,7 @@
 import javax.servlet.http.HttpServletResponse;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -66,15 +68,22 @@
     public String getAttributeTypes( IdentifiableObjectParams params, Model model, HttpServletRequest request )
     {
         Attributes attributes = new Attributes();
-        attributes.setAttributes( new ArrayList<Attribute>( attributeService.getAllAttributes() ) );
 
         if ( params.isPaging() )
         {
-
+            int total = attributeService.getAttributeCount();
+
+            Pager pager = new Pager( params.getPage(), total );
+            attributes.setPager( pager );
+
+            List<Attribute> attributeList = new ArrayList<Attribute>(
+                attributeService.getAttributesBetween( pager.getOffset(), pager.getPageSize() ) );
+
+            attributes.setAttributes( attributeList );
         }
         else
         {
-
+            attributes.setAttributes( new ArrayList<Attribute>( attributeService.getAllAttributes() ) );
         }
 
         if ( params.hasLinks() )