← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14877: Add paging and filter-by-name in the Program management form.

 

------------------------------------------------------------
revno: 14877
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-04-15 22:30:00 +0800
message:
  Add paging and filter-by-name in the Program management form.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/GetTrackedEntityListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.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/program/ProgramService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java	2014-04-15 14:30:00 +0000
@@ -179,12 +179,48 @@
      * @param organisationUnit {@link OrganisationUnit}
      */
     Collection<Program> getProgramsByCurrentUser( OrganisationUnit organisationUnit );
-    
+
     /**
-     * Get {@link Program} by TrackedEntity
+     * Get {@link TrackedEntity} by TrackedEntity
      * 
      * @param trackedEntity {@link TrackedEntity}
      */
     Collection<Program> getProgramsByTrackedEntity( TrackedEntity trackedEntity );
-    
+
+    /**
+     * Returns The number of Programs with the key searched
+     * 
+     * @param name Keyword for searching by name
+     * 
+     * @return A number
+     * 
+     */
+    Integer getProgramCountByName( String name );
+
+    /**
+     * Returns {@link Program} list with paging
+     * 
+     * @param name Keyword for searching by name
+     * @param min
+     * @param max
+     * @return a collection of all Program, or an empty collection if
+     *         there are no Program.
+     */
+    Collection<? extends Program> getProgramBetweenByName( String name, int min, int max );
+
+    /**
+     * Returns The number of all Program available
+     * 
+     */
+    Integer getProgramCount();
+
+    /**
+     * Returns {@link Program} list with paging
+     * 
+     * @param min
+     * @param max
+     * @return a collection of all Program, or an empty collection if
+     *         there are no Program.
+     */
+    Collection<Program> getProgramsBetween( int min, int max );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityService.java	2014-04-14 16:10:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityService.java	2014-04-15 14:30:00 +0000
@@ -121,7 +121,7 @@
      * @return a collection of all TrackedEntity, or an empty
      *         collection if there are no TrackedEntity.
      */
-    Collection<? extends TrackedEntity> getTrackedEntityBetweenByName( String name,
+    Collection<TrackedEntity> getTrackedEntityBetweenByName( String name,
         int min, int max );
 
     /**

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramService.java	2014-04-06 17:03:28 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramService.java	2014-04-15 14:30:00 +0000
@@ -180,4 +180,28 @@
     {
         return i18n( i18nService, programStore.getByTrackedEntity( trackedEntity ) );
     }
+
+    @Override
+    public Integer getProgramCountByName( String name )
+    {
+        return programStore.getCountLikeName( name );
+    }
+
+    @Override
+    public Collection<Program> getProgramBetweenByName( String name, int min, int max )
+    {
+        return programStore.getAllLikeNameOrderedName( name, min, max );
+    }
+
+    @Override
+    public Integer getProgramCount()
+    {
+        return programStore.getCount();
+    }
+
+    @Override
+    public Collection<Program> getProgramsBetween( int min, int max )
+    {
+        return programStore.getAllOrderedName( min, max );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityService.java	2014-04-14 16:10:45 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityService.java	2014-04-15 14:30:00 +0000
@@ -105,7 +105,7 @@
     }
 
     @Override
-    public Collection<? extends TrackedEntity> getTrackedEntityBetweenByName( String name, int min, int max )
+    public Collection<TrackedEntity> getTrackedEntityBetweenByName( String name, int min, int max )
     {
         return trackedEntityStore.getAllLikeNameOrderedName( name, min, max );
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramListAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramListAction.java	2014-04-15 14:30:00 +0000
@@ -28,25 +28,23 @@
  * 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.Collection;
 import java.util.Collections;
 import java.util.List;
 
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageService;
-
-import com.opensymphony.xwork2.Action;
 
 /**
  * @author Abyot Asalefew Gizaw
  * @version $Id$
  */
 public class GetProgramListAction
-    implements Action
+    extends ActionPagingSupport<Program>
 {
     // -------------------------------------------------------------------------
     // Dependencies
@@ -59,41 +57,10 @@
         this.programService = programService;
     }
 
-    private ProgramStageService programStageService;
-
-    public void setProgramStageService( ProgramStageService programStageService )
-    {
-        this.programStageService = programStageService;
-    }
-
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
-    private Integer id;
-
-    public Integer getId()
-    {
-        return id;
-    }
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    private Collection<ProgramStage> associations = new ArrayList<ProgramStage>();
-
-    public Collection<ProgramStage> getAssociations()
-    {
-        return associations;
-    }
-
-    public void setAssociations( Collection<ProgramStage> associations )
-    {
-        this.associations = associations;
-    }
-
     private List<Program> programs = new ArrayList<Program>();
 
     public List<Program> getPrograms()
@@ -101,9 +68,16 @@
         return programs;
     }
 
