dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31485
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16047: disable paging if we are filtering programs by type, orgUnit or userFilter
------------------------------------------------------------
revno: 16047
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-07-09 15:35:03 +0700
message:
disable paging if we are filtering programs by type, orgUnit or userFilter
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java
--
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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java 2014-07-09 07:17:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java 2014-07-09 08:35:03 +0000
@@ -52,7 +52,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping(value = ProgramSchemaDescriptor.API_ENDPOINT)
+@RequestMapping( value = ProgramSchemaDescriptor.API_ENDPOINT )
public class ProgramController
extends AbstractCrudController<Program>
{
@@ -79,8 +79,17 @@
protected List<Program> getEntityList( WebMetaData metaData, WebOptions options )
{
+ String type = options.getOptions().get( "type" );
+ String orgUnit = options.getOptions().get( "orgUnit" );
+ Boolean userFilter = Boolean.parseBoolean( options.getOptions().get( "userFilter" ) );
+
List<Program> entityList;
+ if ( type != null || orgUnit != null || userFilter )
+ {
+ options.getOptions().put( "paging", "false" );
+ }
+
if ( options.getOptions().containsKey( "query" ) )
{
entityList = Lists.newArrayList( manager.filter( getEntityClass(), options.getOptions().get( "query" ) ) );
@@ -92,17 +101,13 @@
Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
metaData.setPager( pager );
- entityList = new ArrayList<Program>( manager.getBetween( getEntityClass(), pager.getOffset(), pager.getPageSize() ) );
+ entityList = new ArrayList<>( manager.getBetween( getEntityClass(), pager.getOffset(), pager.getPageSize() ) );
}
else
{
- entityList = new ArrayList<Program>( manager.getAllSorted( getEntityClass() ) );
+ entityList = new ArrayList<>( manager.getAllSorted( getEntityClass() ) );
}
- String type = options.getOptions().get( "type" );
- String orgUnit = options.getOptions().get( "orgUnit" );
- Boolean userFilter = Boolean.parseBoolean( options.getOptions().get( "userFilter" ) );
-
if ( userFilter )
{
List<Program> programs = Lists.newArrayList( programService.getProgramsByCurrentUser() );