← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2273: Apply pagination in DataDictionary list.

 

------------------------------------------------------------
revno: 2273
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Fri 2010-12-03 19:31:32 +0700
message:
  Apply pagination in DataDictionary list.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datadictionary/DataDictionaryService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/datadictionary/GetDataDictionaryListAction.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/dataDictionary.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/datadictionary/DataDictionaryService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datadictionary/DataDictionaryService.java	2010-05-04 06:47:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datadictionary/DataDictionaryService.java	2010-12-03 12:31:32 +0000
@@ -30,6 +30,7 @@
 import java.util.Collection;
 
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
 
 /**
  * @author Lars Helge Overland
@@ -96,4 +97,12 @@
      * @return data elements with identifier in the given id.
      */
     Collection<DataElement> getDataElementsByDictionaryId( int dictionaryId );
+    
+    Collection<DataDictionary> getDataDictionarysBetween( int first, int max );
+    
+    Collection<DataDictionary> getDataDictionarysBetweenByName( String name, int first, int max );
+    
+    int getDataDictionaryCount();
+    
+    int getDataDictionaryCountByName( String name );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.java	2010-05-04 06:47:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.java	2010-12-03 12:31:32 +0000
@@ -110,4 +110,24 @@
     {
         return i18n( i18nService, dataDictionaryStore.get( dictionaryId ).getDataElements() );
     }
+
+    public int getDataDictionaryCount()
+    {
+        return dataDictionaryStore.getCount();
+    }
+
+    public int getDataDictionaryCountByName( String name )
+    {
+        return dataDictionaryStore.getCountByName( name );
+    }
+
+    public Collection<DataDictionary> getDataDictionarysBetween( int first, int max )
+    {
+        return i18n( i18nService, dataDictionaryStore.getBetween( first, max ) );
+    }
+
+    public Collection<DataDictionary> getDataDictionarysBetweenByName( String name, int first, int max )
+    {
+        return i18n( i18nService, dataDictionaryStore.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/datadictionary/GetDataDictionaryListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/datadictionary/GetDataDictionaryListAction.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/datadictionary/GetDataDictionaryListAction.java	2010-12-03 12:31:32 +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,9 @@
 import org.hisp.dhis.datadictionary.DataDictionary;
 import org.hisp.dhis.datadictionary.DataDictionaryService;
 import org.hisp.dhis.datadictionary.comparator.DataDictionaryNameComparator;
+import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.paging.ActionPagingSupport;
 
 import com.opensymphony.xwork2.Action;
 
@@ -42,7 +47,7 @@
  * @version $Id$
  */
 public class GetDataDictionaryListAction
-    implements Action
+    extends ActionPagingSupport<IndicatorGroup>
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -56,7 +61,7 @@
     }
 
     // -------------------------------------------------------------------------
-    // Output
+    // Input & Output
     // -------------------------------------------------------------------------
 
     private List<DataDictionary> dataDictionaries;
@@ -64,7 +69,20 @@
     public List<DataDictionary> getDataDictionaries()
     {
         return dataDictionaries;
-    }    
+    }  
+    
+    private String key;
+    
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -72,7 +90,18 @@
 
     public String execute()
     {
-        dataDictionaries = new ArrayList<DataDictionary>( dataDictionaryService.getAllDataDictionaries() );
+        if ( isNotBlank( key ) ) // Filter on key only if set
+        {
+            this.paging = createPaging( dataDictionaryService.getDataDictionaryCountByName( key ) );
+            
+            dataDictionaries = new ArrayList<DataDictionary>( dataDictionaryService.getDataDictionarysBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+        }
+        else
+        {
+            this.paging = createPaging( dataDictionaryService.getDataDictionaryCount() );
+            
+            dataDictionaries = new ArrayList<DataDictionary>( dataDictionaryService.getDataDictionarysBetween( paging.getStartPos(), paging.getPageSize() ) );
+        }
         
         Collections.sort( dataDictionaries, new DataDictionaryNameComparator() );        
         

=== 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 18:13:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml	2010-12-03 12:31:32 +0000
@@ -681,6 +681,7 @@
 			<param name="page">/dhis-web-maintenance-datadictionary/dataDictionary.vm</param>
 			<param name="menu">/dhis-web-maintenance-datadictionary/menu.vm</param>
 			<param name="javascripts">javascript/dataDictionary.js</param>
+			<param name="stylesheets">../dhis-web-commons/paging/paging.css</param>	
 		</action>
 
 		<action name="getDataDictionary"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataDictionary.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataDictionary.vm	2010-12-03 05:41:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataDictionary.vm	2010-12-03 12:31:32 +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( "dataDictionary" )</td>
 					<td colspan="3" style="text-align:right"><input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddDataDictionaryForm.action'" style="width:80px"/></td>
 				</tr>
 			</table>
@@ -31,6 +31,8 @@
 				#end
 				</tbody>
 			</table>
+			<p></p>
+			#parse( "/dhis-web-commons/paging/paging.vm" )
 
 		</td>
 		<td style="width:20em; padding-left:2em; vertical-align:top">