dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22549
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10860: wip, api for events
------------------------------------------------------------
revno: 10860
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-05-17 10:29:07 +0700
message:
wip, api for events
removed:
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/programdatavalue/
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/programdatavalue/ProgramInstance.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramInstanceController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramStageController.java
added:
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DataValue.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Event.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/EventService.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/JacksonEventService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramStageController.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java
dhis-2/dhis-dxf2/pom.xml
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java
dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl
--
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-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java 2013-04-08 04:21:21 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java 2013-05-17 03:29:07 +0000
@@ -26,16 +26,23 @@
*/
package org.hisp.dhis.patient;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.ExportView;
+
import java.util.HashSet;
import java.util.Set;
-import org.hisp.dhis.common.BaseIdentifiableObject;
-
/**
* @author Abyot Asalefew
* @version $Id$
*/
-
+@JacksonXmlRootElement( localName = "patientAttribute", namespace = DxfNamespaces.DXF_2_0 )
public class PatientAttribute
extends BaseIdentifiableObject
{
@@ -57,7 +64,7 @@
public static final String TYPE_COMBO = "combo";
private String description;
-
+
private String valueType;
private boolean mandatory;
@@ -140,14 +147,25 @@
attributeOptions.add( option );
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public Boolean getInherit()
+ {
+ return inherit;
+ }
+
public void setInherit( Boolean inherit )
{
this.inherit = inherit;
}
- public Boolean getInherit()
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public Boolean getGroupBy()
{
- return inherit;
+ return groupBy;
}
public void setGroupBy( Boolean groupBy )
@@ -155,11 +173,9 @@
this.groupBy = groupBy;
}
- public Boolean getGroupBy()
- {
- return groupBy;
- }
-
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public boolean isMandatory()
{
return mandatory;
@@ -170,6 +186,9 @@
this.mandatory = mandatory;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public String getDescription()
{
return description;
@@ -180,6 +199,9 @@
this.description = description;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public String getValueType()
{
return valueType;
@@ -200,6 +222,9 @@
this.patientAttributeGroup = patientAttributeGroup;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public String getExpression()
{
return expression;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroup.java 2013-02-13 03:57:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeGroup.java 2013-05-17 03:29:07 +0000
@@ -26,22 +26,25 @@
*/
package org.hisp.dhis.patient;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.ExportView;
+
+import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.hisp.dhis.common.BaseIdentifiableObject;
-import org.hisp.dhis.common.DxfNamespaces;
-
/**
* @author Chau Thu Tran
* @version $Id$
*/
-@XmlRootElement( name = "patientAttributeGroup", namespace = DxfNamespaces.DXF_2_0)
-@XmlAccessorType( value = XmlAccessType.NONE )
+@XmlRootElement(name = "patientAttributeGroup", namespace = DxfNamespaces.DXF_2_0)
public class PatientAttributeGroup
extends BaseIdentifiableObject
{
@@ -117,6 +120,11 @@
this.description = description;
}
+ @JsonProperty
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "patientAttributes", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "patientAttribute", namespace = DxfNamespaces.DXF_2_0 )
public List<PatientAttribute> getAttributes()
{
return attributes;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2013-05-15 09:14:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2013-05-17 03:29:07 +0000
@@ -27,10 +27,12 @@
package org.hisp.dhis.program;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.apache.commons.lang.StringUtils;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.DxfNamespaces;
@@ -45,12 +47,9 @@
import org.hisp.dhis.user.UserAuthorityGroup;
import org.hisp.dhis.validation.ValidationCriteria;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
/**
* @author Abyot Asalefew
@@ -117,7 +116,6 @@
/**
* Enabled this property to show a pop-up for confirming Complete a program
* after to complete a progam-stage
- *
*/
private Boolean remindCompleted = false;
@@ -486,6 +484,11 @@
return type != null && (SINGLE_EVENT_WITH_REGISTRATION == type || MULTIPLE_EVENTS_WITH_REGISTRATION == type);
}
+ @JsonProperty
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "userRoles", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "userRole", namespace = DxfNamespaces.DXF_2_0 )
public Set<UserAuthorityGroup> getUserRoles()
{
return userRoles;
@@ -496,6 +499,8 @@
this.userRoles = userRoles;
}
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Boolean getOnlyEnrollOnce()
{
return onlyEnrollOnce;
@@ -516,6 +521,8 @@
this.patientReminders = patientReminders;
}
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Boolean getDisableRegistrationFields()
{
return disableRegistrationFields;
@@ -526,6 +533,10 @@
this.disableRegistrationFields = disableRegistrationFields;
}
+ @JsonProperty
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+ @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0 )
public Set<OrganisationUnitGroup> getOrganisationUnitGroups()
{
return organisationUnitGroups;
@@ -536,6 +547,8 @@
this.organisationUnitGroups = organisationUnitGroups;
}
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Boolean getDisplayOnAllOrgunit()
{
return displayOnAllOrgunit;
@@ -545,5 +558,5 @@
{
this.displayOnAllOrgunit = displayOnAllOrgunit;
}
-
+
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2013-04-10 08:45:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2013-05-17 03:29:07 +0000
@@ -29,6 +29,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.hisp.dhis.common.BaseIdentifiableObject;
@@ -145,11 +146,6 @@
// Getters and setters
// -------------------------------------------------------------------------
- public DataEntryForm getDataEntryForm()
- {
- return dataEntryForm;
- }
-
public Set<PatientReminder> getPatientReminders()
{
return patientReminders;
@@ -160,6 +156,11 @@
this.patientReminders = patientReminders;
}
+ public DataEntryForm getDataEntryForm()
+ {
+ return dataEntryForm;
+ }
+
public void setDataEntryForm( DataEntryForm dataEntryForm )
{
this.dataEntryForm = dataEntryForm;
@@ -173,6 +174,11 @@
return description;
}
+ @JsonProperty( value = "validationCriterias" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "validationCriterias", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "validationCriteria", namespace = DxfNamespaces.DXF_2_0 )
public Set<ProgramStageSection> getProgramStageSections()
{
return programStageSections;
@@ -241,7 +247,10 @@
this.program = program;
}
- // TODO expose as xml/json
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "programStageDataElements", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "programStageDataElement", namespace = DxfNamespaces.DXF_2_0 )
public Set<ProgramStageDataElement> getProgramStageDataElements()
{
return programStageDataElements;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java 2013-02-13 03:00:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java 2013-05-17 03:29:07 +0000
@@ -26,6 +26,15 @@
*/
package org.hisp.dhis.program;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataelement.DataElement;
import java.io.Serializable;
@@ -34,6 +43,7 @@
* @author Viet Nguyen
* @version $Id$
*/
+@JacksonXmlRootElement( localName = "programStageDataElement", namespace = DxfNamespaces.DXF_2_0 )
public class ProgramStageDataElement
implements Serializable
{
@@ -88,6 +98,10 @@
{
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JsonSerialize( as = BaseIdentifiableObject.class )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public ProgramStage getProgramStage()
{
return programStage;
@@ -98,6 +112,10 @@
this.programStage = programStage;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JsonSerialize( as = BaseIdentifiableObject.class )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public DataElement getDataElement()
{
return dataElement;
@@ -108,6 +126,9 @@
this.dataElement = dataElement;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public Boolean getAllowProvidedElsewhere()
{
return allowProvidedElsewhere;
@@ -118,6 +139,9 @@
this.allowProvidedElsewhere = allowProvidedElsewhere;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public boolean isCompulsory()
{
return compulsory;
@@ -138,6 +162,9 @@
this.sortOrder = sortOrder;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public Boolean getDisplayInReports()
{
return displayInReports;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java 2013-02-04 03:09:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSection.java 2013-05-17 03:29:07 +0000
@@ -30,14 +30,23 @@
import java.util.ArrayList;
import java.util.List;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.ExportView;
/**
* @author Chau Thu Tran
*
* @version ProgramStageSection.java 11:07:27 AM Aug 22, 2012 $
*/
-
+@JacksonXmlRootElement( localName = "programStageSection", namespace = DxfNamespaces.DXF_2_0 )
public class ProgramStageSection
extends BaseIdentifiableObject
{
@@ -122,6 +131,11 @@
return sortOrder;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+ @JacksonXmlElementWrapper( localName = "programStageDataElements", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "programStageDataElement", namespace = DxfNamespaces.DXF_2_0 )
public List<ProgramStageDataElement> getProgramStageDataElements()
{
return programStageDataElements;
=== modified file 'dhis-2/dhis-dxf2/pom.xml'
--- dhis-2/dhis-dxf2/pom.xml 2013-05-13 10:39:38 +0000
+++ dhis-2/dhis-dxf2/pom.xml 2013-05-17 03:29:07 +0000
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -26,6 +26,10 @@
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-i18n</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
<artifactId>dhis-support-system</artifactId>
</dependency>
<dependency>
@@ -37,10 +41,10 @@
<artifactId>dhis-support-xml</artifactId>
</dependency>
<dependency>
- <groupId>net.sf.opencsv</groupId>
- <artifactId>opencsv</artifactId>
+ <groupId>net.sf.opencsv</groupId>
+ <artifactId>opencsv</artifactId>
</dependency>
-
+
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
=== added directory 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event'
=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java 2013-05-17 03:29:07 +0000
@@ -0,0 +1,238 @@
+package org.hisp.dhis.dxf2.event;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dxf2.importsummary.ImportConflict;
+import org.hisp.dhis.dxf2.importsummary.ImportStatus;
+import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.i18n.I18nManager;
+import org.hisp.dhis.i18n.I18nManagerException;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.patientdatavalue.PatientDataValue;
+import org.hisp.dhis.patientdatavalue.PatientDataValueService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public abstract class BaseEventService implements EventService
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private ProgramService programService;
+
+ @Autowired
+ private ProgramInstanceService programInstanceService;
+
+ @Autowired
+ private ProgramStageInstanceService programStageInstanceService;
+
+ @Autowired
+ private OrganisationUnitService organisationUnitService;
+
+ @Autowired
+ private DataElementService dataElementService;
+
+ @Autowired
+ private CurrentUserService currentUserService;
+
+ @Autowired
+ private PatientDataValueService patientDataValueService;
+
+ @Autowired
+ private I18nManager i18nManager;
+
+ // -------------------------------------------------------------------------
+ // Implementation
+ // -------------------------------------------------------------------------
+
+ protected ImportSummary saveEvent( Event event )
+ {
+ Program program = programService.getProgram( event.getId() );
+
+ if ( program == null )
+ {
+ return new ImportSummary( ImportStatus.ERROR, "Event ID does not point to a valid program." );
+ }
+
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( event.getOrganisationUnitId() );
+
+ if ( organisationUnit == null )
+ {
+ return new ImportSummary( ImportStatus.ERROR, "Event organisationUnitId does not point to a valid organisation unit." );
+ }
+
+ if ( program.getType() == Program.SINGLE_EVENT_WITHOUT_REGISTRATION )
+ {
+ return saveSingleEventWithoutRegistration( program, organisationUnit, event );
+ }
+ else if ( program.getType() == Program.SINGLE_EVENT_WITH_REGISTRATION )
+ {
+ return saveSingleEventWithRegistration( program, organisationUnit, event );
+ }
+ else if ( program.getType() == Program.MULTIPLE_EVENTS_WITH_REGISTRATION )
+ {
+ return saveMultipleEventsWithRegistration( program, organisationUnit, event );
+ }
+
+ return new ImportSummary();
+ }
+
+ private ImportSummary saveSingleEventWithoutRegistration( Program program, OrganisationUnit organisationUnit, Event event )
+ {
+ I18nFormat format = null;
+
+ try
+ {
+ format = i18nManager.getI18nFormat();
+ }
+ catch ( I18nManagerException ex )
+ {
+ return new ImportSummary( ImportStatus.ERROR, ex.getMessage() );
+ }
+
+ Date executionDate = format.parseDate( event.getExecutionDate() );
+
+ if ( executionDate == null )
+ {
+ return new ImportSummary( ImportStatus.ERROR, "Event executionDate is not in a valid format." );
+ }
+
+ ImportSummary importSummary = new ImportSummary();
+
+ ProgramStageInstance programStageInstance = saveExecutionDate( program, organisationUnit, executionDate, event.getCompleted() );
+
+ for ( DataValue dataValue : event.getDataValues() )
+ {
+ DataElement dataElement = dataElementService.getDataElement( dataValue.getDataElementId() );
+
+ if ( dataElement == null )
+ {
+ importSummary.getConflicts().add( new ImportConflict( "dataElementId", dataValue.getDataElementId() + " is not a valid dataElementId." ) );
+ importSummary.getDataValueCount().incrementIgnored();
+ }
+ else
+ {
+ saveDataValue( programStageInstance, dataElement, dataValue.getValue(), dataValue.getProvidedElsewhere() );
+ importSummary.getDataValueCount().incrementImported();
+ }
+ }
+
+ importSummary.setStatus( ImportStatus.SUCCESS );
+
+ return importSummary;
+ }
+
+ private ProgramStageInstance saveExecutionDate( Program program, OrganisationUnit organisationUnit, Date date, Boolean completed )
+ {
+ ProgramStage programStage = program.getProgramStages().iterator().next();
+ ProgramInstance programInstance = programInstanceService.getProgramInstances( program ).iterator().next();
+
+ ProgramStageInstance programStageInstance = new ProgramStageInstance();
+ programStageInstance.setProgramInstance( programInstance );
+ programStageInstance.setProgramStage( programStage );
+ programStageInstance.setDueDate( date );
+ programStageInstance.setExecutionDate( date );
+ programStageInstance.setOrganisationUnit( organisationUnit );
+
+ if ( completed != null )
+ {
+ programStageInstance.setCompleted( completed );
+ programStageInstance.setCompletedDate( new Date() );
+ programStageInstance.setCompletedUser( currentUserService.getCurrentUsername() );
+ }
+
+ programStageInstanceService.addProgramStageInstance( programStageInstance );
+
+ return programStageInstance;
+ }
+
+ private void saveDataValue( ProgramStageInstance programStageInstance, DataElement dataElement, String value, Boolean providedElsewhere )
+ {
+ String storedBy = currentUserService.getCurrentUsername();
+
+ if ( value != null && value.trim().length() == 0 )
+ {
+ value = null;
+ }
+
+ PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, dataElement );
+
+ if ( value != null )
+ {
+ if ( patientDataValue == null )
+ {
+ patientDataValue = new PatientDataValue( programStageInstance, dataElement, new Date(), value );
+ patientDataValue.setStoredBy( storedBy );
+ patientDataValue.setProvidedElsewhere( providedElsewhere );
+
+ patientDataValueService.savePatientDataValue( patientDataValue );
+ }
+ else
+ {
+ patientDataValue.setValue( value );
+ patientDataValue.setTimestamp( new Date() );
+ patientDataValue.setProvidedElsewhere( providedElsewhere );
+ patientDataValue.setStoredBy( storedBy );
+
+ patientDataValueService.updatePatientDataValue( patientDataValue );
+ }
+ }
+ else if ( patientDataValue != null )
+ {
+ patientDataValueService.deletePatientDataValue( patientDataValue );
+ }
+ }
+
+ private ImportSummary saveSingleEventWithRegistration( Program program, OrganisationUnit organisationUnit, Event event )
+ {
+ return new ImportSummary();
+ }
+
+ private ImportSummary saveMultipleEventsWithRegistration( Program program, OrganisationUnit organisationUnit, Event event )
+ {
+ return new ImportSummary();
+ }
+}
=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DataValue.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DataValue.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DataValue.java 2013-05-17 03:29:07 +0000
@@ -0,0 +1,94 @@
+package org.hisp.dhis.dxf2.event;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import org.hisp.dhis.common.DxfNamespaces;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DataValue
+{
+ private String value;
+
+ private String dataElementId;
+
+ private Boolean providedElsewhere = false;
+
+ public DataValue()
+ {
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public String getDataElementId()
+ {
+ return dataElementId;
+ }
+
+ public void setDataElementId( String dataElementId )
+ {
+ this.dataElementId = dataElementId;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public Boolean getProvidedElsewhere()
+ {
+ return providedElsewhere;
+ }
+
+ public void setProvidedElsewhere( Boolean providedElsewhere )
+ {
+ this.providedElsewhere = providedElsewhere;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "DataValue{" +
+ "value='" + value + '\'' +
+ ", dataElementId='" + dataElementId + '\'' +
+ ", providedElsewhere=" + providedElsewhere +
+ '}';
+ }
+}
=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Event.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Event.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Event.java 2013-05-17 03:29:07 +0000
@@ -0,0 +1,176 @@
+package org.hisp.dhis.dxf2.event;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.DxfNamespaces;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@JacksonXmlRootElement( localName = "event", namespace = DxfNamespaces.DXF_2_0 )
+public class Event
+{
+ private String id;
+
+ private String eventId;
+
+ private String organisationUnitId;
+
+ private String patientId;
+
+ private String executionDate;
+
+ private Boolean completed = false;
+
+ private String storedBy;
+
+ private List<DataValue> dataValues = new ArrayList<DataValue>();
+
+ public Event()
+ {
+ }
+
+ @JsonProperty( required = true )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public String getEventId()
+ {
+ return eventId;
+ }
+
+ public void setEventId( String eventId )
+ {
+ this.eventId = eventId;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public String getOrganisationUnitId()
+ {
+ return organisationUnitId;
+ }
+
+ public void setOrganisationUnitId( String organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public String getPatientId()
+ {
+ return patientId;
+ }
+
+ public void setPatientId( String patientId )
+ {
+ this.patientId = patientId;
+ }
+
+ @JsonProperty( required = true )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public String getExecutionDate()
+ {
+ return executionDate;
+ }
+
+ public void setExecutionDate( String executionDate )
+ {
+ this.executionDate = executionDate;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public Boolean getCompleted()
+ {
+ return completed;
+ }
+
+ public void setCompleted( Boolean completed )
+ {
+ this.completed = completed;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
+ public String getStoredBy()
+ {
+ return storedBy;
+ }
+
+ public void setStoredBy( String storedBy )
+ {
+ this.storedBy = storedBy;
+ }
+
+ @JsonProperty
+ @JacksonXmlElementWrapper( localName = "dataValues", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "dataValue", namespace = DxfNamespaces.DXF_2_0 )
+ public List<DataValue> getDataValues()
+ {
+ return dataValues;
+ }
+
+ public void setDataValues( List<DataValue> dataValues )
+ {
+ this.dataValues = dataValues;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Event{" +
+ "id='" + id + '\'' +
+ ", eventId='" + eventId + '\'' +
+ ", organisationUnitId='" + organisationUnitId + '\'' +
+ ", patientId='" + patientId + '\'' +
+ ", executionDate='" + executionDate + '\'' +
+ ", completed=" + completed +
+ ", storedBy='" + storedBy + '\'' +
+ ", dataValues=" + dataValues +
+ '}';
+ }
+}
=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/EventService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/EventService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/EventService.java 2013-05-17 03:29:07 +0000
@@ -0,0 +1,43 @@
+package org.hisp.dhis.dxf2.event;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public interface EventService
+{
+ ImportSummary saveEventXml( InputStream inputStream ) throws IOException;
+
+ ImportSummary saveEventJson( InputStream inputStream ) throws IOException;
+}
=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/JacksonEventService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/JacksonEventService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/JacksonEventService.java 2013-05-17 03:29:07 +0000
@@ -0,0 +1,64 @@
+package org.hisp.dhis.dxf2.event;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Implementation of EventService that uses Jackson for serialization and deserialization.
+ *
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class JacksonEventService extends BaseEventService
+{
+ // -------------------------------------------------------------------------
+ // EventService Impl
+ // -------------------------------------------------------------------------
+
+ @Override
+ public ImportSummary saveEventXml( InputStream inputStream ) throws IOException
+ {
+ Event event = JacksonUtils.fromXml( inputStream, Event.class );
+ ImportSummary importSummary = saveEvent( event );
+
+ return importSummary;
+ }
+
+ @Override
+ public ImportSummary saveEventJson( InputStream inputStream ) throws IOException
+ {
+ Event event = JacksonUtils.fromJson( inputStream, Event.class );
+ ImportSummary importSummary = saveEvent( event );
+
+ return importSummary;
+ }
+}
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java 2013-02-13 03:57:52 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java 2013-05-17 03:29:07 +0000
@@ -43,7 +43,7 @@
private String description;
- private ImportCount dataValueCount;
+ private ImportCount dataValueCount = new ImportCount();
private List<ImportConflict> conflicts = new ArrayList<ImportConflict>();
=== removed directory 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/programdatavalue'
=== removed file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/programdatavalue/ProgramInstance.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/programdatavalue/ProgramInstance.java 2013-05-14 09:56:21 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/programdatavalue/ProgramInstance.java 1970-01-01 00:00:00 +0000
@@ -1,126 +0,0 @@
-package org.hisp.dhis.dxf2.programdatavalue;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import org.hisp.dhis.common.DxfNamespaces;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@JacksonXmlRootElement( localName = "programInstance", namespace = DxfNamespaces.DXF_2_0 )
-public class ProgramInstance
-{
- private String id;
-
- private String programInstanceId;
-
- private String organisationUnitId;
-
- private String executionDate;
-
- private Boolean completed = false;
-
- public ProgramInstance()
- {
- }
-
- @JsonProperty( required = true )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- @JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
- public String getProgramInstanceId()
- {
- return programInstanceId;
- }
-
- public void setProgramInstanceId( String programInstanceId )
- {
- this.programInstanceId = programInstanceId;
- }
-
- @JsonProperty( required = true )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
- public String getOrganisationUnitId()
- {
- return organisationUnitId;
- }
-
- public void setOrganisationUnitId( String organisationUnitId )
- {
- this.organisationUnitId = organisationUnitId;
- }
-
- @JsonProperty( required = true )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
- public String getExecutionDate()
- {
- return executionDate;
- }
-
- public void setExecutionDate( String executionDate )
- {
- this.executionDate = executionDate;
- }
-
- @JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0, isAttribute = true )
- public boolean isCompleted()
- {
- return completed;
- }
-
- public void setCompleted( Boolean completed )
- {
- this.completed = completed;
- }
-
- @Override
- public String toString()
- {
- return "ProgramInstance{" +
- "id='" + id + '\'' +
- ", programInstanceId='" + programInstanceId + '\'' +
- ", organisationUnitId='" + organisationUnitId + '\'' +
- ", executionDate='" + executionDate + '\'' +
- ", completed=" + completed +
- '}';
- }
-}
=== modified file 'dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml 2013-03-01 10:18:31 +0000
+++ dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml 2013-05-17 03:29:07 +0000
@@ -14,6 +14,8 @@
<bean id="org.hisp.dhis.dxf2.datavalueset.DataValueSetStore"
class="org.hisp.dhis.dxf2.datavalueset.SpringDataValueSetStore" />
+ <bean id="org.hisp.dhis.dxf2.event.EventService" class="org.hisp.dhis.dxf2.event.JacksonEventService" />
+
<!-- register idObject handlers -->
<bean id="organisationUnitObjectHandler"
=== added directory 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event'
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java 2013-05-17 03:29:07 +0000
@@ -0,0 +1,86 @@
+package org.hisp.dhis.api.controller.event;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.api.utils.ContextUtils;
+import org.hisp.dhis.dxf2.event.EventService;
+import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.dxf2.metadata.ImportOptions;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Controller
+@RequestMapping( value = EventController.RESOURCE_PATH )
+public class EventController
+{
+ public static final String RESOURCE_PATH = "/events";
+
+ @Autowired
+ private EventService eventService;
+
+ // -------------------------------------------------------------------------
+ // Controller
+ // -------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, consumes = "application/xml" )
+ @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')" )
+ public void postDxf2ProgramInstance( ImportOptions importOptions,
+ HttpServletResponse response, InputStream inputStream, Model model ) throws IOException
+ {
+ ImportSummary importSummary = eventService.saveEventXml( inputStream );
+ JacksonUtils.toXml( response.getOutputStream(), importSummary );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
+ @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')" )
+ public void postJsonProgramInstance( ImportOptions importOptions,
+ HttpServletResponse response, InputStream inputStream, Model model ) throws IOException
+ {
+ ImportSummary importSummary = eventService.saveEventJson( inputStream );
+ JacksonUtils.toJson( response.getOutputStream(), importSummary );
+ }
+
+ @ExceptionHandler( IllegalArgumentException.class )
+ public void handleError( IllegalArgumentException ex, HttpServletResponse response )
+ {
+ ContextUtils.conflictResponse( response, ex.getMessage() );
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramController.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramController.java 2013-05-17 03:29:07 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.api.controller.event;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.api.controller.AbstractCrudController;
+import org.hisp.dhis.program.Program;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Controller
+@RequestMapping( value = ProgramController.RESOURCE_PATH )
+public class ProgramController
+ extends AbstractCrudController<Program>
+{
+ public static final String RESOURCE_PATH = "/programs";
+}
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/ProgramStageController.java 2013-05-17 03:29:07 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.api.controller.event;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.api.controller.AbstractCrudController;
+import org.hisp.dhis.program.ProgramStage;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Controller
+@RequestMapping( value = ProgramStageController.RESOURCE_PATH )
+public class ProgramStageController
+ extends AbstractCrudController<ProgramStage>
+{
+ public static final String RESOURCE_PATH = "/programStages";
+}
=== removed directory 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker'
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramController.java 2013-05-14 09:56:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramController.java 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
-package org.hisp.dhis.api.controller.tracker;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.api.controller.AbstractCrudController;
-import org.hisp.dhis.program.Program;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@Controller
-@RequestMapping( value = ProgramController.RESOURCE_PATH )
-public class ProgramController
- extends AbstractCrudController<Program>
-{
- public static final String RESOURCE_PATH = "/programs";
-}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramInstanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramInstanceController.java 2013-05-15 15:00:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramInstanceController.java 1970-01-01 00:00:00 +0000
@@ -1,115 +0,0 @@
-package org.hisp.dhis.api.controller.tracker;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.hisp.dhis.api.utils.ContextUtils;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dxf2.metadata.ImportOptions;
-import org.hisp.dhis.dxf2.programdatavalue.ProgramInstance;
-import org.hisp.dhis.dxf2.utils.JacksonUtils;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.patientdatavalue.PatientDataValueService;
-import org.hisp.dhis.program.ProgramInstanceService;
-import org.hisp.dhis.program.ProgramService;
-import org.hisp.dhis.program.ProgramStageInstanceService;
-import org.hisp.dhis.user.CurrentUserService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@Controller
-@RequestMapping( value = ProgramInstanceController.RESOURCE_PATH )
-public class ProgramInstanceController
-{
- public static final String RESOURCE_PATH = "/programInstances";
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- @Autowired
- private ProgramService programService;
-
- @Autowired
- private ProgramInstanceService programInstanceService;
-
- @Autowired
- private ProgramStageInstanceService programStageInstanceService;
-
- @Autowired
- private OrganisationUnitService organisationUnitService;
-
- @Autowired
- private DataElementService dataElementService;
-
- @Autowired
- private CurrentUserService currentUserService;
-
- @Autowired
- private PatientDataValueService patientDataValueService;
-
- // -------------------------------------------------------------------------
- // Controller
- // -------------------------------------------------------------------------
-
- @RequestMapping( method = RequestMethod.POST, consumes = "application/xml" )
- @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')" )
- public void postDxf2ProgramInstance( ImportOptions importOptions,
- HttpServletResponse response, InputStream in, Model model ) throws IOException
- {
- ProgramInstance programInstance = JacksonUtils.fromXml( in, ProgramInstance.class );
- System.err.println( programInstance );
- }
-
- @RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_DATAVALUE_ADD')" )
- public void postJsonProgramInstance( ImportOptions importOptions,
- HttpServletResponse response, InputStream in, Model model ) throws IOException
- {
- ProgramInstance programInstance = JacksonUtils.fromJson( in, ProgramInstance.class );
- System.err.println( programInstance );
- }
-
- @ExceptionHandler( IllegalArgumentException.class )
- public void handleError( IllegalArgumentException ex, HttpServletResponse response )
- {
- ContextUtils.conflictResponse( response, ex.getMessage() );
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramStageController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramStageController.java 2013-05-14 09:56:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/tracker/ProgramStageController.java 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
-package org.hisp.dhis.api.controller.tracker;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.api.controller.AbstractCrudController;
-import org.hisp.dhis.program.ProgramStage;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@Controller
-@RequestMapping( value = ProgramStageController.RESOURCE_PATH )
-public class ProgramStageController
- extends AbstractCrudController<ProgramStage>
-{
- public static final String RESOURCE_PATH = "/programStages";
-}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl 2012-12-09 10:12:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl 2013-05-17 03:29:07 +0000
@@ -19,7 +19,7 @@
d:organisationUnitGroupSets|d:indicatorTypes|d:attributeTypes|d:reports|d:constants|
d:sqlViews|d:validationRules|d:validationRuleGroups|d:users|d:userGroups|d:userAuthorityGroups|
d:reportTables|d:mapLegends|d:mapLegendSets|d:mapLayers|d:optionSets|d:interpretations|
- d:sections|d:userRoles|d:organisationUnitLevels">
+ d:sections|d:userRoles|d:organisationUnitLevels|d:programs|d:programStages">
<h3>
<xsl:value-of select="local-name()" />