dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27637
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13754: csd: minor fixes
------------------------------------------------------------
revno: 13754
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-01-16 19:27:55 +0700
message:
csd: minor fixes
modified:
dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/Envelope.java
dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/GetModificationsResponse.java
dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/webapi/CsdController.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-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/Envelope.java'
--- dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/Envelope.java 2014-01-15 13:10:05 +0000
+++ dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/Envelope.java 2014-01-16 12:27:55 +0000
@@ -36,15 +36,15 @@
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
-@XmlAccessorType( XmlAccessType.FIELD )
-@XmlRootElement( name = "Envelope", namespace = "http://www.w3.org/2003/05/soap-envelope" )
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "Envelope", namespace = "http://www.w3.org/2003/05/soap-envelope")
public class Envelope
{
- @XmlElement( name = "Header", required = true, namespace = "http://www.w3.org/2003/05/soap-envelope" )
- private Header header;
+ @XmlElement(name = "Header", required = true, namespace = "http://www.w3.org/2003/05/soap-envelope")
+ private Header header = new Header();
- @XmlElement( name = "Body", required = true, namespace = "http://www.w3.org/2003/05/soap-envelope" )
- private Body body;
+ @XmlElement(name = "Body", required = true, namespace = "http://www.w3.org/2003/05/soap-envelope")
+ private Body body = new Body();
public Envelope()
{
=== modified file 'dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/GetModificationsResponse.java'
--- dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/GetModificationsResponse.java 2014-01-16 08:30:19 +0000
+++ dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/domain/GetModificationsResponse.java 2014-01-16 12:27:55 +0000
@@ -49,6 +49,11 @@
{
}
+ public GetModificationsResponse( Csd csd )
+ {
+ this.csd = csd;
+ }
+
public Csd getCsd()
{
return csd;
=== modified file 'dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/webapi/CsdController.java'
--- dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/webapi/CsdController.java 2014-01-16 08:23:19 +0000
+++ dhis-2/dhis-web/dhis-web-ohie/src/main/java/org/hisp/dhis/web/ohie/csd/webapi/CsdController.java 2014-01-16 12:27:55 +0000
@@ -33,6 +33,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.web.ohie.csd.domain.Envelope;
+import org.hisp.dhis.web.ohie.csd.domain.GetModificationsResponse;
import org.hisp.dhis.web.ohie.csd.domain.csd.CodedType;
import org.hisp.dhis.web.ohie.csd.domain.csd.CommonName;
import org.hisp.dhis.web.ohie.csd.domain.csd.Contact;
@@ -51,7 +52,6 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.HttpClientErrorException;
import javax.servlet.http.HttpServletRequest;
@@ -92,12 +92,21 @@
}
@RequestMapping( value = "", method = RequestMethod.POST )
- public @ResponseBody Csd csdRequest( HttpServletRequest request, HttpServletResponse response ) throws IOException, JAXBException
+ public void careServicesRequest( HttpServletRequest request, HttpServletResponse response ) throws IOException, JAXBException
{
Object o = jaxbContext.createUnmarshaller().unmarshal( request.getInputStream() );
- Envelope envelope = (Envelope) o;
-
- Date lastModified = null;
+
+ List<OrganisationUnit> organisationUnits = getOrganisationUnits( (Envelope) o );
+
+ Csd csd = createCsd( organisationUnits );
+ Envelope envelope = createResponse( csd ); // unused for now
+
+ jaxbContext.createMarshaller().marshal( csd, response.getOutputStream() );
+ }
+
+ private List<OrganisationUnit> getOrganisationUnits( Envelope envelope )
+ {
+ Date lastModified;
try
{
@@ -108,15 +117,21 @@
throw new HttpClientErrorException( HttpStatus.BAD_REQUEST );
}
- List<OrganisationUnit> byLastUpdated = new ArrayList<OrganisationUnit>(
+ return new ArrayList<OrganisationUnit>(
organisationUnitService.getAllOrganisationUnitsByLastUpdated( lastModified ) );
-
- Csd csd = convertToCsd( byLastUpdated );
-
- return csd;
- }
-
- private Csd convertToCsd( Iterable<OrganisationUnit> organisationUnits )
+ }
+
+ public Envelope createResponse( Csd csd )
+ {
+ Envelope envelope = new Envelope();
+
+ GetModificationsResponse response = new GetModificationsResponse( csd );
+ envelope.getBody().setGetModificationsResponse( response );
+
+ return envelope;
+ }
+
+ private Csd createCsd( Iterable<OrganisationUnit> organisationUnits )
{
Csd csd = new Csd();
csd.getFacilityDirectory().setFacilities( new ArrayList<Facility>() );