dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08151
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1895: Cleanup/fixes/implemented tentative definition of current activity plan.
------------------------------------------------------------
revno: 1895
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: cbhis-mobile
timestamp: Tue 2010-08-10 12:35:30 +0200
message:
Cleanup/fixes/implemented tentative definition of current activity plan.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
dhis-2/dhis-web/dhis-web-cbhis-api/README.txt
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/OrgUnit.java
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/serialization/ActivityListSerializer.java
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/mapping/OrgUnitsMapper.java
dhis-2/dhis-web/dhis-web-cbhis-api/src/main/webapp/WEB-INF/web.xml
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-portal/pom.xml
dhis-2/dhis-web/dhis-web-portal/src/main/webapp/WEB-INF/web.xml
dhis-2/dhis-web/pom.xml
dhis-2/pom.xml
--
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-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<ProgramStageInstance> 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<ProgramStageInstance> 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<List<ActivityPlanItem>>
{
-
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.
+ * <p>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<Activity> allActivities = activityPlanService.getActivitiesWithInDate( from, to );
+ DateMidnight from = dt.withDayOfMonth( 1 ).toDateMidnight();
+ DateMidnight to = from.plusMonths( 1 );
+
+ final Collection<Activity> allActivities = activityPlanService.getActivitiesByProvider( unit );
Collection<Activity> activities = new ArrayList<Activity>();
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<Activity> 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 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+ <listener>
+ <listener-class>org.hisp.dhis.system.startup.StartupListener</listener-class>
+ </listener>
+
<servlet>
- <servlet-name>case-web-api</servlet-name>
+ <servlet-name>cbhis-web-api</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
@@ -58,20 +65,11 @@
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
</init-param>
-
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
- <servlet-name>case-web-api</servlet-name>
+ <servlet-name>cbhis-web-api</servlet-name>
<url-pattern>/api/cbhis/*</url-pattern>
</servlet-mapping>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <listener>
- <listener-class>org.hisp.dhis.system.startup.StartupListener</listener-class>
- </listener>
-
-
</web-app>
=== 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<BeanMapper<?, ?>> mappers = new HashSet<BeanMapper<?, ?>>();
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 @@
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
- <artifactId>dhis-web-case-api</artifactId>
+ <artifactId>dhis-web-cbhis-api</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
@@ -155,7 +155,7 @@
<dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web-reports-national</artifactId>
- <version>${version}</version>
+ <version>${project.version}</version>
<type>war</type>
</dependency>
-->
=== 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 @@
</filter-mapping>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
- <url-pattern>/api/nbits/*</url-pattern>
+ <url-pattern>/api/cbhis/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>filterChainProxy</filter-name>
@@ -73,24 +73,31 @@
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
+
+<!-- For the dhis-web-cbhis-api module -->
+
+ <servlet>
+ <servlet-name>cbhis-web-api</servlet-name>
+ <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
+ <init-param>
+ <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
+ <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
+ </init-param>
+ <init-param>
+ <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
+ <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
<servlet-mapping>
<servlet-name>mapfish.print</servlet-name>
<url-pattern>/pdf/*</url-pattern>
</servlet-mapping>
-<!-- For the dhis-web-nbits-api module -->
-
- <servlet>
- <servlet-name>nbits-web-api</servlet-name>
- <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
- <init-param>
- <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
- <param-value>com.sun.jersey.server.linking.impl.LinkFilter</param-value>
- </init-param>
- </servlet>
<servlet-mapping>
- <servlet-name>nbits-web-api</servlet-name>
- <url-pattern>/api/nbits/*</url-pattern>
+ <servlet-name>cbhis-web-api</servlet-name>
+ <url-pattern>/api/cbhis/*</url-pattern>
</servlet-mapping>
=== 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 @@
-<project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.hisp.dhis</groupId>
@@ -9,7 +10,7 @@
<packaging>pom</packaging>
<name>DHIS Web Modules Project</name>
<description>This project is a web based GUI for the DHIS 2 system.</description>
-
+
<modules>
<module>dhis-web-commons</module>
<module>dhis-web-commons-resources</module>
@@ -24,9 +25,9 @@
<module>dhis-web-excel-reporting</module>
<module>dhis-web-caseentry</module>
<module>dhis-web-cbhis-api</module>
- <module>dhis-web-portal</module>
-</modules>
-
+ <module>dhis-web-portal</module>
+ </modules>
+
<build>
<plugins>
<plugin>
@@ -41,7 +42,9 @@
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.24</version>
<configuration>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
<systemProperties>
<systemProperty>
<name>org.mortbay.jetty.Request.maxFormContentSize</name>
@@ -52,7 +55,7 @@
</configuration>
</plugin>
</plugins>
- </build>
+ </build>
<dependencyManagement>
<dependencies>
@@ -68,8 +71,7 @@
<type>war</type>
</dependency>
</dependencies>
- </dependencyManagement>
-
+ </dependencyManagement>
<properties>
<rootDir>../</rootDir>
</properties>
=== 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 @@
<name>Dhis2 External Dependencies Repository</name>
<url>http://dhis.uio.no/maven/external</url>
</repository>
- <repository>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Repository Group</name>
+ <url>http://repository.jboss.org/nexus/content/groups/public/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ <!-- repository>
<id>JBoss</id>
<url>http://repository.jboss.org/maven2</url>
- </repository>
+ </repository>-->
</repositories>
<issueManagement>
@@ -438,12 +452,12 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
- <version>3.5.1-Final</version>
+ <version>3.5.4-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
- <version>3.5.1-Final</version>
+ <version>3.5.4-Final</version>
<exclusions>
<exclusion>
<groupId>net.sf.ehcache</groupId>
@@ -454,7 +468,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
- <version>3.5.1-Final</version>
+ <version>3.5.4-Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>