dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08938
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2262: Apply pagination in IndicatorGroup.
------------------------------------------------------------
revno: 2262
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Fri 2010-12-03 00:54:22 +0700
message:
Apply pagination in IndicatorGroup.
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/indicatorgroup/GetIndicatorGroupListAction.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/indicatorGroup.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:41:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2010-12-02 17:54:22 +0000
@@ -123,6 +123,14 @@
Collection<IndicatorGroup> getGroupsContainingIndicator( Indicator indicator );
+ Collection<IndicatorGroup> getIndicatorGroupsBetween( int first, int max );
+
+ Collection<IndicatorGroup> getIndicatorGroupsBetweenByName( String name, int first, int max );
+
+ int getIndicatorGroupCount();
+
+ int getIndicatorGroupCountByName( String name );
+
// -------------------------------------------------------------------------
// IndicatorGroupSet
// -------------------------------------------------------------------------
=== 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:41:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2010-12-02 17:54:22 +0000
@@ -355,6 +355,26 @@
return groups;
}
+ public int getIndicatorGroupCount()
+ {
+ return indicatorGroupStore.getCount();
+ }
+
+ public int getIndicatorGroupCountByName( String name )
+ {
+ return indicatorGroupStore.getCountByName( name );
+ }
+
+ public Collection<IndicatorGroup> getIndicatorGroupsBetween( int first, int max )
+ {
+ return i18n( i18nService, indicatorGroupStore.getBetween( first, max ) );
+ }
+
+ public Collection<IndicatorGroup> getIndicatorGroupsBetweenByName( String name, int first, int max )
+ {
+ return i18n( i18nService, indicatorGroupStore.getBetweenByName( name, first, max ) );
+ }
+
// -------------------------------------------------------------------------
// IndicatorGroupSet
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroup/GetIndicatorGroupListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroup/GetIndicatorGroupListAction.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/indicatorgroup/GetIndicatorGroupListAction.java 2010-12-02 17:54:22 +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.IndicatorService;
+import org.hisp.dhis.indicator.IndicatorType;
import org.hisp.dhis.indicator.comparator.IndicatorGroupNameComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
import com.opensymphony.xwork2.ActionSupport;
@@ -42,7 +46,7 @@
* @version $Id: GetIndicatorGroupListAction.java 3305 2007-05-14 18:55:52Z larshelg $
*/
public class GetIndicatorGroupListAction
- extends ActionSupport
+ extends ActionPagingSupport<IndicatorGroup>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -56,7 +60,7 @@
}
// -------------------------------------------------------------------------
- // Output
+ // Input & Output
// -------------------------------------------------------------------------
private List<IndicatorGroup> indicatorGroups;
@@ -65,6 +69,18 @@
{
return indicatorGroups;
}
+
+ 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()
{
- indicatorGroups = new ArrayList<IndicatorGroup>( indicatorService.getAllIndicatorGroups() );
+ if ( isNotBlank( key ) ) // Filter on key only if set
+ {
+ this.paging = createPaging( indicatorService.getIndicatorGroupCountByName( key ) );
+
+ indicatorGroups = new ArrayList<IndicatorGroup>( indicatorService.getIndicatorGroupsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+ }
+ else
+ {
+ this.paging = createPaging( indicatorService.getIndicatorGroupCount() );
+
+ indicatorGroups = new ArrayList<IndicatorGroup>( indicatorService.getIndicatorGroupsBetween( paging.getStartPos(), paging.getPageSize() ) );
+ }
Collections.sort( indicatorGroups, new IndicatorGroupNameComparator() );
=== 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:41:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml 2010-12-02 17:54:22 +0000
@@ -481,6 +481,7 @@
<param name="page">/dhis-web-maintenance-datadictionary/indicatorGroup.vm</param>
<param name="menu">/dhis-web-maintenance-datadictionary/menu.vm</param>
<param name="javascripts">javascript/indicatorGroup.js</param>
+ <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
</action>
<action name="removeIndicatorGroup"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorGroup.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorGroup.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/indicatorGroup.vm 2010-12-02 17:54:22 +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( "indicatorGroup" )</td>
<td colspan="4" style="text-align:right"><input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddIndicatorGroupForm.action'" style="width:80px"/></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">