=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2010-08-05 10:48:44 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2010-08-10 10:35:30 +0000 @@ -82,14 +82,15 @@ public Collection getProgramStageInstances( Date startDate, Date endDate ) { - return (getCriteria( Restrictions.ge( "startDate", startDate ), Restrictions.le( "endDate", endDate ) )).list(); + return (getCriteria( Restrictions.ge( "dueDate", startDate ), Restrictions.le( "dueDate", endDate ) )).list(); } @SuppressWarnings( "unchecked" ) public Collection getProgramStageInstances( Date startDate, Date endDate, Boolean completed ) { - return (getCriteria( Restrictions.ge( "startDate", startDate ), Restrictions.le( "endDate", endDate ), + return (getCriteria( Restrictions.ge( "dueDate", startDate ), Restrictions.le( "dueDate", endDate ), Restrictions.eq( "completed", completed ) )).list(); } + } === modified file 'dhis-2/dhis-web/dhis-web-cbhis-api/README.txt' --- dhis-2/dhis-web/dhis-web-cbhis-api/README.txt 2010-08-09 11:40:55 +0000 +++ dhis-2/dhis-web/dhis-web-cbhis-api/README.txt 2010-08-10 10:35:30 +0000 @@ -4,7 +4,7 @@ a experimental example of what a web api for the CBHIS module of DHIS2 might look like. -Requests to paths under /api/cbhis/ will be attempted mapped to the +Requests to paths under /api/cbhis/v0.1/ will be attempted mapped to the resource classes in the package org.hisp.dhis2.cbhis.api.resources. The root resource handling /api/cbhis/ will resolve the logged in @@ -21,15 +21,18 @@ should give an xml with links to the orgunits activity plans, while -curl -u test_user:Trivandrum1 http://localhost:8080/api/cbhis/v0.1/orgunits/2262/activityplan - -should result in an xml of the activity plan, and - -curl -u test_user:Trivandrum1 http://localhost:8080/api/cbhis/v0.1/orgunits/2262/activityplan -H "Accept: applicat -ion/vnd.org.dhis2.casebased.v0.1.activityplan+serialized" - -should return a serialized like openxdata uses. - +curl -u test_user:Trivandrum1 http://localhost:8080/api/cbhis/v0.1/orgUnits/2256/activities/plan/current + +should result in an xml of the current activity plan*, and + +curl -u test_user:Trivandrum1 curl -u test_user:Trivandrum1 http://localhost:8080/api/cbhis/v0.1/orgunits/2262/activityplan -H "Accept: application/vnd.org.dhis2.cbhis.v0.1.activityplan+serialized" + +should return it in serialized form somewhat like openxdata uses. + +* Activity plan is tentatively defined as all activities in the + current month + earlier uncompleted activities. + +curl -u test_user:Trivandrum1 http://localhost:8080/api/cbhis/v0.1/orgUnits/2256/activities/all [1] https://jsr311.dev.java.net/ [2] https://jersey.dev.java.net/ === modified file 'dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/model/Link.java' --- dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/model/Link.java 2010-08-09 22:50:29 +0000 +++ dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/model/Link.java 2010-08-10 10:35:30 +0000 @@ -1,14 +1,10 @@ package org.hisp.dhis.patient.api.model; -import javax.ws.rs.core.UriInfo; import javax.xml.bind.annotation.XmlAttribute; -import org.hisp.dhis.patient.api.resources.ProgramFormsResource; - public class Link { - @XmlAttribute private String url; public Link() @@ -20,6 +16,12 @@ this.url = url; } + @XmlAttribute + public String getUrl() + { + return url; + } + public void setUrl( String url ) { this.url = url; === modified file 'dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/model/OrgUnit.java' --- dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/model/OrgUnit.java 2010-08-09 22:50:29 +0000 +++ dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/model/OrgUnit.java 2010-08-10 10:35:30 +0000 @@ -9,6 +9,7 @@ @XmlAttribute private int id; + @XmlAttribute private String name; === modified file 'dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/model/OrgUnits.java' --- dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/model/OrgUnits.java 2010-08-09 22:50:29 +0000 +++ dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/model/OrgUnits.java 2010-08-10 10:35:30 +0000 @@ -1,15 +1,10 @@ package org.hisp.dhis.patient.api.model; -import java.util.ArrayList; -import java.util.Collection; import java.util.List; -import javax.ws.rs.core.UriInfo; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.hisp.dhis.organisationunit.OrganisationUnit; - @XmlRootElement(name="orgUnits") public class OrgUnits { === modified file 'dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/serialization/ActivityListSerializer.java' --- dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/serialization/ActivityListSerializer.java 2010-08-09 11:40:55 +0000 +++ dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/serialization/ActivityListSerializer.java 2010-08-10 10:35:30 +0000 @@ -13,7 +13,6 @@ public class ActivityListSerializer implements JavaObjectSerializer> { - private Log log = LogFactory.getLog( this.getClass() ); @Override === modified file 'dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/service/ActivityPlanModelService.java' --- dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/service/ActivityPlanModelService.java 2010-08-09 22:50:29 +0000 +++ dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/service/ActivityPlanModelService.java 2010-08-10 10:35:30 +0000 @@ -15,6 +15,7 @@ import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.patient.api.model.ActivityPlan; import org.hisp.dhis.patient.api.model.ActivityPlanItem; +import org.joda.time.DateMidnight; import org.joda.time.DateTime; import org.springframework.beans.factory.annotation.Autowired; @@ -32,22 +33,33 @@ @Context private UriInfo uriInfo; + /** + * Gets the current activity plan for an org unit. + *

The current activity plan is tentatively defined as all activities within the current month and all uncompleted activities from earlier. + */ public ActivityPlan getCurrentActivityPlan( OrganisationUnit unit ) { DateTime dt = new DateTime(); - Date from = dt.withDayOfMonth( 1 ).toDateMidnight().toDate(); - Date to = dt.plusMonths( 1 ).withDayOfMonth( 1 ).toDate(); - - final Collection allActivities = activityPlanService.getActivitiesWithInDate( from, to ); + DateMidnight from = dt.withDayOfMonth( 1 ).toDateMidnight(); + DateMidnight to = from.plusMonths( 1 ); + + final Collection allActivities = activityPlanService.getActivitiesByProvider( unit ); Collection activities = new ArrayList(); for ( Activity activity : allActivities ) { - if (activity.getProvider().getId() == unit.getId()) { + long dueTime = activity.getDueDate().getTime(); + if ( to.isBefore( dueTime ) ) + { + continue; + } + + if (from.isBefore( dueTime ) || !activity.getTask().isCompleted()) { activities.add( activity ); } } - - ActivityPlan plan = mappingFactory.getBeanMapper(Collection.class, ActivityPlan.class).getModel( activities, mappingFactory, uriInfo ); + + ActivityPlan plan = mappingFactory.getBeanMapper( Collection.class, ActivityPlan.class ).getModel( activities, + mappingFactory, uriInfo ); return plan; } @@ -55,11 +67,11 @@ public ActivityPlan getAllActivities( OrganisationUnit unit ) { final Collection activities = activityPlanService.getActivitiesByProvider( unit ); - - return mappingFactory.getBeanMapper(activities, ActivityPlan.class).getModel( activities, mappingFactory, uriInfo ); + + return mappingFactory.getBeanMapper( activities, ActivityPlan.class ).getModel( activities, mappingFactory, + uriInfo ); } - public void setActivityPlanService( ActivityPlanService activityPlanService ) { this.activityPlanService = activityPlanService; @@ -75,7 +87,4 @@ this.mappingFactory = mappingFactory; } - - - } === modified file 'dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/service/mapping/OrgUnitsMapper.java' --- dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/service/mapping/OrgUnitsMapper.java 2010-08-09 22:50:29 +0000 +++ dhis-2/dhis-web/dhis-web-cbhis-api/src/main/java/org/hisp/dhis/patient/api/service/mapping/OrgUnitsMapper.java 2010-08-10 10:35:30 +0000 @@ -38,7 +38,7 @@ OrgUnit m = new OrgUnit(); m.setId(unit.getId()); m.setName(unit.getShortName()); - m.setProgramFormsLink( new Link(uriInfo.getBaseUriBuilder().fromResource( ProgramFormsResource.class).build( unit.getId()).toString())); + m.setProgramFormsLink( new Link(uriInfo.getBaseUriBuilder().path( ProgramFormsResource.class).build( unit.getId()).toString())); m.setActivitiesLink( new Link(uriInfo.getBaseUriBuilder().path( "v0.1/orgUnits/{id}/activities/plan/current" ).build( unit.getId() ).toString())); return m; === modified file 'dhis-2/dhis-web/dhis-web-cbhis-api/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-cbhis-api/src/main/webapp/WEB-INF/web.xml 2010-08-09 11:40:55 +0000 +++ dhis-2/dhis-web/dhis-web-cbhis-api/src/main/webapp/WEB-INF/web.xml 2010-08-10 10:35:30 +0000 @@ -47,8 +47,15 @@ /* + + org.springframework.web.context.ContextLoaderListener + + + org.hisp.dhis.system.startup.StartupListener + + - case-web-api + cbhis-web-api com.sun.jersey.spi.spring.container.servlet.SpringServlet com.sun.jersey.spi.container.ContainerRequestFilters @@ -58,20 +65,11 @@ com.sun.jersey.spi.container.ContainerResponseFilters com.sun.jersey.api.container.filter.LoggingFilter - 1 - case-web-api + cbhis-web-api /api/cbhis/* - - org.springframework.web.context.ContextLoaderListener - - - org.hisp.dhis.system.startup.StartupListener - - - === modified file 'dhis-2/dhis-web/dhis-web-cbhis-api/src/test/java/org/hisp/dhis/patient/api/service/ActivityPlanModelServiceTest.java' --- dhis-2/dhis-web/dhis-web-cbhis-api/src/test/java/org/hisp/dhis/patient/api/service/ActivityPlanModelServiceTest.java 2010-08-09 22:50:29 +0000 +++ dhis-2/dhis-web/dhis-web-cbhis-api/src/test/java/org/hisp/dhis/patient/api/service/ActivityPlanModelServiceTest.java 2010-08-10 10:35:30 +0000 @@ -2,8 +2,7 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collection; @@ -60,7 +59,7 @@ when( mockedOrgUnitService.getOrganisationUnit( 1 ) ).thenReturn( orgUnit ); mockedActivityPlanService = mock( ActivityPlanService.class ); - when( mockedActivityPlanService.getActivitiesByProvider( orgUnit ) ).thenReturn( activities ); + when( mockedActivityPlanService.getActivitiesWithInDate( any(Date.class), any(Date.class) ) ).thenReturn( activities ); Set> mappers = new HashSet>(); mappers.add( new ActivityPlanMapper() ); === modified file 'dhis-2/dhis-web/dhis-web-portal/pom.xml' --- dhis-2/dhis-web/dhis-web-portal/pom.xml 2010-08-10 07:12:18 +0000 +++ dhis-2/dhis-web/dhis-web-portal/pom.xml 2010-08-10 10:35:30 +0000 @@ -138,7 +138,7 @@ org.hisp.dhis - dhis-web-case-api + dhis-web-cbhis-api ${project.version} war @@ -155,7 +155,7 @@ org.hisp.dhis dhis-web-reports-national - ${version} + ${project.version} war --> === modified file 'dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml' --- dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml 2010-08-09 11:40:55 +0000 +++ dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml 2010-08-10 10:35:30 +0000 @@ -44,7 +44,7 @@ OpenSessionInViewFilter - /api/nbits/* + /api/cbhis/* filterChainProxy @@ -73,24 +73,31 @@ 1 + + + + + cbhis-web-api + com.sun.jersey.spi.spring.container.servlet.SpringServlet + + com.sun.jersey.spi.container.ContainerRequestFilters + com.sun.jersey.api.container.filter.LoggingFilter + + + com.sun.jersey.spi.container.ContainerResponseFilters + com.sun.jersey.api.container.filter.LoggingFilter + + 1 + + mapfish.print /pdf/* - - - - nbits-web-api - com.sun.jersey.spi.spring.container.servlet.SpringServlet - - com.sun.jersey.spi.container.ContainerResponseFilters - com.sun.jersey.server.linking.impl.LinkFilter - - - nbits-web-api - /api/nbits/* + cbhis-web-api + /api/cbhis/* === modified file 'dhis-2/dhis-web/pom.xml' --- dhis-2/dhis-web/pom.xml 2010-08-09 19:43:12 +0000 +++ dhis-2/dhis-web/pom.xml 2010-08-10 10:35:30 +0000 @@ -1,4 +1,5 @@ - + 4.0.0 org.hisp.dhis @@ -9,7 +10,7 @@ pom DHIS Web Modules Project This project is a web based GUI for the DHIS 2 system. - + dhis-web-commons dhis-web-commons-resources @@ -24,9 +25,9 @@ dhis-web-excel-reporting dhis-web-caseentry dhis-web-cbhis-api - dhis-web-portal - - + dhis-web-portal + + @@ -41,7 +42,9 @@ org.mortbay.jetty maven-jetty-plugin + 6.1.24 + 10 org.mortbay.jetty.Request.maxFormContentSize @@ -52,7 +55,7 @@ - + @@ -68,8 +71,7 @@ war - - + ../ === modified file 'dhis-2/pom.xml' --- dhis-2/pom.xml 2010-08-09 19:43:12 +0000 +++ dhis-2/pom.xml 2010-08-10 10:35:30 +0000 @@ -51,10 +51,24 @@ Dhis2 External Dependencies Repository http://dhis.uio.no/maven/external - + + jboss-public-repository-group + JBoss Public Repository Group + http://repository.jboss.org/nexus/content/groups/public/ + default + + true + never + + + true + never + + + @@ -438,12 +452,12 @@ org.hibernate hibernate-core - 3.5.1-Final + 3.5.4-Final org.hibernate hibernate-ehcache - 3.5.1-Final + 3.5.4-Final net.sf.ehcache @@ -454,7 +468,7 @@ org.hibernate hibernate-entitymanager - 3.5.1-Final + 3.5.4-Final org.slf4j