-    public void setPrograms( List<Program> programs )
-    {
-        this.programs = programs;
+    private String key;
+
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
     }
 
     // -------------------------------------------------------------------------
@@ -113,19 +87,22 @@
     public String execute()
         throws Exception
     {
-        programs = new ArrayList<Program>( programService.getAllPrograms() );
+        if ( isNotBlank( key ) )
+        {
+            this.paging = createPaging( programService.getProgramCountByName( key ) );
+
+            programs = new ArrayList<Program>( programService.getProgramBetweenByName( key, paging.getStartPos(),
+                paging.getPageSize() ) );
+        }
+        else
+        {
+            this.paging = createPaging( programService.getProgramCount() );
+
+            programs = new ArrayList<Program>( programService.getProgramsBetween( paging.getStartPos(),
+                paging.getPageSize() ) );
+        }
+
         Collections.sort( programs, IdentifiableObjectNameComparator.INSTANCE );
-        
-        if ( id == null )
-        {
-            associations = programStageService.getAllProgramStages();
-        }
-        else
-        {
-            Program program = programService.getProgram( id );
-
-            associations = program.getProgramStages();
-        }
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/GetTrackedEntityListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/GetTrackedEntityListAction.java	2014-04-14 16:10:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/GetTrackedEntityListAction.java	2014-04-15 14:30:00 +0000
@@ -46,7 +46,7 @@
  * @version $ AddTrackedEntityAction.java Feb 15, 2014 7:20:44 PM $
  */
 public class GetTrackedEntityListAction
-extends ActionPagingSupport<TrackedEntity>
+    extends ActionPagingSupport<TrackedEntity>
 {
     // -------------------------------------------------------------------------
     // Dependency
@@ -90,17 +90,15 @@
         {
             this.paging = createPaging( trackedEntityService.getTrackedEntityCountByName( key ) );
 
-            trackedEntities = new ArrayList<TrackedEntity>(
-                trackedEntityService.getTrackedEntityBetweenByName( key, paging.getStartPos(),
-                    paging.getPageSize() ) );
+            trackedEntities = new ArrayList<TrackedEntity>( trackedEntityService.getTrackedEntityBetweenByName( key,
+                paging.getStartPos(), paging.getPageSize() ) );
         }
         else
         {
             this.paging = createPaging( trackedEntityService.getTrackedEntityCount() );
 
-            trackedEntities = new ArrayList<TrackedEntity>(
-                trackedEntityService.getTrackedEntitysBetween( paging.getStartPos(),
-                    paging.getPageSize() ) );
+            trackedEntities = new ArrayList<TrackedEntity>( trackedEntityService.getTrackedEntitysBetween(
+                paging.getStartPos(), paging.getPageSize() ) );
         }
 
         Collections.sort( trackedEntities, IdentifiableObjectNameComparator.INSTANCE );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml	2014-03-24 09:02:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml	2014-04-15 14:30:00 +0000
@@ -186,7 +186,6 @@
 		class="org.hisp.dhis.trackedentity.action.program.GetProgramListAction"
 		scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
 	</bean>
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm	2014-02-26 15:09:48 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/programList.vm	2014-04-15 14:30:00 +0000
@@ -21,16 +21,22 @@
 
 <table class="mainPageTable">
   <tr>
-	  <td align="right">
-      <input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddProgramForm.action'" style="width:70px">
-    </td>
-  </tr>
-
-  <tr>
-    <td style="vertical-align:top">
+	 <td style="vertical-align:top">
+		<table width="100%">
+			<tr valign="bottom">
+				<td>
+					#filterDiv( "program" )
+				</td>
+				<td colspan="3" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddAttributeGroupForm.action'" style="width:70px"></td>				
+		
+				<td align="right">
+					<input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddProgramForm.action'" style="width:70px">
+				</td>
+			</tr>
+		</table>
 		
 		<table class="listTable" id="listTable">
-      <col>
+			<col>
 			<thead>
 			  <tr>            
 				<th>$i18n.getString( "name" )</th>
@@ -50,6 +56,7 @@
 
       </tbody>
       </table>
+		#parse( "/dhis-web-commons/paging/paging.vm" )
 		</td>
 
 		<td id="detailsData">