dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16711
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6420: Moved DataValueSetService from import-export to dxf2 module. Moved DataValueSets object from dhis...
------------------------------------------------------------
revno: 6420
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-28 18:04:53 +0200
message:
Moved DataValueSetService from import-export to dxf2 module. Moved DataValueSets object from dhis-web-api to dx2 module. Changed DataValueSet from using Jaxb to Jackson for serialization.
removed:
dhis-2/dhis-dxf2/src/test/java/org/
dhis-2/dhis-dxf2/src/test/java/org/hisp/
dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/
dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2/
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataValue.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/package-info.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueImportService.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/StaXDataValueImportService.java
added:
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValues.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/
dhis-2/dhis-dxf2/src/main/resources/
dhis-2/dhis-dxf2/src/main/resources/META-INF/
dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/
dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml
renamed:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataValueSet.java => dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetService.java => dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DefaultDataValueSetService.java => dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/DataValueSets.java => dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSets.java
modified:
dhis-2/dhis-dxf2/pom.xml
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java
dhis-2/dhis-services/dhis-service-importexport/pom.xml
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java
dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetServiceTest.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java
dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSets.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-dxf2/pom.xml'
--- dhis-2/dhis-dxf2/pom.xml 2012-03-22 15:11:32 +0000
+++ dhis-2/dhis-dxf2/pom.xml 2012-03-28 16:04:53 +0000
@@ -21,6 +21,15 @@
<artifactId>dhis-api</artifactId>
</dependency>
<dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-support-system</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-support-test</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
@@ -36,17 +45,15 @@
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
-
+
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
-
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
-
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
=== added directory 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue'
=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValue.java 2012-03-28 16:04:53 +0000
@@ -0,0 +1,174 @@
+package org.hisp.dhis.dxf2.datavalue;
+
+/*
+ * Copyright (c) 2011, 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.util.Date;
+
+import org.hisp.dhis.common.Dxf2Namespace;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
+@JacksonXmlRootElement( localName = "dataValue", namespace = Dxf2Namespace.NAMESPACE )
+public class DataValue
+{
+ private String dataElement;
+
+ private String period;
+
+ private String orgUnit;
+
+ private String categoryOptionCombo;
+
+ private String value;
+
+ private String storedBy;
+
+ private Date timestamp;
+
+ private String comment;
+
+ private Boolean followup;
+
+ public DataValue()
+ {
+ }
+
+ public DataValue( String s )
+ {
+ }
+
+ @JsonProperty( required=true)
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public String getDataElement()
+ {
+ return dataElement;
+ }
+
+ public void setDataElement( String dataElement )
+ {
+ this.dataElement = dataElement;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public String getPeriod()
+ {
+ return period;
+ }
+
+ public void setPeriod( String period )
+ {
+ this.period = period;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public String getOrgUnit()
+ {
+ return orgUnit;
+ }
+
+ public void setOrgUnit( String orgUnit )
+ {
+ this.orgUnit = orgUnit;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public String getCategoryOptionCombo()
+ {
+ return categoryOptionCombo;
+ }
+
+ public void setCategoryOptionCombo( String categoryOptionCombo )
+ {
+ this.categoryOptionCombo = categoryOptionCombo;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public String getStoredBy()
+ {
+ return storedBy;
+ }
+
+ public void setStoredBy( String storedBy )
+ {
+ this.storedBy = storedBy;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public Date getTimestamp()
+ {
+ return timestamp;
+ }
+
+ public void setTimestamp( Date timestamp )
+ {
+ this.timestamp = timestamp;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public String getComment()
+ {
+ return comment;
+ }
+
+ public void setComment( String comment )
+ {
+ this.comment = comment;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public Boolean getFollowup()
+ {
+ return followup;
+ }
+
+ public void setFollowup( Boolean followup )
+ {
+ this.followup = followup;
+ }
+}
=== added file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValues.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValues.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/DataValues.java 2012-03-28 16:04:53 +0000
@@ -0,0 +1,30 @@
+package org.hisp.dhis.dxf2.datavalue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.common.Dxf2Namespace;
+
+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;
+
+@JacksonXmlRootElement( localName = "dxf2", namespace = Dxf2Namespace.NAMESPACE )
+public class DataValues
+{
+ private List<DataValue> dataValues = new ArrayList<DataValue>();
+
+ @JsonProperty
+ @JacksonXmlElementWrapper( localName = "dataValues", namespace = Dxf2Namespace.NAMESPACE )
+ @JacksonXmlProperty( localName = "dataValue", namespace = Dxf2Namespace.NAMESPACE )
+ public List<DataValue> getDataValues()
+ {
+ return dataValues;
+ }
+
+ public void setDataValues( List<DataValue> dataValues )
+ {
+ this.dataValues = dataValues;
+ }
+}
=== added directory 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset'
=== renamed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataValueSet.java' => 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataValueSet.java 2012-01-06 09:42:17 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java 2012-03-28 16:04:53 +0000
@@ -1,4 +1,4 @@
-package org.hisp.dhis.importexport.dxf2.model;
+package org.hisp.dhis.dxf2.datavalueset;
/*
* Copyright (c) 2011, University of Oslo
@@ -27,31 +27,30 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+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.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-@XmlAccessorType( XmlAccessType.FIELD )
+import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.dxf2.datavalue.DataValue;
+
+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;
+
+@JacksonXmlRootElement( localName = "dataValueSet", namespace = Dxf2Namespace.NAMESPACE )
public class DataValueSet
{
- // ---------------------------------------------------------------------------
- // Element and attribute names
- // ---------------------------------------------------------------------------
-
+ /*
public static final String ATTR_COMMENT = "comment";
public static final String ATTR_DATASET = "dataSet";
public static final String ATTR_IDSCHEME = "idScheme";
public static final String ATTR_ORGUNIT = "orgUnit";
public static final String ATTR_PERIOD = "period";
public static final String ATTR_COMPLETE = "period";
-
public static final String DATAVALUE = "dataValue";
-
+ */
+
public enum IdentificationStrategy { INTERNAL, UID, CODE };
/**
@@ -59,24 +58,20 @@
*/
public static final IdentificationStrategy DEFAULT_STRATEGY = IdentificationStrategy.UID;
- @XmlAttribute( name = ATTR_DATASET )
private String dataSetIdentifier;
- @XmlAttribute( name = ATTR_ORGUNIT )
private String organisationUnitIdentifier;
- @XmlAttribute( name = ATTR_PERIOD, required = true )
private String periodIsoDate;
- @XmlAttribute( name = ATTR_COMPLETE )
private String completeDate;
- @XmlAttribute( name = ATTR_IDSCHEME )
private IdentificationStrategy idScheme;
- @XmlElement( name = DATAVALUE )
- private List<DataValue> dataValues;
+ private List<DataValue> dataValues = new ArrayList<DataValue>();
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
public IdentificationStrategy getIdScheme()
{
return (idScheme != null) ? idScheme : DEFAULT_STRATEGY;
@@ -87,6 +82,8 @@
this.idScheme = idScheme;
}
+ @JsonProperty( value="dataSet" )
+ @JacksonXmlProperty( localName="dataSet", isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
public String getDataSetIdentifier()
{
return dataSetIdentifier;
@@ -97,6 +94,8 @@
this.dataSetIdentifier = dataSetId;
}
+ @JsonProperty( value="orgUnit" )
+ @JacksonXmlProperty( localName="orgUnit", isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
public String getOrganisationUnitIdentifier()
{
return organisationUnitIdentifier;
@@ -107,6 +106,8 @@
this.organisationUnitIdentifier = organisationUnitId;
}
+ @JsonProperty( value="period" )
+ @JacksonXmlProperty( localName="period", isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
public String getPeriodIsoDate()
{
return periodIsoDate;
@@ -117,6 +118,8 @@
this.periodIsoDate = periodIsoDate;
}
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
public String getCompleteDate()
{
return completeDate;
@@ -127,6 +130,9 @@
this.completeDate = completeDate;
}
+ @JsonProperty
+ @JacksonXmlElementWrapper( localName = "dataValues", namespace = Dxf2Namespace.NAMESPACE )
+ @JacksonXmlProperty( localName = "dataValue", namespace = Dxf2Namespace.NAMESPACE )
public List<DataValue> getDataValues()
{
return dataValues;
=== renamed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetService.java' => 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetService.java 2012-03-12 20:25:54 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java 2012-03-28 16:04:53 +0000
@@ -1,4 +1,4 @@
-package org.hisp.dhis.importexport.dxf2.service;
+package org.hisp.dhis.dxf2.datavalueset;
/*
* Copyright (c) 2004-2005, University of Oslo
@@ -27,7 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
public interface DataValueSetService
{
=== renamed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/DataValueSets.java' => 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSets.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/DataValueSets.java 2012-03-22 15:04:58 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSets.java 2012-03-28 16:04:53 +0000
@@ -1,4 +1,4 @@
-package org.hisp.dhis.api.webdomain;
+package org.hisp.dhis.dxf2.datavalueset;
/*
* Copyright (c) 2004-2012, University of Oslo
@@ -32,7 +32,6 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
import java.util.ArrayList;
import java.util.List;
=== renamed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DefaultDataValueSetService.java' => 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DefaultDataValueSetService.java 2012-03-19 16:48:19 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-03-28 16:04:53 +0000
@@ -1,4 +1,4 @@
-package org.hisp.dhis.importexport.dxf2.service;
+package org.hisp.dhis.dxf2.datavalueset;
/*
* Copyright (c) 2011, University of Oslo
@@ -45,8 +45,7 @@
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
-import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
-import org.hisp.dhis.importexport.dxf2.model.DataValueSet.IdentificationStrategy;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSet.IdentificationStrategy;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.DailyPeriodType;
@@ -149,7 +148,7 @@
handleComplete( dataValueSet, dataSet, unit, period );
- for ( org.hisp.dhis.importexport.dxf2.model.DataValue dxfValue : dataValueSet.getDataValues() )
+ for ( org.hisp.dhis.dxf2.datavalue.DataValue dxfValue : dataValueSet.getDataValues() )
{
saveDataValue( timestamp, dataSet, unit, period, dxfValue );
}
@@ -162,9 +161,9 @@
String message = "Saved data value set for " + dataSet.getName() + ", " + unit.getName() + ", "
+ dataValueSet.getPeriodIsoDate() + " - data values received: ";
- for ( org.hisp.dhis.importexport.dxf2.model.DataValue value : dataValueSet.getDataValues() )
+ for ( org.hisp.dhis.dxf2.datavalue.DataValue value : dataValueSet.getDataValues() )
{
- message += value.getDataElementIdentifier() + " = " + value.getValue() + ", ";
+ message += value.getDataElement() + " = " + value.getValue() + ", ";
}
log.info( message.substring( 0, message.length() - 3 ) );
@@ -202,9 +201,9 @@
Set<DataSet> potentialDataSets = new HashSet<DataSet>();
- for ( org.hisp.dhis.importexport.dxf2.model.DataValue value : dataValueSet.getDataValues() )
+ for ( org.hisp.dhis.dxf2.datavalue.DataValue value : dataValueSet.getDataValues() )
{
- DataElement dataElement = getDataElement( value.getDataElementIdentifier() );
+ DataElement dataElement = getDataElement( value.getDataElement() );
Set<DataSet> dataSets = dataElement.getDataSets();
if ( dataSets == null || dataSets.isEmpty() )
@@ -234,9 +233,9 @@
}
private void saveDataValue( Date timestamp, DataSet dataSet, OrganisationUnit unit, Period period,
- org.hisp.dhis.importexport.dxf2.model.DataValue dxfValue )
+ org.hisp.dhis.dxf2.datavalue.DataValue dxfValue )
{
- DataElement dataElement = getDataElement( dxfValue.getDataElementIdentifier() );
+ DataElement dataElement = getDataElement( dxfValue.getDataElement() );
if ( !dataSet.getDataElements().contains( dataElement ) )
{
@@ -244,7 +243,7 @@
+ dataSet.getUid() );
}
- DataElementCategoryOptionCombo combo = getOptionCombo( dxfValue.getCategoryOptionComboIdentifier(), dataElement );
+ DataElementCategoryOptionCombo combo = getOptionCombo( dxfValue.getCategoryOptionCombo(), dataElement );
DataValue dv = dataValueService.getDataValue( unit, dataElement, period, combo );
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java 2012-03-22 15:24:25 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java 2012-03-28 16:04:53 +0000
@@ -130,6 +130,7 @@
return jsonMapper.writerWithView( viewClass ).writeValueAsString( value );
}
+ @SuppressWarnings("unchecked")
public static <T> T fromJson( InputStream input, Class<?> clazz ) throws IOException
{
return (T) jsonMapper.readValue( input, clazz );
@@ -159,6 +160,7 @@
return xmlMapper.writerWithView( viewClass ).writeValueAsString( value );
}
+ @SuppressWarnings("unchecked")
public static <T> T fromXml( InputStream input, Class<?> clazz ) throws IOException
{
return (T) xmlMapper.readValue( input, clazz );
=== added directory 'dhis-2/dhis-dxf2/src/main/resources'
=== added directory 'dhis-2/dhis-dxf2/src/main/resources/META-INF'
=== added directory 'dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis'
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-dxf2/src/main/resources/META-INF/dhis/beans.xml 2012-03-28 16:04:53 +0000
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
+
+ <bean id="org.hisp.dhis.dxf2.datavalueset.DataValueSetService" class="org.hisp.dhis.dxf2.datavalueset.DefaultDataValueSetService">
+ <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+ <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
+ <property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+ </bean>
+
+</beans>
=== removed directory 'dhis-2/dhis-dxf2/src/test/java/org'
=== removed directory 'dhis-2/dhis-dxf2/src/test/java/org/hisp'
=== removed directory 'dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis'
=== removed directory 'dhis-2/dhis-dxf2/src/test/java/org/hisp/dhis/dxf2'
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/pom.xml'
--- dhis-2/dhis-services/dhis-service-importexport/pom.xml 2012-02-20 12:01:56 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/pom.xml 2012-03-28 16:04:53 +0000
@@ -23,6 +23,10 @@
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-dxf2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-core</artifactId>
</dependency>
<dependency>
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java 2012-03-12 20:25:54 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java 2012-03-28 16:04:53 +0000
@@ -48,7 +48,6 @@
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.ProcessState;
import org.hisp.dhis.importexport.dxf.converter.DXFConverter;
-import org.hisp.dhis.importexport.dxf2.service.DataValueImportService;
import org.hisp.dhis.importexport.xml.XMLPreConverter;
import org.hisp.dhis.importexport.zip.ZipAnalyzer;
import org.hisp.dhis.system.process.OutputHolderState;
@@ -83,13 +82,6 @@
this.converter = converter;
}
- private DataValueImportService dxf2converter;
-
- public void setDxf2converter( DataValueImportService dxf2converter )
- {
- this.dxf2converter = dxf2converter;
- }
-
// -------------------------------------------------------------------------
// ImportService implementation
// -------------------------------------------------------------------------
@@ -190,13 +182,8 @@
}
- if (rootNameSpace.equals( DXF2URI )) {
- log.debug( "Sending DXFv2 to converter" );
- dxf2converter.read( dxfReader, params, state );
- } else {
- log.debug( "Sending DXFv1 to converter" );
- converter.read( dxfReader, params, state );
- }
+ log.debug( "Sending DXFv1 to converter" );
+ converter.read( dxfReader, params, state );
}
catch ( IOException ex )
{
=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2'
=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model'
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataValue.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataValue.java 2012-02-13 15:21:51 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/DataValue.java 1970-01-01 00:00:00 +0000
@@ -1,128 +0,0 @@
-package org.hisp.dhis.importexport.dxf2.model;
-
-/*
- * Copyright (c) 2011, 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.util.HashMap;
-import java.util.Map;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAnyAttribute;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.namespace.QName;
-
-@XmlAccessorType( XmlAccessType.FIELD )
-public class DataValue
-{
- // ---------------------------------------------------------------------------
- // Element and attribute names
- // ---------------------------------------------------------------------------
-
- public static final String ATTR_DATAELEMENT = "dataElement";
- public static final String ATTR_VALUE = "value";
- public static final String ATTR_CATEGORY_OPTION_COMBO = "categoryOptionCombo";
- public static final String ATTR_ORGUNIT = "orgUnit";
-
- @XmlAttribute( name = ATTR_DATAELEMENT, required = true )
- private String dataElementIdentifier;
-
- @XmlAttribute( name = ATTR_VALUE, required = true)
- private String value;
-
- /**
- * optional - defaults to default
- */
- @XmlAttribute( name = ATTR_CATEGORY_OPTION_COMBO )
- private String categoryOptionComboIdentifier;
-
- /**
- * optional - defaults to orgUnit id from datavalueset
- */
- @XmlAttribute( name = ATTR_ORGUNIT )
- private String organisationUnitIdentifier;
-
- /**
- * Arbitrary attributes identifying dimensions by concept name
- */
- @XmlAnyAttribute
- private Map<QName,Object> dimensions;
-
- public String getDataElementIdentifier()
- {
- return dataElementIdentifier;
- }
-
- public void setDataElementIdentifier( String dataElementId )
- {
- this.dataElementIdentifier = dataElementId;
- }
-
- public String getCategoryOptionComboIdentifier()
- {
- return categoryOptionComboIdentifier;
- }
-
- public void setCategoryOptionComboIdentifier( String categoryOptionComboId )
- {
- this.categoryOptionComboIdentifier = categoryOptionComboId;
- }
-
- public String getOrganisationUnitIdentifier()
- {
- return organisationUnitIdentifier;
- }
-
- public void setOrganisationUnitIdentifier( String organisationUnitIdentifier )
- {
- this.organisationUnitIdentifier = organisationUnitIdentifier;
- }
-
- public Map<QName, Object> getDimensions()
- {
- if ( dimensions == null )
- {
- dimensions = new HashMap<QName,Object>();
- }
-
- return dimensions;
- }
-
- public void setDimensions( Map<QName, Object> dimensions )
- {
- this.dimensions = dimensions;
- }
-
- public String getValue()
- {
- return value;
- }
-
- public void setValue( String value )
- {
- this.value = value;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/package-info.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/package-info.java 2011-12-06 13:20:18 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/model/package-info.java 1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
-@XmlSchema(
- namespace = "http://dhis2.org/schema/dxf/2.0",
- xmlns = {
- @XmlNs(namespaceURI = "http://dhis2.org/schema/dxf/2.0", prefix = "d")
- },
- elementFormDefault = XmlNsForm.QUALIFIED)
-
-
-package org.hisp.dhis.importexport.dxf2.model;
-
-import javax.xml.bind.annotation.XmlSchema;
-import javax.xml.bind.annotation.XmlNs;
-import javax.xml.bind.annotation.XmlNsForm;
-
-/*
- * Copyright (c) 2011, 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.
- */
=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service'
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueImportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueImportService.java 2012-03-12 20:25:54 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/DataValueImportService.java 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
-package org.hisp.dhis.importexport.dxf2.service;
-
-/*
- * Copyright (c) 2004-2005, 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 <ORGANIZATION> 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.amplecode.staxwax.reader.XMLReader;
-import org.hisp.dhis.common.ProcessState;
-import org.hisp.dhis.importexport.ImportParams;
-
-public interface DataValueImportService
-{
- void read( XMLReader reader, ImportParams params, ProcessState state );
-}
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/StaXDataValueImportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/StaXDataValueImportService.java 2012-03-12 20:25:54 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf2/service/StaXDataValueImportService.java 1970-01-01 00:00:00 +0000
@@ -1,506 +0,0 @@
-package org.hisp.dhis.importexport.dxf2.service;
-
-/*
- * Copyright (c) 2004-2005, 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 <ORGANIZATION> 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 static org.apache.commons.lang.StringUtils.defaultIfEmpty;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.amplecode.quick.BatchHandler;
-import org.amplecode.quick.BatchHandlerFactory;
-import org.amplecode.staxwax.reader.XMLReader;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.aggregation.AggregatedDataValueService;
-import org.hisp.dhis.common.ProcessState;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.importexport.ImportException;
-import org.hisp.dhis.importexport.ImportParams;
-import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
-import org.hisp.dhis.importexport.importer.DataValueImporter;
-import org.hisp.dhis.jdbc.batchhandler.DataValueBatchHandler;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.user.CurrentUserService;
-
-/**
- * Really basic DXF2 class for reading data
- *
- * @author bobj
- */
-public class StaXDataValueImportService
- implements DataValueImportService
-{
- private static final Log log = LogFactory.getLog( StaXDataValueImportService.class );
-
- // -------------------------------------------------------------------------
- // Status/Log messages
- // TODO: internationalise these
- // -------------------------------------------------------------------------
-
- public static final String NO_DATAVALUESETS = "There are no datasets in this message";
-
- public static final String IMPORTING_DATAVALUES = "Importing data values";
-
- public static final String INVALID_PERIOD = "Invalid period : %s";
-
- public static final String NO_SUCH_ORGUNIT = "No such orgunit : %s = %s";
-
- public static final String NO_SUCH_DATAELEMENT = "No such dataElement : %s = %s";
-
- public static final String NO_ROOT = "Couldn't find dxf root element";
-
- public static final String UNKNOWN_ID_STRATEGY = "Unknown id strategy = %s";
-
- public static final String SUCCESS = "DataValue import complete";
-
- public static final String COUNTER = "%s DataValues imported";
-
- public static final int DISPLAYCOUNT = 1000;
-
- public static final String NAMESPACE_20 = "http://dhis2.org/schema/dxf/2.0";
-
- public static final String DXFROOT = "dxf";
-
- public static final String ATTRIBUTE_MINOR_VERSION = "minorVersion";
-
- public static final String ATTRIBUTE_EXPORTED = "exported";
-
- public static final String DATAVALUESETS = "dataValueSets";
-
- public static final String DATAVALUESET = "dataValueSet";
-
- public static final String MINOR_VERSION_10 = "1.0";
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private CurrentUserService currentUserService;
-
- public void setCurrentUserService( CurrentUserService currentUserService )
- {
- this.currentUserService = currentUserService;
- }
-
- private AggregatedDataValueService aggregatedDataValueService;
-
- public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService )
- {
- this.aggregatedDataValueService = aggregatedDataValueService;
- }
-
- private DataSetService dataSetService;
-
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
- private DataElementService dataElementService;
-
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
- private DataElementCategoryService categoryService;
-
- public void setCategoryService( DataElementCategoryService categoryService )
- {
- this.categoryService = categoryService;
- }
-
- private OrganisationUnitService organisationUnitService;
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
- private PeriodService periodService;
-
- public void setPeriodService( PeriodService periodService )
- {
- this.periodService = periodService;
- }
-
- private BatchHandlerFactory batchHandlerFactory;
-
- public void setBatchHandlerFactory( BatchHandlerFactory batchHandlerFactory )
- {
- this.batchHandlerFactory = batchHandlerFactory;
- }
-
- public void read( XMLReader reader, ImportParams params, ProcessState state )
- {
- String user = currentUserService.getCurrentUsername();
-
- BatchHandler<DataValue> batchHandler = batchHandlerFactory.createBatchHandler(
- DataValueBatchHandler.class ).init();
-
- DataValueImporter importer =
- new DataValueImporter(batchHandler, aggregatedDataValueService, params);
-
- int cumulativeDataValueCounter = 0;
-
- try
- {
- if ( !reader.moveToStartElement( DXFROOT, DXFROOT ) )
- {
- throw new ImportException( NO_ROOT );
- }
-
- QName rootName = reader.getElementQName();
-
- params.setNamespace( defaultIfEmpty( rootName.getNamespaceURI(), NAMESPACE_20 ) );
- String version = reader.getAttributeValue( ATTRIBUTE_MINOR_VERSION );
- params.setMinorVersion( version != null ? version : MINOR_VERSION_10 );
-
- log.debug( String.format( "Importing %s minor version %s", rootName.getNamespaceURI(), version ) );
-
- // move straight to the DataValue sets, we are not looking for metadata
- reader.moveToStartElement( DATAVALUESETS );
-
- Date timestamp = new Date();
-
- if ( !reader.isStartElement( DATAVALUESETS ) )
- {
- throw new ImportException( NO_DATAVALUESETS );
- }
-
- // Outer loop, process datavaluesets until no more datavaluesets
- int countDataValueSets = 0;
-
- do
- {
- // look for a DataValue set
- if ( !reader.isStartElement( DATAVALUESET ) )
- {
- try
- {
- reader.moveToStartElement( DATAVALUESET );
- }
- catch ( java.util.NoSuchElementException ex )
- {
- // we have to reach here eventuallyperiodId
- break;
- }
- }
-
- // Pick off the attributes
- String idSchemeStr = reader.getAttributeValue( DataValueSet.ATTR_IDSCHEME );
- String dataSet = reader.getAttributeValue( DataValueSet.ATTR_DATASET );
- String period = reader.getAttributeValue( DataValueSet.ATTR_PERIOD );
- String outerOrgunit = reader.getAttributeValue( DataValueSet.ATTR_ORGUNIT );
- String comment = reader.getAttributeValue( DataValueSet.ATTR_COMMENT );
-
- log.debug( String.format(
- "Importing datavalueset (%s): period %s : orgunit %s : idscheme : %s",
- comment, period, outerOrgunit, idSchemeStr ) );
-
- // Determine identifier scheme to use
-
- DataValueSet.IdentificationStrategy idScheme = DataValueSet.DEFAULT_STRATEGY;
-
- if ( idSchemeStr != null )
- {
- try
- {
- idScheme = DataValueSet.IdentificationStrategy.valueOf( idSchemeStr );
- }
- catch ( IllegalArgumentException ex )
- {
- throw new ImportException( String.format( UNKNOWN_ID_STRATEGY, idSchemeStr ) );
- }
- }
-
- Period outerPeriod = getPeriodObj( period );
-
- // maps for translating identifiers
- Map<String, Integer> dataelementMap = null;
- Map<String, Integer> orgunitMap = null;
-
- // get map for translating dataelement identifiers
- dataelementMap = getDataElementMap( dataSet, idScheme );
-
- Integer outerOrgunitId = null;
- // if orgunit defined at datavalueset level, use it
- if ( outerOrgunit != null )
- {
- outerOrgunitId = getOrgUnitByIdentifier( outerOrgunit, idScheme ).getId();
- } else
- {
- // get map for translating orgunit identifiers
- orgunitMap = getOrgUnitMap( dataSet, idScheme );
- }
-
- // only supporting default optioncombo at present
- DataElementCategoryOptionCombo optioncombo =
- categoryService.getDefaultDataElementCategoryOptionCombo();
-
- int countDataValues = 0;
- // process datavalues - loop until no more datavalues
-
- do
- {
- // look for a DataValue
- reader.moveToStartElement();
-
- if ( !reader.isStartElement( DataValueSet.DATAVALUE ) )
- {
- // we have to reach here eventually
- break;
- }
-
- log.debug( "Reading Datavalue" );
-
- String dataElementId = reader.getAttributeValue(
- org.hisp.dhis.importexport.dxf2.model.DataValue.ATTR_DATAELEMENT );
- String innerOrgUnitId = reader.getAttributeValue(
- org.hisp.dhis.importexport.dxf2.model.DataValue.ATTR_ORGUNIT );
- String value = reader.getAttributeValue(
- org.hisp.dhis.importexport.dxf2.model.DataValue.ATTR_VALUE );
-
- DataValue dv = new DataValue();
- dv.setPeriod( outerPeriod );
- dv.setValue( value );
- // populate with placeholders
- dv.setDataElement( new DataElement() );
- dv.setSource( new OrganisationUnit() );
- dv.setOptionCombo( optioncombo );
- dv.setComment( comment );
- dv.setStoredBy( user );
- dv.setTimestamp( timestamp );
-
- // if no outer orgunit defined, use the map
- if ( outerOrgunit == null )
- {
- Integer id = orgunitMap.get( innerOrgUnitId );
- if ( id == null )
- {
- log.info( "Unknown orgunit: " + innerOrgUnitId + " Rejecting value");
- continue;
- }
- dv.getSource().setId( orgunitMap.get( innerOrgUnitId ) );
-
- }
- else
- {
- dv.getSource().setId( outerOrgunitId );
- }
-
- dv.getDataElement().setId( dataelementMap.get( dataElementId ) );
-
- importer.importObject(dv,params);
-
- ++countDataValues;
- ++cumulativeDataValueCounter;
-
- if (countDataValues % DISPLAYCOUNT == 0) {
- state.setMessage( String.format(COUNTER,cumulativeDataValueCounter));
- }
-
- log.debug( cumulativeDataValueCounter + " DataValues read" );
-
- } while ( true ); // DataValues loop
-
- ++countDataValueSets;
- log.debug( countDataValueSets + " DataValueSets read" );
-
- } while ( true ); // DataValueSets loop
-
- log.info( String.format(COUNTER,cumulativeDataValueCounter));
- state.setMessage( String.format(COUNTER,cumulativeDataValueCounter));
-
- }
- catch ( ImportException ex )
- {
- log.warn( ex.toString() );
- state.setMessage( ex.toString() );
- }
- finally
- {
- batchHandler.flush();
- }
- }
-
- private Period getPeriodObj( String period )
- throws ImportException
- {
- Period periodObj;
-
- PeriodType pt = PeriodType.getPeriodTypeFromIsoString( period );
-
- if ( pt == null )
- {
- throw new ImportException( String.format( INVALID_PERIOD, period ) );
- }
-
- try
- {
- periodObj = pt.createPeriod( period );
-
- } catch ( Exception e )
- {
- throw new ImportException( String.format( INVALID_PERIOD, period ) );
- }
-
- Period storedPeriod = periodService.getPeriod( periodObj.getStartDate(), periodObj.getEndDate(), pt );
-
- if ( storedPeriod == null )
- {
- int periodId = periodService.addPeriod( periodObj );
-
- periodObj.setId( periodId );
-
- } else
- {
- periodObj = storedPeriod;
- }
-
- return periodObj;
- }
-
- private Map<String, Integer> getDataElementMap( String dataSet, DataValueSet.IdentificationStrategy idScheme )
- {
- Collection<DataElement> dataelements;
- Map<String, Integer> result = null;
-
- if ( dataSet != null )
- {
- DataSet ds = getDataSet( dataSet, idScheme );
- dataelements = ds.getDataElements();
- } else
- {
- dataelements = dataElementService.getAllDataElements();
- }
- switch ( idScheme )
- {
- case CODE:
- result = DataElement.getCodeMap( dataelements );
- break;
- case INTERNAL:
- break;
- default:
- throw new IllegalArgumentException( "Can't map with :" + idScheme );
- }
- return result;
- }
-
- private Map<String, Integer> getOrgUnitMap( String dataSet, DataValueSet.IdentificationStrategy idScheme )
- {
- Collection<OrganisationUnit> orgunits;
- Map<String, Integer> result = null;
-
- if ( dataSet != null )
- {
- DataSet ds = getDataSet( dataSet, idScheme );
- orgunits = ds.getSources();
- } else
- {
- orgunits = organisationUnitService.getAllOrganisationUnits();
- }
-
- switch ( idScheme )
- {
- case CODE:
- result = OrganisationUnit.getCodeMap( orgunits );
- break;
- case INTERNAL:
- break;
- default:
- throw new IllegalArgumentException( "Can't map with :" + idScheme );
- }
- log.debug( result.size() + " orgunits in map" );
- return result;
- }
-
- /**
- * For a given orgunit identifier and id scheme, returns the orgunit object reference
- * @param orgunit
- * @param idScheme
- * @return
- * @throws ImportException thrown if no orgunit matches
- */
- private OrganisationUnit getOrgUnitByIdentifier( String orgunit, DataValueSet.IdentificationStrategy idScheme )
- throws ImportException
- {
- OrganisationUnit ou;
- switch ( idScheme )
- {
- case UID:
- ou = organisationUnitService.getOrganisationUnit( orgunit );
- break;
- case CODE:
- ou = organisationUnitService.getOrganisationUnitByCode( orgunit );
- break;
- case INTERNAL:
- ou = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgunit ) );
- break;
- default:
- throw new IllegalArgumentException( "Can't map with :" + idScheme );
- }
-
- if ( ou == null )
- {
- throw new ImportException( String.format( NO_SUCH_ORGUNIT, idScheme, orgunit ) );
- }
- return ou;
- }
-
- private DataSet getDataSet( String dataSet, DataValueSet.IdentificationStrategy idScheme )
- {
- DataSet result = null;
- switch ( idScheme )
- {
- case INTERNAL:
- result = dataSetService.getDataSet( Integer.parseInt( dataSet ) );
- break;
- case CODE:
- result = dataSetService.getDataSetByCode( dataSet );
- break;
- default:
- result = dataSetService.getDataSet( dataSet );
- }
- return result;
- }
-}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml 2012-03-12 20:25:54 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml 2012-03-28 16:04:53 +0000
@@ -217,20 +217,8 @@
<property name="cacheManager" ref="cacheManager" />
</bean>
- <bean id="dxfv2StaXImporter" class="org.hisp.dhis.importexport.dxf2.service.StaXDataValueImportService">
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
- <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
- <property name="batchHandlerFactory" ref="batchHandlerFactory" />
- <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
- <property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />
- </bean>
-
<bean id="org.hisp.dhis.importexport.ImportService" class="org.hisp.dhis.importexport.DefaultImportService">
<property name="converter" ref="dxfv1-Converter" />
- <property name="dxf2converter" ref="dxfv2StaXImporter" />
<property name="preConverter" ref="preConverter" />
</bean>
@@ -334,14 +322,4 @@
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
</bean>
- <bean id="org.hisp.dhis.importexport.dxf2.service.DataValueSetService" class="org.hisp.dhis.importexport.dxf2.service.DefaultDataValueSetService">
- <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
- <property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
- <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
- </bean>
-
</beans>
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetServiceTest.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetServiceTest.java 2011-11-22 15:48:30 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf2/service/DataValueSetServiceTest.java 2012-03-28 16:04:53 +0000
@@ -37,12 +37,10 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
-import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
-import javax.xml.namespace.QName;
import org.hisp.dhis.DhisTest;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -53,11 +51,12 @@
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSet;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
import org.hisp.dhis.importexport.ImportException;
import org.hisp.dhis.importexport.ImportParams;
import org.hisp.dhis.importexport.ImportService;
import org.hisp.dhis.importexport.ImportStrategy;
-import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
import org.hisp.dhis.importexport.util.ImportExportUtils;
import org.hisp.dhis.period.WeeklyPeriodType;
import org.junit.Ignore;
@@ -121,11 +120,11 @@
dataValueSet.setPeriodIsoDate( "2011W5" );
dataValueSet.setOrganisationUnitIdentifier( ORGANISATION_UNIT_UUID );
- final org.hisp.dhis.importexport.dxf2.model.DataValue dv = new org.hisp.dhis.importexport.dxf2.model.DataValue();
- dv.setDataElementIdentifier( DATA_ELEMENT_UUID );
+ final org.hisp.dhis.dxf2.datavalue.DataValue dv = new org.hisp.dhis.dxf2.datavalue.DataValue();
+ dv.setDataElement( DATA_ELEMENT_UUID );
dv.setValue( "11" );
- dataValueSet.setDataValues( new ArrayList<org.hisp.dhis.importexport.dxf2.model.DataValue>()
+ dataValueSet.setDataValues( new ArrayList<org.hisp.dhis.dxf2.datavalue.DataValue>()
{
{
add( dv );
@@ -145,7 +144,7 @@
throws JAXBException, IOException
{
JAXBContext jc = JAXBContext.newInstance( DataValueSet.class,
- org.hisp.dhis.importexport.dxf2.model.DataValue.class );
+ org.hisp.dhis.dxf2.datavalue.DataValue.class );
Unmarshaller u = jc.createUnmarshaller();
InputStream is = classLoader.getResourceAsStream( "dxf2/dataValueSet.xml" );
@@ -158,44 +157,12 @@
assertEquals( 1, dxfDataValueSet.getDataValues().size() );
- org.hisp.dhis.importexport.dxf2.model.DataValue dv = dxfDataValueSet.getDataValues().get( 0 );
- org.hisp.dhis.importexport.dxf2.model.DataValue dataValue = dataValueSet.getDataValues().get( 0 );
-
- assertEquals( dataValue.getDataElementIdentifier(), dv.getDataElementIdentifier() );
-
- assertNull( dv.getCategoryOptionComboIdentifier() );
-
- }
-
- @Test
- @Ignore
- public void testJaxbDimensions()
- throws JAXBException, IOException
- {
- JAXBContext jc = JAXBContext.newInstance( DataValueSet.class,
- org.hisp.dhis.importexport.dxf2.model.DataValue.class );
- Unmarshaller u = jc.createUnmarshaller();
- InputStream is = classLoader.getResourceAsStream( "dxf2/dataValueSet_dim.xml" );
-
- DataValueSet dxfDataValueSet = (DataValueSet) u.unmarshal( is );
- is.close();
-
- assertEquals( "internal", dxfDataValueSet.getIdScheme() );
-
- assertEquals( 1, dxfDataValueSet.getDataValues().size() );
-
- org.hisp.dhis.importexport.dxf2.model.DataValue dv = dxfDataValueSet.getDataValues().get( 0 );
-
- Map<QName,Object> dimensions = dv.getDimensions();
- assertEquals( 2, dimensions.size() );
-
- QName sex = new QName("sex");
- QName age = new QName("age");
-
- assertTrue(dimensions.containsKey( sex ));
- assertTrue(dimensions.containsKey( age));
- assertEquals("1", dimensions.get( sex ));
- assertEquals("2", dimensions.get( age ));
+ org.hisp.dhis.dxf2.datavalue.DataValue dv = dxfDataValueSet.getDataValues().get( 0 );
+ org.hisp.dhis.dxf2.datavalue.DataValue dataValue = dataValueSet.getDataValues().get( 0 );
+
+ assertEquals( dataValue.getDataElement(), dv.getDataElement() );
+
+ assertNull( dv.getCategoryOptionCombo() );
}
@@ -403,9 +370,8 @@
@Test
public void elementExistsAndNotInSet()
{
-
- org.hisp.dhis.importexport.dxf2.model.DataValue dv = new org.hisp.dhis.importexport.dxf2.model.DataValue();
- dv.setDataElementIdentifier( "ladida" );
+ org.hisp.dhis.dxf2.datavalue.DataValue dv = new org.hisp.dhis.dxf2.datavalue.DataValue();
+ dv.setDataElement( "ladida" );
dv.setValue( "11" );
dataValueSet.getDataValues().add( dv );
@@ -419,7 +385,7 @@
// Expected
}
- dv.setDataElementIdentifier( DATA_ELEMENT_NOT_IN_SET_UUID );
+ dv.setDataElement( DATA_ELEMENT_NOT_IN_SET_UUID );
try
{
@@ -436,11 +402,11 @@
public void optionComboExistsAndInDataElement()
{
- dataValueSet.getDataValues().get( 0 ).setCategoryOptionComboIdentifier( DEFAULT_COMBO_UUID );
+ dataValueSet.getDataValues().get( 0 ).setCategoryOptionCombo( DEFAULT_COMBO_UUID );
service.saveDataValueSet( dataValueSet );
- dataValueSet.getDataValues().get( 0 ).setCategoryOptionComboIdentifier( "AAB2299E-ECD6-46CF-A61F-817D350" );
+ dataValueSet.getDataValues().get( 0 ).setCategoryOptionCombo( "AAB2299E-ECD6-46CF-A61F-817D350" );
try
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2012-03-22 15:04:58 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2012-03-28 16:04:53 +0000
@@ -27,23 +27,26 @@
* 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.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.api.webdomain.DataValueSets;
-import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
-import org.hisp.dhis.importexport.dxf2.service.DataValueSetService;
+import org.hisp.dhis.api.utils.ContextUtils;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSet;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSetService;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSets;
+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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
@Controller
@RequestMapping( value = DataValueSetController.RESOURCE_PATH )
public class DataValueSetController
@@ -65,15 +68,20 @@
return "dataValueSets";
}
-
- @RequestMapping( method = RequestMethod.POST )
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml"} )
@PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_ADD')" )
- public void storeDataValueSet( @RequestBody DataValueSet dataValueSet )
+ public void postDataValueSet( HttpServletResponse response, InputStream input )
+ throws IOException
{
+ DataValueSet dataValueSet = JacksonUtils.fromXml( input, DataValueSet.class );
+
dataValueSetService.saveDataValueSet( dataValueSet );
log.debug( "Saved data value set for data set: " + dataValueSet.getDataSetIdentifier() +
", org unit: " + dataValueSet.getOrganisationUnitIdentifier() + ", period: " + dataValueSet.getPeriodIsoDate() );
+
+ ContextUtils.okResponse( response, "Saved data value set succesfully" );
}
@ExceptionHandler( IllegalArgumentException.class )
@@ -82,4 +90,31 @@
{
response.sendError( HttpServletResponse.SC_CONFLICT, ex.getMessage() );
}
+
+ /*
+ @RequestMapping( value = "/test", method = RequestMethod.GET )
+ public String getDataValueSetTest( Model model ) throws Exception
+ {
+ DataValueSets dataValueSets = new DataValueSets();
+
+ DataValue v1 = new DataValue();
+ v1.setDataElement( "de" );
+ v1.setValue( "va" );
+
+ DataValue v2 = new DataValue();
+ v2.setDataElement( "de" );
+ v2.setValue( "va" );
+
+ DataValueSet d = new DataValueSet();
+ d.setDataSetIdentifier( "ds" );
+ d.setOrganisationUnitIdentifier( "ou" );
+ d.setPeriodIsoDate( "pe" );
+ d.getDataValues().add( v1 );
+ d.getDataValues().add( v2 );
+ dataValueSets.getDataValueSets().add( d );
+
+ model.addAttribute( "model", dataValueSets );
+
+ return "dataValueSets";
+ }*/
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java 2012-03-12 12:33:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java 2012-03-28 16:04:53 +0000
@@ -133,4 +133,15 @@
writer.println( message );
writer.flush();
}
+
+ public static void okResponse( HttpServletResponse response, String message )
+ throws IOException
+ {
+ response.setStatus( HttpServletResponse.SC_OK );
+ response.setContentType( CONTENT_TYPE_TEXT );
+
+ PrintWriter writer = response.getWriter();
+ writer.println( message );
+ writer.flush();
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java 2012-03-28 07:40:14 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java 2012-03-28 16:04:53 +0000
@@ -39,6 +39,7 @@
import org.hisp.dhis.dataelement.*;
import org.hisp.dhis.dataset.DataSets;
import org.hisp.dhis.document.Documents;
+import org.hisp.dhis.dxf2.datavalueset.DataValueSets;
import org.hisp.dhis.indicator.IndicatorGroupSets;
import org.hisp.dhis.indicator.IndicatorGroups;
import org.hisp.dhis.indicator.IndicatorTypes;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl 2012-03-21 09:12:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl 2012-03-28 16:04:53 +0000
@@ -27,9 +27,11 @@
<pre style="font-size:12pt;">
<![CDATA[
<dataValueSet xmlns="http://dhis2.org/schema/dxf/2.0" period="periodISODate" dataSet="dataSetID" orgUnit="orgUnitID">
- <dataValue dataElement="dataElementID" categoryOptionCombo="categoryOptionComboID" value="1" />
- <dataValue dataElement="dataElementID" categoryOptionCombo="categoryOptionComboID" value="2" />
- <dataValue dataElement="dataElementID" categoryOptionCombo="categoryOptionComboID" value="3" />
+ <dataValues>
+ <dataValue dataElement="dataElementID" categoryOptionCombo="categoryOptionComboID" value="1" />
+ <dataValue dataElement="dataElementID" categoryOptionCombo="categoryOptionComboID" value="2" />
+ <dataValue dataElement="dataElementID" categoryOptionCombo="categoryOptionComboID" value="3" />
+ </dataValues>
</dataValueSet>
]]>
</pre>