← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2261: Apply pagination in IndicatorType.

 

------------------------------------------------------------
revno: 2261
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Fri 2010-12-03 00:41:00 +0700
message:
  Apply pagination in IndicatorType.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatortype/GetIndicatorTypeListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorType.vm


--
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/indicator/IndicatorService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java	2010-11-27 07:46:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java	2010-12-02 17:41:00 +0000
@@ -29,6 +29,8 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.dataelement.DataElementGroupSet;
+
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -91,6 +93,14 @@
 
     IndicatorType getIndicatorTypeByName( String name );
 
+    Collection<IndicatorType> getIndicatorTypesBetween( int first, int max );
+    
+    Collection<IndicatorType> getIndicatorTypesBetweenByName( String name, int first, int max );
+    
+    int getIndicatorTypeCount();
+    
+    int getIndicatorTypeCountByName( String name );
+
     // -------------------------------------------------------------------------
     // IndicatorGroup
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java	2010-11-27 07:46:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java	2010-12-02 17:41:00 +0000
@@ -251,6 +251,26 @@
         return i18n( i18nService, indicatorTypeStore.getByName( name ) );
     }    
 
+    public int getIndicatorTypeCount()
+    {
+        return indicatorTypeStore.getCount();
+    }
+
+    public int getIndicatorTypeCountByName( String name )
+    {
+        return indicatorTypeStore.getCountByName( name );
+    }
+
+    public Collection<IndicatorType> getIndicatorTypesBetween( int first, int max )
+    {
+        return i18n( i18nService, indicatorTypeStore.getBetween( first, max ) );
+    }
+
+    public Collection<IndicatorType> getIndicatorTypesBetweenByName( String name, int first, int max )
+    {
+        return i18n( i18nService, indicatorTypeStore.getBetweenByName( name, first, max ) );
+    }
+
     // -------------------------------------------------------------------------
     // IndicatorGroup
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatortype/GetIndicatorTypeListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatortype/GetIndicatorTypeListAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatortype/GetIndicatorTypeListAction.java	2010-12-02 17:41:00 +0000
@@ -27,13 +27,17 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.hisp.dhis.dataelement.DataElementGroupSet;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.indicator.IndicatorType;
 import org.hisp.dhis.indicator.comparator.IndicatorTypeNameComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
 
 import com.opensymphony.xwork2.ActionSupport;
 
@@ -42,7 +46,7 @@
  * @version $Id: GetIndicatorTypeListAction.java 3305 2007-05-14 18:55:52Z larshelg $
  */
 public class GetIndicatorTypeListAction
-    extends ActionSupport
+extends ActionPagingSupport<IndicatorType>
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -56,7 +60,7 @@
     }
     
     // -------------------------------------------------------------------------
-    // Output
+    // Input & Output
     // -------------------------------------------------------------------------
 
     private List<IndicatorType> indicatorTypes;
@@ -65,6 +69,18 @@
     {
         return indicatorTypes;
     }
+    
+    private String key;
+    
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
 
     // -------------------------------------------------------------------------
     // Action implemantation
@@ -72,7 +88,18 @@
 
     public String execute()
     {
-        indicatorTypes = new ArrayList<IndicatorType>( indicatorService.getAllIndicatorTypes() );
+        if ( isNotBlank( key ) ) // Filter on key only if set
+        {
+            this.paging = createPaging( indicatorService.getIndicatorTypeCountByName( key ) );
+            
+            indicatorTypes = new ArrayList<IndicatorType>( indicatorService.getIndicatorTypesBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+        }
+        else
+        {
+            this.paging = createPaging( indicatorService.getIndicatorTypeCount() );
+            
+            indicatorTypes = new ArrayList<IndicatorType>( indicatorService.getIndicatorTypesBetween( paging.getStartPos(), paging.getPageSize() ) );
+        }
 
         Collections.sort( indicatorTypes, new IndicatorTypeNameComparator() );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml	2010-12-01 18:00:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml	2010-12-02 17:41:00 +0000
@@ -605,7 +605,8 @@
 			class="org.hisp.dhis.dd.action.indicatortype.GetIndicatorTypeListAction">
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">/dhis-web-maintenance-datadictionary/indicatorType.vm</param>
-			<param name="menu">/dhis-web-maintenance-datadictionary/menu.vm</param>			
+			<param name="menu">/dhis-web-maintenance-datadictionary/menu.vm</param>		
+			<param name="stylesheets">../dhis-web-commons/paging/paging.css</param>	
 		</action>
 
 		<action name="getIndicatorType"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorType.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorType.vm	2010-09-21 06:16:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorType.vm	2010-12-02 17:41:00 +0000
@@ -5,7 +5,7 @@
 		<td style="vertical-align:top">
 			<table width="100%">
 				<tr>
-					<td>$i18n.getString( "filter_by_name" ): <form style="display:inline" action="none" onsubmit="return false"><div style="inline"><input type="text" onkeyup="filterValues( this.value )"></div></form></td>
+					<td>#filterDiv( "indicatorType" )</td>
 					<td colspan="4" style="text-align:right"><input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddIndicatorTypeForm.action'" style="width:80px"></td>
 				</tr>
 			</table>
@@ -33,6 +33,8 @@
 				#end
 				</tbody>
 			</table>
+			<p></p>
+			#parse( "/dhis-web-commons/paging/paging.vm" )
 
 		</td>
 		<td style="width:20em; padding-left:2em; vertical-align:top">