dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26885
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13312: add ?program=uid parameter to programStage controller
------------------------------------------------------------
revno: 13312
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-12-18 17:18:37 +0100
message:
add ?program=uid parameter to programStage controller
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramStageController.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-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2013-12-18 15:28:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2013-12-18 16:18:37 +0000
@@ -615,7 +615,7 @@
{
return true;
}
-
+
int months = DateUtils.monthsBetween( credentials.getPasswordLastUpdated(), new Date() );
return months < credentialsExpires;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramStageController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramStageController.java 2013-08-23 16:00:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramStageController.java 2013-12-18 16:18:37 +0000
@@ -29,17 +29,73 @@
*/
import org.hisp.dhis.api.controller.AbstractCrudController;
+import org.hisp.dhis.api.controller.WebMetaData;
+import org.hisp.dhis.api.controller.WebOptions;
+import org.hisp.dhis.common.Pager;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStage;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = ProgramStageController.RESOURCE_PATH )
+@RequestMapping(value = ProgramStageController.RESOURCE_PATH)
public class ProgramStageController
extends AbstractCrudController<ProgramStage>
{
public static final String RESOURCE_PATH = "/programStages";
+
+ private ProgramService programService;
+
+ @Autowired
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
+ @Override
+ protected List<ProgramStage> getEntityList( WebMetaData metaData, WebOptions options )
+ {
+ List<ProgramStage> entityList = new ArrayList<ProgramStage>();
+
+ Date lastUpdated = options.getLastUpdated();
+
+ if ( lastUpdated != null )
+ {
+ entityList = new ArrayList<ProgramStage>( manager.getByLastUpdatedSorted( getEntityClass(), lastUpdated ) );
+ }
+ else if ( options.hasPaging() )
+ {
+ int count = manager.getCount( getEntityClass() );
+
+ Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
+ metaData.setPager( pager );
+
+ entityList = new ArrayList<ProgramStage>( manager.getBetween( getEntityClass(), pager.getOffset(), pager.getPageSize() ) );
+ }
+ else if ( options.getOptions().containsKey( "program" ) )
+ {
+ String programId = options.getOptions().get( "program" );
+ Program program = programService.getProgram( programId );
+
+ if ( program != null )
+ {
+ entityList = new ArrayList<ProgramStage>( program.getProgramStages() );
+ }
+ }
+ else
+ {
+ entityList = new ArrayList<ProgramStage>( manager.getAllSorted( getEntityClass() ) );
+ }
+
+ return entityList;
+ }
}