dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08939
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2263: Apply pagination in IndicatorGroupSet.
------------------------------------------------------------
revno: 2263
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Fri 2010-12-03 01:13:14 +0700
message:
Apply pagination in IndicatorGroupSet.
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/indicatorgroupset/ListIndicatorGroupSetAction.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/indicatorGroupSet.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-12-02 17:54:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2010-12-02 18:13:14 +0000
@@ -148,4 +148,12 @@
Collection<IndicatorGroupSet> getAllIndicatorGroupSets();
Collection<IndicatorGroupSet> getIndicatorGroupSets( Collection<Integer> identifiers );
+
+ Collection<IndicatorGroupSet> getIndicatorGroupSetsBetween( int first, int max );
+
+ Collection<IndicatorGroupSet> getIndicatorGroupSetsBetweenByName( String name, int first, int max );
+
+ int getIndicatorGroupSetCount();
+
+ int getIndicatorGroupSetCountByName( String name );
}
=== 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-12-02 17:54:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2010-12-02 18:13:14 +0000
@@ -430,4 +430,24 @@
} );
}
+ public int getIndicatorGroupSetCountByName( String name )
+ {
+ return indicatorGroupSetStore.getCountByName( name );
+ }
+
+ public int getIndicatorGroupSetCount()
+ {
+ return indicatorGroupSetStore.getCount();
+ }
+
+ public Collection<IndicatorGroupSet> getIndicatorGroupSetsBetween( int first, int max )
+ {
+ return i18n( i18nService, indicatorGroupSetStore.getBetween( first, max ) );
+ }
+
+ public Collection<IndicatorGroupSet> getIndicatorGroupSetsBetweenByName( String name, int first, int max )
+ {
+ return i18n( i18nService, indicatorGroupSetStore.getBetweenByName( name, first, max ) );
+ }
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroupset/ListIndicatorGroupSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroupset/ListIndicatorGroupSetAction.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/indicatorgroupset/ListIndicatorGroupSetAction.java 2010-12-02 18:13:14 +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.indicator.IndicatorGroup;
import org.hisp.dhis.indicator.IndicatorGroupSet;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.comparator.IndicatorGroupSetNameComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
import com.opensymphony.xwork2.Action;
@@ -42,7 +46,7 @@
* @version $Id$
*/
public class ListIndicatorGroupSetAction
- implements Action
+ extends ActionPagingSupport<IndicatorGroup>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -56,7 +60,7 @@
}
// -------------------------------------------------------------------------
- // Output
+ // Input & Output
// -------------------------------------------------------------------------
private List<IndicatorGroupSet> indicatorGroupSets;
@@ -65,6 +69,18 @@
{
return indicatorGroupSets;
}
+
+ private String key;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -73,8 +89,19 @@
public String execute()
throws Exception
{
- indicatorGroupSets = new ArrayList<IndicatorGroupSet>( indicatorService.getAllIndicatorGroupSets() );
-
+ if ( isNotBlank( key ) ) // Filter on key only if set
+ {
+ this.paging = createPaging( indicatorService.getIndicatorGroupSetCountByName( key ) );
+
+ indicatorGroupSets = new ArrayList<IndicatorGroupSet>( indicatorService.getIndicatorGroupSetsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+ }
+ else
+ {
+ this.paging = createPaging( indicatorService.getIndicatorGroupSetCount() );
+
+ indicatorGroupSets = new ArrayList<IndicatorGroupSet>( indicatorService.getIndicatorGroupSetsBetween( paging.getStartPos(), paging.getPageSize() ) );
+ }
+
Collections.sort( indicatorGroupSets, new IndicatorGroupSetNameComparator() );
return SUCCESS;
=== 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-02 17:54:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml 2010-12-02 18:13:14 +0000
@@ -548,6 +548,7 @@
<param name="page">/dhis-web-maintenance-datadictionary/indicatorGroupSet.vm</param>
<param name="menu">/dhis-web-maintenance-datadictionary/menu.vm</param>
<param name="javascripts">javascript/indicatorGroupSet.js</param>
+ <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
</action>
<action name="openAddIndicatorGroupSet"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorGroupSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorGroupSet.vm 2010-11-20 08:23:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorGroupSet.vm 2010-12-02 18:13:14 +0000
@@ -6,7 +6,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( "indicatorGroupSet" )</td>
<td colspan="4" style="text-align:right"><input type=button value="$i18n.getString( 'add_new' )" onclick="window.location='openAddIndicatorGroupSet.action'"/></td>
</tr>
<table>
@@ -34,6 +34,8 @@
#end
</tbody>
</table>
+ <p></p>
+ #parse( "/dhis-web-commons/paging/paging.vm" )
</td>
<td style="width:20em; padding-left:2em; vertical-align:top">