dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09150
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2363: Apply pagination in reporttable and chart list.
------------------------------------------------------------
revno: 2363
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Mon 2010-12-13 23:32:50 +0700
message:
Apply pagination in reporttable and chart list.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetAllChartsAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetAllTablesAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewChartForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.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/chart/ChartStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartStore.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartStore.java 2010-12-13 16:32:50 +0000
@@ -27,6 +27,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Collection;
+
import org.hisp.dhis.common.GenericStore;
/**
@@ -45,4 +47,13 @@
* @return the Chart.
*/
Chart getByTitle( String title );
+
+ Collection<Chart> getChartsBetween( int first, int max );
+
+ Collection<Chart> getChartsBetweenByName( String name, int first, int max );
+
+ int getChartCount();
+
+ int getChartCountByName( String name );
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2010-11-29 17:23:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2010-12-13 16:32:50 +0000
@@ -30,6 +30,7 @@
import java.util.Collection;
import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
/**
* @author Lars Helge Overland
@@ -142,4 +143,12 @@
* @return true if the report table has been generated, false it not.
*/
boolean reportTableIsGenerated( int id );
+
+ Collection<ReportTable> getReportTablesBetween( int first, int max );
+
+ Collection<ReportTable> getReportTablesBetweenByName( String name, int first, int max );
+
+ int getReportTableCount();
+
+ int getReportTableCountByName( String name );
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartService.java 2010-07-28 13:44:59 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartService.java 2010-12-13 16:32:50 +0000
@@ -33,6 +33,7 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -73,4 +74,13 @@
Chart getChartByTitle( String name );
Collection<Chart> getCharts( final Collection<Integer> identifiers );
+
+ Collection<Chart> getChartsBetween( int first, int max );
+
+ Collection<Chart> getChartsBetweenByName( String name, int first, int max );
+
+ int getChartCount();
+
+ int getChartCountByName( String name );
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/hibernate/HibernateChartStore.java 2010-12-13 16:32:50 +0000
@@ -27,6 +27,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Collection;
+
+import org.hibernate.Criteria;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartStore;
@@ -43,4 +48,35 @@
{
return getObject( Restrictions.eq( "title", title ) );
}
+
+ public int getChartCount()
+ {
+ return getCount();
+ }
+
+ public Collection<Chart> getChartsBetween( int first, int max )
+ {
+ Criteria criteria = getCriteria();
+ criteria.addOrder( Order.asc( "title" ) );
+ criteria.setFirstResult( first );
+ criteria.setMaxResults( max );
+ return criteria.list();
+ }
+ public Collection<Chart> getChartsBetweenByName( String name, int first, int max )
+ {
+ Criteria criteria = getCriteria();
+ criteria.add( Restrictions.ilike( "title", "%" + name + "%" ) );
+ criteria.addOrder( Order.asc( "title" ) );
+ criteria.setFirstResult( first );
+ criteria.setMaxResults( max );
+ return criteria.list();
+ }
+
+ public int getChartCountByName( String name )
+ {
+ Criteria criteria = getCriteria();
+ criteria.setProjection( Projections.rowCount() );
+ criteria.add( Restrictions.ilike( "title", "%" + name + "%" ) );
+ return ((Number) criteria.uniqueResult()).intValue();
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2010-12-05 19:09:58 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2010-12-13 16:32:50 +0000
@@ -640,4 +640,23 @@
} );
}
+ public int getChartCount()
+ {
+ return chartStore.getChartCount();
+ }
+
+ public int getChartCountByName( String name )
+ {
+ return chartStore.getChartCountByName( name );
+ }
+
+ public Collection<Chart> getChartsBetween( int first, int max )
+ {
+ return chartStore.getChartsBetween( first, max );
+ }
+
+ public Collection<Chart> getChartsBetweenByName( String name, int first, int max )
+ {
+ return chartStore.getChartsBetweenByName( name, first, max );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2010-12-11 19:53:11 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2010-12-13 16:32:50 +0000
@@ -558,4 +558,24 @@
return reportTables;
}
+
+ public Collection<ReportTable> getReportTablesBetweenByName( String name, int first, int max )
+ {
+ return reportTableStore.getBetweenByName( name, first, max );
+ }
+
+ public int getReportTableCount()
+ {
+ return reportTableStore.getCount();
+ }
+
+ public int getReportTableCountByName( String name )
+ {
+ return reportTableStore.getCountByName( name );
+ }
+
+ public Collection<ReportTable> getReportTablesBetween( int first, int max )
+ {
+ return reportTableStore.getBetween( first, max );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetAllChartsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetAllChartsAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/GetAllChartsAction.java 2010-12-13 16:32:50 +0000
@@ -27,6 +27,8 @@
* 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;
@@ -34,6 +36,8 @@
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.chart.comparator.ChartTitleComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.reporttable.ReportTable;
import com.opensymphony.xwork2.Action;
@@ -42,7 +46,7 @@
* @version $Id$
*/
public class GetAllChartsAction
- implements Action
+ extends ActionPagingSupport<Chart>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -56,8 +60,20 @@
}
// -------------------------------------------------------------------------
- // Output
+ // Input & Output
// -------------------------------------------------------------------------
+
+ private String key;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
private List<Chart> charts;
@@ -72,7 +88,18 @@
public String execute()
{
- charts = new ArrayList<Chart>( chartService.getAllCharts() );
+ if ( isNotBlank( key ) )
+ {
+ this.paging = createPaging( chartService.getChartCountByName( key ) );
+
+ charts = new ArrayList<Chart>( chartService.getChartsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+ }
+ else
+ {
+ this.paging = createPaging( chartService.getChartCount() );
+
+ charts = new ArrayList<Chart>( chartService.getChartsBetween( paging.getStartPos(), paging.getPageSize() ) );
+ }
Collections.sort( charts, new ChartTitleComparator() );
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetAllTablesAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetAllTablesAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetAllTablesAction.java 2010-12-13 16:32:50 +0000
@@ -27,22 +27,24 @@
* 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.document.Document;
+import org.hisp.dhis.paging.ActionPagingSupport;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.reporttable.ReportTableService;
import org.hisp.dhis.reporttable.comparator.ReportTableComparator;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Lars Helge Overland
* @version $Id$
*/
public class GetAllTablesAction
- implements Action
+ extends ActionPagingSupport<ReportTable>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -56,8 +58,20 @@
}
// -------------------------------------------------------------------------
- // Output
+ // Input & Output
// -------------------------------------------------------------------------
+
+ private String key;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
private List<ReportTable> tables;
@@ -72,7 +86,18 @@
public String execute()
{
- tables = new ArrayList<ReportTable>( reportTableService.getAllReportTables() );
+ if ( isNotBlank( key ) )
+ {
+ this.paging = createPaging( reportTableService.getReportTableCountByName( key ) );
+
+ tables = new ArrayList<ReportTable>( reportTableService.getReportTablesBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+ }
+ else
+ {
+ this.paging = createPaging( reportTableService.getReportTableCount() );
+
+ tables = new ArrayList<ReportTable>( reportTableService.getReportTablesBetween( paging.getStartPos(), paging.getPageSize() ) );
+ }
Collections.sort( tables, new ReportTableComparator() );
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2010-12-13 15:18:59 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2010-12-13 16:32:50 +0000
@@ -85,6 +85,7 @@
<param name="page">/dhis-web-reporting/viewChartForm.vm</param>
<param name="menu">/dhis-web-reporting/menu.vm</param>
<param name="javascripts">javascript/chart.js</param>
+ <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
</action>
<action name="viewChart" class="org.hisp.dhis.reporting.chart.action.ViewChartAction">
@@ -184,6 +185,7 @@
<param name="page">/dhis-web-reporting/viewTableForm.vm</param>
<param name="menu">/dhis-web-reporting/menu.vm</param>
<param name="javascripts">javascript/table.js</param>
+ <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
</action>
<action name="removeTable" class="org.hisp.dhis.reporting.tablecreator.action.RemoveTableAction">
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewChartForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewChartForm.vm 2010-12-03 05:41:34 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewChartForm.vm 2010-12-13 16:32:50 +0000
@@ -5,6 +5,7 @@
<td style="vertical-align:top">
<table width="100%">
<tr>
+ <td>#filterDiv( "displayViewChartForm" )</td>
<td align="right">
<input type="button" value="$i18n.getString( 'add_period_chart' )" style="width:200px" onclick="window.location.href='displayAddChartForm.action?dimension=period'"><br>
<input type="button" value="$i18n.getString( 'add_organisation_unit_chart' )" style="width:200px" onclick="window.location.href='displayAddChartForm.action?dimension=organisationUnit'"><br>
@@ -35,6 +36,8 @@
#end
</tbody>
</table>
+ <p></p>
+ #parse( "/dhis-web-commons/paging/paging.vm" )
</td>
<td style="width:20em; padding-left:2em; vertical-align:top">
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm 2010-12-03 05:41:34 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm 2010-12-13 16:32:50 +0000
@@ -6,6 +6,7 @@
<td style="vertical-align:top">
<table width="100%">
<tr>
+ <td>#filterDiv( "displayManageTableForm" )</td>
<td colspan="10" style="text-align:right">
<input type="button" value="$i18n.getString( 'add_indicator_table' )" style="width:250px" onclick="window.location.href='displayAddTableForm.action?mode=indicators'"><br>
<input type="button" value="$i18n.getString( 'add_dataelement_table' )" style="width:250px" onclick="window.location.href='displayAddTableForm.action?mode=dataelements'"><br>
@@ -42,6 +43,8 @@
#end
</tbody>
</table>
+ <p></p>
+ #parse( "/dhis-web-commons/paging/paging.vm" )
</td>
<td style="width:20em; padding-left:2em; vertical-align:top">