dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08771
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2194: Implement pagination in DataSet list.
------------------------------------------------------------
revno: 2194
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Sat 2010-11-27 16:37:29 +0700
message:
Implement pagination in DataSet list.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DataSetListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/dataSetList.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/dataset/DataSetService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java 2010-11-01 06:32:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java 2010-11-27 09:37:29 +0000
@@ -256,4 +256,12 @@
*/
Collection<FrequencyOverrideAssociation> getFrequencyOverrideAssociationsBySource( Source source );
+ int getDataSetCountByName( String name );
+
+ Collection<DataSet> getDataSetsBetweenByName( String name, int first, int max );
+
+ int getDataSetCount();
+
+ Collection<DataSet> getDataSetsBetween(int first, int max );
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java 2010-11-01 06:32:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetStore.java 2010-11-27 09:37:29 +0000
@@ -178,4 +178,13 @@
* Source.
*/
Collection<FrequencyOverrideAssociation> getFrequencyOverrideAssociationsBySource( Source source );
+
+ int getDataSetCountByName( String name );
+
+ Collection<DataSet> getDataSetsBetweenByName( String name, int first, int max );
+
+ int getDataSetCount();
+
+ Collection<DataSet> getDataSetsBetween(int first, int max );
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2010-11-01 06:32:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2010-11-27 09:37:29 +0000
@@ -313,4 +313,28 @@
{
return dataSetStore.getFrequencyOverrideAssociationsBySource( source );
}
+
+ @Override
+ public int getDataSetCount()
+ {
+ return dataSetStore.getDataSetCount();
+ }
+
+ @Override
+ public int getDataSetCountByName( String name )
+ {
+ return dataSetStore.getDataSetCountByName( name );
+ }
+
+ @Override
+ public Collection<DataSet> getDataSetsBetween( int first, int max )
+ {
+ return dataSetStore.getDataSetsBetween( first, max );
+ }
+
+ @Override
+ public Collection<DataSet> getDataSetsBetweenByName( String name, int first, int max )
+ {
+ return dataSetStore.getDataSetsBetweenByName( name, first, max );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2010-11-10 13:49:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateDataSetStore.java 2010-11-27 09:37:29 +0000
@@ -32,11 +32,11 @@
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
-import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetStore;
import org.hisp.dhis.dataset.FrequencyOverrideAssociation;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
import org.hisp.dhis.period.PeriodStore;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.source.Source;
@@ -47,19 +47,12 @@
* @version $Id: HibernateDataSetStore.java 3303 2007-05-14 13:39:34Z larshelg $
*/
public class HibernateDataSetStore
- implements DataSetStore
+ extends HibernateGenericStore<DataSet> implements DataSetStore
{
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
- private SessionFactory sessionFactory;
-
- public void setSessionFactory( SessionFactory sessionFactory )
- {
- this.sessionFactory = sessionFactory;
- }
-
private PeriodStore periodStore;
public void setPeriodStore( PeriodStore periodStore )
@@ -257,5 +250,29 @@
return criteria.list();
}
+
+ @Override
+ public int getDataSetCount()
+ {
+ return getCount();
+ }
+
+ @Override
+ public int getDataSetCountByName( String name )
+ {
+ return getCountByName( name );
+ }
+
+ @Override
+ public Collection<DataSet> getDataSetsBetween( int first, int max )
+ {
+ return getBetween( first, max );
+ }
+
+ @Override
+ public Collection<DataSet> getDataSetsBetweenByName( String name, int first, int max )
+ {
+ return getBetweenByName( name, first, max );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2010-11-27 07:46:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2010-11-27 09:37:29 +0000
@@ -85,6 +85,7 @@
</bean>
<bean id="org.hisp.dhis.dataset.DataSetStore" class="org.hisp.dhis.dataset.hibernate.HibernateDataSetStore">
+ <property name="clazz" value="org.hisp.dhis.dataset.DataSet" />
<property name="sessionFactory" ref="sessionFactory"/>
<property name="periodStore" ref="org.hisp.dhis.period.PeriodStore" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DataSetListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DataSetListAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DataSetListAction.java 2010-11-27 09:37:29 +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.Comparator;
@@ -35,15 +37,14 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.paging.ActionPagingSupport;
/**
* @author Kristian
* @version $Id: DataSetListAction.java 6256 2008-11-10 17:10:30Z larshelg $
*/
public class DataSetListAction
- implements Action
+ extends ActionPagingSupport<DataSet>
{
private List<DataSet> dataSets;
@@ -80,7 +81,23 @@
{
return dataSets;
}
-
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private String key;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
+
// -------------------------------------------------------------------------
// Execute
// -------------------------------------------------------------------------
@@ -88,7 +105,18 @@
public String execute()
throws Exception
{
- dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
+ if ( isNotBlank( key ) ) // Filter on key only if set
+ {
+ this.paging = createPaging( dataSetService.getDataSetCountByName( key ) );
+
+ dataSets = new ArrayList<DataSet>( dataSetService.getDataSetsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+ }
+ else
+ {
+ this.paging = createPaging( dataSetService.getDataSetCount() );
+
+ dataSets = new ArrayList<DataSet>( dataSetService.getDataSetsBetween( paging.getStartPos(), paging.getPageSize() ) );
+ }
Collections.sort( dataSets, dataSetComparator );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml 2010-11-20 08:23:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml 2010-11-27 09:37:29 +0000
@@ -31,6 +31,7 @@
<param name="page">/dhis-web-maintenance-dataset/dataSetList.vm</param>
<param name="menu">/dhis-web-maintenance-dataset/menu.vm</param>
<param name="javascripts">javascript/dataSet.js</param>
+ <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
</action>
<!-- Section -->
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/dataSetList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/dataSetList.vm 2010-09-21 06:16:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/dataSetList.vm 2010-11-27 09:37:29 +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( "dataSet" )</td>
<td colspan="9" style="text-align:right">
<input type="button" value="$i18n.getString( 'sort' )" onclick="window.location.href='showSortDataSetForm.action'" style="width:80px"/></a>
<input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='addDataSetForm.action'" style="width:80px"/></a>
@@ -64,6 +64,9 @@
</tbody>
</table>
+ <p></p>
+ #parse( "/dhis-web-commons/paging/paging.vm" )
+
</td>
<td style="width:20em; padding-left:2em; vertical-align:top">