dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10447
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2863: - Reworked data value api into an even less stable prototype of a dxf style "universal" data format.
------------------------------------------------------------
revno: 2863
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-02-17 13:55:53 +0530
message:
- Reworked data value api into an even less stable prototype of a dxf style "universal" data format.
- Fixed type on method in DataSet
added:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/Dxf.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValue.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValueSet.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValueSetService.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/package-info.java
dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/datavalueset/DataValueSetServiceTest.java
dhis-2/dhis-services/dhis-service-importexport/src/test/resources/datavalueset/dataValueSet.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/rpc/RPCResource.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/MergeAssignedOrgunitsAction.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-api/src/main/java/org/hisp/dhis/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2011-01-06 13:41:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2011-02-17 08:25:53 +0000
@@ -286,7 +286,7 @@
return mobile;
}
- public Set<OrganisationUnit> getOrganisationUnis()
+ public Set<OrganisationUnit> getOrganisationUnits()
{
Set<OrganisationUnit> result = new HashSet<OrganisationUnit>();
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValue.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValue.java 2011-02-16 17:16:18 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValue.java 2011-02-17 08:25:53 +0000
@@ -35,6 +35,15 @@
public class DataValue
{
+ @XmlAttribute( name = "dataSet" )
+ private String dataSetUuid;
+
+ @XmlAttribute( name = "orgUnit", required = true )
+ private String organisationUnitUuid;
+
+ @XmlAttribute( name = "period", required = true )
+ private String periodIsoDate;
+
@XmlAttribute( name = "dataElement", required = true )
private String dataElementUuid;
@@ -47,6 +56,36 @@
@XmlAttribute
private String value;
+ public String getDataSetUuid()
+ {
+ return dataSetUuid;
+ }
+
+ public void setDataSetUuid( String dataSetUuid )
+ {
+ this.dataSetUuid = dataSetUuid;
+ }
+
+ public String getOrganisationUnitUuid()
+ {
+ return organisationUnitUuid;
+ }
+
+ public void setOrganisationUnitUuid( String organisationUnitUuid )
+ {
+ this.organisationUnitUuid = organisationUnitUuid;
+ }
+
+ public String getPeriodIsoDate()
+ {
+ return periodIsoDate;
+ }
+
+ public void setPeriodIsoDate( String periodIsoDate )
+ {
+ this.periodIsoDate = periodIsoDate;
+ }
+
public String getDataElementUuid()
{
return dataElementUuid;
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValueSet.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValueSet.java 2011-02-16 17:16:18 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValueSet.java 2011-02-17 08:25:53 +0000
@@ -27,21 +27,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Date;
-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;
@XmlAccessorType( XmlAccessType.FIELD )
-@XmlRootElement
public class DataValueSet
{
- @XmlAttribute( name = "dataSet", required = true )
+ @XmlAttribute( name = "dataSet" )
private String dataSetUuid;
@XmlAttribute( name = "orgUnit", required = true )
@@ -53,10 +47,6 @@
@XmlAttribute( name = "complete" )
private String completeDate;
- @XmlElement( name = "dataValue" )
- private List<DataValue> dataValues;
-
-
public String getDataSetUuid()
{
return dataSetUuid;
@@ -97,14 +87,5 @@
this.completeDate = completeDate;
}
- public List<DataValue> getDataValues()
- {
- return dataValues;
- }
-
- public void setDataValues( List<DataValue> dataValues )
- {
- this.dataValues = dataValues;
- }
-
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValueSetService.java 2011-02-16 17:16:18 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/DataValueSetService.java 2011-02-17 08:25:53 +0000
@@ -29,9 +29,9 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Set;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -82,30 +82,111 @@
* For all dataValues it checks that:
* <ul>
* <li>dataElement exists and is in dataSet
- * <li>optionCombo exists (defaults to 'default' if not specified) and is in dataElement
+ * <li>optionCombo exists (defaults to 'default' if not specified) and is in
+ * dataElement
* </ul>
* What isn't checked yet:
* <ul>
- * <li>That there isn't duplicated value entries (will throw Constraint exception)
+ * <li>That there isn't duplicated value entries (will throw Constraint
+ * exception)
* <li>That the value is valid!
* </ul>
* Concerns:
* <ul>
- * <li>deletion through sending "empty string" value dependant on semantics of add/update in data value store
- * <li>completed semantics, can't uncomplete but can complete and "recomplete"
+ * <li>deletion through sending "empty string" value dependant on semantics
+ * of add/update in data value store
+ * <li>completed semantics, can't uncomplete but can complete and
+ * "recomplete"
* <li>what is 'comment' really?
*
- * @param dataValueSet
- * @throws IllegalArgumentException if
+ * @param dxf
+ * @throws IllegalArgumentException if
*/
- public void saveDataValueSet( DataValueSet dataValueSet )
+ @Transactional
+ public void saveDataValueSet( Dxf dxf )
throws IllegalArgumentException
{
+ handleComplete( dxf.getDataValueSets() );
+ for ( org.hisp.dhis.importexport.datavalueset.DataValue dxfValue : dxf.getDataValues() )
+ {
+ saveDataValue( dxfValue );
+ }
+ }
+
+ private void handleComplete( List<DataValueSet> completeNotDataSets )
+ {
+ if ( completeNotDataSets == null )
+ {
+ return;
+ }
+
+ for ( DataValueSet nds : completeNotDataSets )
+ {
+ CompleteDataSetRegistration complete = null;
+
+ DataSet dataSet = getDataSet( nds.getDataSetUuid() );
+
+ OrganisationUnit unit = getOrgUnit( nds.getOrganisationUnitUuid() );
+
+ if ( !dataSet.getSources().contains( unit ) )
+ {
+ throw new IllegalArgumentException( "Org unit with UUID " + unit.getUuid()
+ + " does not report data set with UUID " + dataSet.getUuid() );
+ }
+
+ Period period = getPeriod( nds.getPeriodIsoDate(), dataSet.getPeriodType() );
+
+ CompleteDataSetRegistration alreadyComplete = registrationService.getCompleteDataSetRegistration( dataSet,
+ period, unit );
+ String completeDateString = nds.getCompleteDate();
+
+ if ( alreadyComplete != null && completeDateString == null )
+ {
+ throw new IllegalArgumentException(
+ "DataValueSet is complete, include a new complete date if you want to recomplete" );
+ }
+
+ if ( completeDateString != null )
+ {
+ complete = getComplete( dataSet, unit, period, completeDateString, complete );
+ }
+
+ if ( alreadyComplete != null )
+ {
+ registrationService.deleteCompleteDataSetRegistration( alreadyComplete );
+ }
+ if ( complete != null )
+ {
+ registrationService.saveCompleteDataSetRegistration( complete );
+ }
+
+ }
+ }
+
+ private void saveDataValue( org.hisp.dhis.importexport.datavalueset.DataValue dxfValue )
+ {
Date timestamp = new Date();
- DataSet dataSet = getDataSet( dataValueSet.getDataSetUuid() );
-
- OrganisationUnit unit = getOrgUnit( dataValueSet.getOrganisationUnitUuid() );
+ OrganisationUnit unit = getOrgUnit( dxfValue.getOrganisationUnitUuid() );
+
+ DataElement dataElement = getDataElement( dxfValue.getDataElementUuid() );
+
+ DataSet dataSet = null;
+ if ( dxfValue.getDataSetUuid() != null )
+ {
+ dataSet = getDataSet( dxfValue.getDataSetUuid() );
+
+ if ( !dataSet.getDataElements().contains( dataElement ) )
+ {
+ throw new IllegalArgumentException( "Data element '" + dataElement.getUuid() + "' isn't in data set "
+ + dataSet.getUuid() );
+ }
+
+ }
+ else
+ {
+ dataSet = resolveDataSet( dataElement, unit );
+ }
if ( !dataSet.getSources().contains( unit ) )
{
@@ -113,58 +194,57 @@
+ " does not report data set with UUID " + dataSet.getUuid() );
}
- Period period = getPeriod( dataValueSet.getPeriodIsoDate(), dataSet.getPeriodType() );
-
- CompleteDataSetRegistration alreadyComplete = registrationService.getCompleteDataSetRegistration( dataSet,
- period, unit );
- String completeDateString = dataValueSet.getCompleteDate();
-
- if ( alreadyComplete != null && completeDateString == null )
- {
- throw new IllegalArgumentException(
- "DataValueSet is complete, include a new complete date if you want to recomplete" );
- }
-
- CompleteDataSetRegistration complete = null;
-
- if ( completeDateString != null )
- {
- complete = getComplete( dataSet, unit, period, completeDateString, complete );
- }
-
- List<DataValue> newDataValues = new ArrayList<DataValue>( dataValueSet.getDataValues().size() );
- List<DataValue> updatedDataValues = new ArrayList<DataValue>( dataValueSet.getDataValues().size() );
-
- for ( org.hisp.dhis.importexport.datavalueset.DataValue dxfValue : dataValueSet.getDataValues() )
- {
- DataElement dataElement = getDataElement( dxfValue.getDataElementUuid(), dataSet );
-
- DataElementCategoryOptionCombo combo = getOptionCombo( dxfValue.getCategoryOptionComboUuid(), dataElement );
-
-
-
- DataValue dv = dataValueService.getDataValue( unit, dataElement, period, combo );
-
- String value = dxfValue.getValue();
-
- // dataElement.isValidValue(value);
-
- if ( dv == null )
- {
- dv = new DataValue( dataElement, period, unit, value, dxfValue.getStoredBy(), timestamp,
- null, combo );
- newDataValues.add( dv );
- }
- else
- {
- dv.setValue( value );
- dv.setTimestamp( timestamp );
- dv.setStoredBy( dxfValue.getStoredBy() );
- updatedDataValues.add( dv );
- }
- }
-
- save( alreadyComplete, complete, newDataValues, updatedDataValues );
+ Period period = getPeriod( dxfValue.getPeriodIsoDate(), dataSet.getPeriodType() );
+
+ DataElementCategoryOptionCombo combo = getOptionCombo( dxfValue.getCategoryOptionComboUuid(), dataElement );
+
+ String value = dxfValue.getValue();
+
+ // dataElement.isValidValue(value);
+
+ DataValue dv = dataValueService.getDataValue( unit, dataElement, period, combo );
+
+ if ( dv == null )
+ {
+ dv = new DataValue( dataElement, period, unit, value, dxfValue.getStoredBy(), timestamp, null, combo );
+ dataValueService.addDataValue( dv );
+ }
+ else
+ {
+ dv.setValue( value );
+ dv.setTimestamp( timestamp );
+ dv.setStoredBy( dxfValue.getStoredBy() );
+ dataValueService.updateDataValue( dv );
+ }
+ }
+
+ private DataSet resolveDataSet( DataElement dataElement, OrganisationUnit unit )
+ {
+
+ Set<DataSet> dataSets = dataElement.getDataSets();
+
+ if ( dataSets == null || dataSets.isEmpty() )
+ {
+ throw new IllegalArgumentException( "data element '" + dataElement.getName() + "' with UUID '"
+ + dataElement.getUuid() + "' isn't assigned to any data set" );
+ }
+ else if ( dataSets.size() == 1 )
+ {
+ return dataSets.iterator().next();
+ }
+ else
+ {
+ for ( DataSet dataSet : dataSets )
+ {
+ if ( dataSet.getOrganisationUnits().contains( unit ) )
+ {
+ return dataSet;
+ }
+ }
+ }
+ throw new IllegalArgumentException( "data element '" + dataElement.getName() + "' with UUID '"
+ + dataElement.getUuid() + "' isn't assigned to any data set that in turn is assigned to org unit '"
+ + unit.getName() + "', uuid '" + unit.getUuid() + "'" );
}
private CompleteDataSetRegistration getComplete( DataSet dataSet, OrganisationUnit unit, Period period,
@@ -221,7 +301,7 @@
return dataSet;
}
- private DataElement getDataElement( String uuid, DataSet dataSet )
+ private DataElement getDataElement( String uuid )
{
DataElement dataElement = dataElementService.getDataElement( uuid );
@@ -230,11 +310,6 @@
throw new IllegalArgumentException( "Data element with UUID " + uuid + " does not exist" );
}
- if ( !dataSet.getDataElements().contains( dataElement ) )
- {
- throw new IllegalArgumentException( "Data element '" + dataElement.getUuid() + "' isn't in data set "
- + dataSet.getUuid() );
- }
return dataElement;
}
@@ -265,30 +340,31 @@
return combo;
}
- @Transactional
- private void save( CompleteDataSetRegistration alreadyComplete, CompleteDataSetRegistration complete,
- List<DataValue> newDataValues, List<DataValue> updatedDataValues )
- {
- if ( alreadyComplete != null )
- {
- registrationService.deleteCompleteDataSetRegistration( alreadyComplete );
- }
-
- for ( DataValue dataValue : newDataValues )
- {
- dataValueService.addDataValue( dataValue );
- }
-
- for ( DataValue dataValue : updatedDataValues )
- {
- dataValueService.updateDataValue( dataValue );
- }
-
- if ( complete != null )
- {
- registrationService.saveCompleteDataSetRegistration( complete );
- }
- }
+ // @Transactional
+ // private void save( CompleteDataSetRegistration alreadyComplete,
+ // CompleteDataSetRegistration complete,
+ // List<DataValue> newDataValues, List<DataValue> updatedDataValues )
+ // {
+ // if ( alreadyComplete != null )
+ // {
+ // registrationService.deleteCompleteDataSetRegistration( alreadyComplete );
+ // }
+ //
+ // for ( DataValue dataValue : newDataValues )
+ // {
+ // dataValueService.addDataValue( dataValue );
+ // }
+ //
+ // for ( DataValue dataValue : updatedDataValues )
+ // {
+ // dataValueService.updateDataValue( dataValue );
+ // }
+ //
+ // if ( complete != null )
+ // {
+ // registrationService.saveCompleteDataSetRegistration( complete );
+ // }
+ // }
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
{
=== added file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/Dxf.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/Dxf.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/Dxf.java 2011-02-17 08:25:53 +0000
@@ -0,0 +1,72 @@
+package org.hisp.dhis.importexport.datavalueset;
+
+/*
+ * 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.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlAccessorType( XmlAccessType.FIELD )
+@XmlRootElement
+public class Dxf
+{
+
+ @XmlElementWrapper( name = "dataValues" )
+ @XmlElement( name = "dataValue" )
+ private List<DataValue> dataValues;
+
+ @XmlElementWrapper( name = "dataValueSets" )
+ @XmlElement( name = "dataValueSet" )
+ private List<DataValueSet> dataValueSets;
+
+ public List<DataValue> getDataValues()
+ {
+ return dataValues;
+ }
+
+ public void setDataValues( List<DataValue> dataValues )
+ {
+ this.dataValues = dataValues;
+ }
+
+ public List<DataValueSet> getDataValueSets()
+ {
+ return dataValueSets;
+ }
+
+ public void setDataValueSets( List<DataValueSet> dataValueSets )
+ {
+ this.dataValueSets = dataValueSets;
+ }
+
+
+}
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/package-info.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/package-info.java 2011-02-15 06:46:27 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/datavalueset/package-info.java 2011-02-17 08:25:53 +0000
@@ -1,5 +1,5 @@
@javax.xml.bind.annotation.XmlSchema(
- namespace = "http://dhis2.org/schema/dataValueSet/0.1",
+ namespace = "http://dhis2.org/schema/dxf/x.x",
xmlns = { @javax.xml.bind.annotation.XmlNs( prefix = "xs", namespaceURI = "http://www.w3.org/2001/XMLSchema" ) },
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED )
package org.hisp.dhis.importexport.datavalueset;
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/datavalueset/DataValueSetServiceTest.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/datavalueset/DataValueSetServiceTest.java 2011-02-16 17:16:18 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/datavalueset/DataValueSetServiceTest.java 2011-02-17 08:25:53 +0000
@@ -79,7 +79,8 @@
private DataValueSetService service;
- private DataValueSet dataValueSet;
+ private Dxf dxf;
+ private org.hisp.dhis.importexport.datavalueset.DataValue dv;
private ImportService importService;
@@ -87,6 +88,8 @@
private DataElementCategoryOptionCombo defaultCombo;
+ private DataValueSet dataValueSet;
+
// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@@ -112,26 +115,27 @@
importService.importData( importParams, is );
is.close();
+ defaultCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+ defaultCombo.setUuid( DEFAULT_COMBO_UUID );
+ categoryService.updateDataElementCategoryOptionCombo( defaultCombo );
+
+ dxf = new Dxf();
+
+ dv = new org.hisp.dhis.importexport.datavalueset.DataValue();
+// dv.setDataSetUuid( DATA_SET_UUID );
+ dv.setPeriodIsoDate( "2011W5" );
+ dv.setOrganisationUnitUuid( ORGANISATION_UNIT_UUID );
+ dv.setDataElementUuid( DATA_ELEMENT_UUID );
+ dv.setValue( "11" );
+ dv.setStoredBy( "misterindia" );
+
+ dxf.setDataValues( new ArrayList<org.hisp.dhis.importexport.datavalueset.DataValue>() {{ add( dv ); }} );
+
dataValueSet = new DataValueSet();
+ dataValueSet.setCompleteDate( "20101010" );
dataValueSet.setDataSetUuid( DATA_SET_UUID );
- dataValueSet.setPeriodIsoDate( "2011W5" );
dataValueSet.setOrganisationUnitUuid( ORGANISATION_UNIT_UUID );
-
- final org.hisp.dhis.importexport.datavalueset.DataValue dv = new org.hisp.dhis.importexport.datavalueset.DataValue();
- dv.setDataElementUuid( DATA_ELEMENT_UUID );
- dv.setValue( "11" );
- dv.setStoredBy( "misterindia" );
-
- dataValueSet.setDataValues( new ArrayList<org.hisp.dhis.importexport.datavalueset.DataValue>()
- {
- {
- add( dv );
- }
- } );
-
- defaultCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
- defaultCombo.setUuid( DEFAULT_COMBO_UUID );
- categoryService.updateDataElementCategoryOptionCombo( defaultCombo );
+ dataValueSet.setPeriodIsoDate( "201009" );
}
// -------------------------------------------------------------------------
@@ -142,27 +146,25 @@
public void testJaxb()
throws JAXBException, IOException
{
- JAXBContext jc = JAXBContext.newInstance( DataValueSet.class,
- org.hisp.dhis.importexport.datavalueset.DataValue.class );
+ JAXBContext jc = JAXBContext.newInstance( Dxf.class );
Unmarshaller u = jc.createUnmarshaller();
InputStream is = classLoader.getResourceAsStream( "datavalueset/dataValueSet.xml" );
- DataValueSet dxfDataValueSet = (DataValueSet) u.unmarshal( is );
+ Dxf dxfDataValueSet = (Dxf) u.unmarshal( is );
is.close();
- assertEquals( dataValueSet.getDataSetUuid(), dxfDataValueSet.getDataSetUuid() );
- assertEquals( dataValueSet.getPeriodIsoDate(), dxfDataValueSet.getPeriodIsoDate() );
- assertEquals( dataValueSet.getOrganisationUnitUuid(), dxfDataValueSet.getOrganisationUnitUuid() );
-
assertEquals( 1, dxfDataValueSet.getDataValues().size() );
- org.hisp.dhis.importexport.datavalueset.DataValue dv = dxfDataValueSet.getDataValues().get( 0 );
- org.hisp.dhis.importexport.datavalueset.DataValue dataValue = dataValueSet.getDataValues().get( 0 );
-
- assertEquals( dataValue.getDataElementUuid(), dv.getDataElementUuid() );
- assertEquals( dataValue.getStoredBy(), dv.getStoredBy() );
-
- assertNull( dv.getCategoryOptionComboUuid() );
+ org.hisp.dhis.importexport.datavalueset.DataValue dxfValue = dxfDataValueSet.getDataValues().get( 0 );
+
+ assertEquals( dv.getDataSetUuid(), dxfValue.getDataSetUuid() );
+ assertEquals( dv.getPeriodIsoDate(), dxfValue.getPeriodIsoDate() );
+ assertEquals( dv.getOrganisationUnitUuid(), dxfValue.getOrganisationUnitUuid() );
+
+ assertEquals( dv.getDataElementUuid(), dxfValue.getDataElementUuid() );
+ assertEquals( dv.getStoredBy(), dxfValue.getStoredBy() );
+
+ assertNull( dxfValue.getCategoryOptionComboUuid() );
}
@Test
@@ -171,7 +173,7 @@
{
long before = new Date().getTime();
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
long after = new Date().getTime();
@@ -190,7 +192,7 @@
try
{
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
}
catch ( NumberFormatException e )
{
@@ -211,7 +213,7 @@
@Test
public void deleteDataValue() {
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
Collection<DataValue> dataValues = dataValueService.getAllDataValues();
assertEquals( 1, dataValues.size() );
@@ -221,7 +223,7 @@
setValue( null );
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
dataValues = dataValueService.getAllDataValues();
assertEquals( 0, dataValues.size() );
@@ -229,28 +231,12 @@
}
@Test
- public void dataSetMissing()
- {
- dataValueSet.setDataSetUuid( null );
- try
- {
- service.saveDataValueSet( dataValueSet );
- fail( "Should miss data set" );
-
- }
- catch ( IllegalArgumentException e )
- {
- // Expected
- }
- }
-
- @Test
public void orgunitMissingOrNotInSet()
{
- dataValueSet.setOrganisationUnitUuid( "ladlalad" );
+ dv.setOrganisationUnitUuid( "ladlalad" );
try
{
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
fail( "Should miss org unit" );
}
@@ -259,11 +245,11 @@
// Expected
}
- dataValueSet.setOrganisationUnitUuid( ORGANISATION_UNIT_NOT_IN_SET_UUID );
+ dv.setOrganisationUnitUuid( ORGANISATION_UNIT_NOT_IN_SET_UUID );
try
{
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
fail( "Should miss org unit association to data set" );
}
@@ -276,11 +262,11 @@
@Test
public void illegalPeriod() {
- dataValueSet.setPeriodIsoDate( "2011" );
+ dv.setPeriodIsoDate( "2011" );
try
{
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
fail( "should not accept yearly period" );
}
@@ -293,16 +279,17 @@
@Test
public void completeness() {
- service.saveDataValueSet( dataValueSet );
+ dxf.setDataValueSets( new ArrayList() {{ add(dataValueSet); }} );
+ service.saveDataValueSet( dxf );
dataValueSet.setCompleteDate( "20110101" );
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
dataValueSet.setCompleteDate( null );
try
{
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
fail("Shouldn't allow saving to a completed set");
}
catch ( IllegalArgumentException e )
@@ -314,7 +301,7 @@
try
{
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
}
catch ( IllegalArgumentException e )
{
@@ -322,7 +309,7 @@
}
dataValueSet.setCompleteDate( "20101010" );
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
}
@@ -332,11 +319,11 @@
org.hisp.dhis.importexport.datavalueset.DataValue dv = new org.hisp.dhis.importexport.datavalueset.DataValue();
dv.setDataElementUuid( "ladida" );
dv.setValue( "11" );
- dataValueSet.getDataValues().add( dv );
+ dxf.getDataValues().add( dv );
try
{
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
fail( "Should not accept non existing data element" );
}
catch ( IllegalArgumentException e )
@@ -348,7 +335,7 @@
try
{
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
fail( "Should not accept data element not in set" );
}
catch ( IllegalArgumentException e )
@@ -360,15 +347,15 @@
@Test
public void optionComboExistsAndInDataElement() {
- dataValueSet.getDataValues().get( 0 ).setCategoryOptionComboUuid( DEFAULT_COMBO_UUID );
-
- service.saveDataValueSet( dataValueSet );
-
- dataValueSet.getDataValues().get( 0 ).setCategoryOptionComboUuid( "AAB2299E-ECD6-46CF-A61F-817D350" );
+ dxf.getDataValues().get( 0 ).setCategoryOptionComboUuid( DEFAULT_COMBO_UUID );
+
+ service.saveDataValueSet( dxf );
+
+ dxf.getDataValues().get( 0 ).setCategoryOptionComboUuid( "AAB2299E-ECD6-46CF-A61F-817D350" );
try
{
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
fail( "Shouldn't allow non existing option combo" );
}
catch ( IllegalArgumentException e )
@@ -385,7 +372,7 @@
{
long before = new Date().getTime();
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
long after = new Date().getTime();
@@ -401,7 +388,7 @@
before = new Date().getTime();
- service.saveDataValueSet( dataValueSet );
+ service.saveDataValueSet( dxf );
after = new Date().getTime();
@@ -416,7 +403,7 @@
private void setValue(String value)
{
- dataValueSet.getDataValues().get( 0 ).setValue( value );
+ dxf.getDataValues().get( 0 ).setValue( value );
}
private void verifyDataValue( long before, long after, DataValue dv )
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/test/resources/datavalueset/dataValueSet.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/resources/datavalueset/dataValueSet.xml 2011-02-16 17:16:18 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/resources/datavalueset/dataValueSet.xml 2011-02-17 08:25:53 +0000
@@ -1,9 +1,12 @@
<?xml version='1.0'?>
-
-<dataValueSet xmlns="http://dhis2.org/schema/dataValueSet/0.1"
- dataSet="16B2299E-ECD6-46CF-A61F-817D350C180D" period="2011W5"
- orgUnit="9C1B1B5E-3D65-48F2-8D1D-D36C60DD7344">
-
- <dataValue dataElement="56B2299E-ECD6-46CF-A61F-817D350C180D" storedBy="misterindia" value="11" />
-
-</dataValueSet>
+<dxf xmlns="http://dhis2.org/schema/dxf/x.x">
+ <completeNotDataValueSets>
+ <completeNotDataValueSet dataSet="16B2299E-ECD6-46CF-A61F-817D350C180D"
+ period="2011W5" orgUnit="9C1B1B5E-3D65-48F2-8D1D-D36C60DD7344" complete="20101010" />
+ </completeNotDataValueSets>
+ <dataValues>
+ <dataValue period="2011W5"
+ orgUnit="9C1B1B5E-3D65-48F2-8D1D-D36C60DD7344" dataElement="56B2299E-ECD6-46CF-A61F-817D350C180D"
+ storedBy="misterindia" value="11" />
+ </dataValues>
+</dxf>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/rpc/RPCResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/rpc/RPCResource.java 2011-02-16 17:16:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/rpc/RPCResource.java 2011-02-17 08:25:53 +0000
@@ -17,7 +17,7 @@
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.importexport.datavalueset.DataValueSet;
+import org.hisp.dhis.importexport.datavalueset.Dxf;
import org.hisp.dhis.importexport.datavalueset.DataValueSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.springframework.beans.factory.annotation.Required;
@@ -36,7 +36,7 @@
@POST
@Path( "dataValueSets" )
@Consumes( MediaType.APPLICATION_XML )
- public void storeDataValueSet( DataValueSet dataValueSet )
+ public void storeDataValueSet( Dxf dataValueSet )
{
dataValueSetService.saveDataValueSet( dataValueSet );
}
@@ -91,7 +91,7 @@
t.append( "</p>\n" );
t.append( "<h2>Org units reporting data set</h2>\n<ul>" );
- for ( OrganisationUnit unit : dataSet.getOrganisationUnis() )
+ for ( OrganisationUnit unit : dataSet.getOrganisationUnits() )
{
t.append( "<li><b>" ).append( unit.getName() ).append( "</b> - " ).append( unit.getUuid() )
.append( "</li>" );
@@ -138,7 +138,12 @@
t.append( "<p>Post according to the following template to " );
t.append( "<a href=\"" ).append( uri ).append( "\">" ).append( uri ).append( "</a>:</p>" );
- t.append( "<pre>" ).append( "<dataValueSet xmlns=\"http://dhis2.org/schema/dataValueSet/0.1\"\n" );
+ t.append( "<pre>" );
+ t.append( "<dxf xmlns=\"http://dhis2.org/schema/dxf/x.x\">\n <dataValues>\n <dataValue dataSet=\"uuid - only required if data element is registered to multiple data sets\"\n period=\"201102\"\n orgUnit=\"uuid\"\n storedBy=\"string\"\n dataElement=\"uuid\"\n value=\"value\" />\n </dataValues>\n" );
+ t.append( " <dataValueSets>\n <dataValueSet\n dataSet=\"uuid\"\n orgUnit=\"uuid\"\n period=\"period in iso format\"\n complete=\"date (yyyymmdd)\"/>\n </dataValueSets>\n</dxf>" );
+ t.append( "</pre>" );
+
+ t.append( "<p>Old format</p><pre>" ).append( "<dataValueSet xmlns=\"http://dhis2.org/schema/dataValueSet/0.1\"\n" );
t.append( " dataSet=\"dataSet UUID\" \n period=\"periodInIsoFormat\"\n orgUnit=\"unit UUID\">" );
t.append( "\n <dataValue dataElement=\"data element UUID\" categoryOptionCombo=\"UUID, only specify if used\" storedBy=\"string\" value=\"value\"/>" );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.java 2010-09-14 09:03:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.java 2011-02-17 08:25:53 +0000
@@ -142,7 +142,7 @@
dataEntryForm = dataSet.getDataEntryForm();
- selectionTreeManager.setSelectedOrganisationUnits( dataSet.getOrganisationUnis() );
+ selectionTreeManager.setSelectedOrganisationUnits( dataSet.getOrganisationUnits() );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/MergeAssignedOrgunitsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/MergeAssignedOrgunitsAction.java 2010-09-29 07:05:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/MergeAssignedOrgunitsAction.java 2011-02-17 08:25:53 +0000
@@ -102,7 +102,7 @@
if ( iterator.hasNext() )
{
DataSet dataSet = dataSetService.getDataSet( Integer.valueOf( iterator.next() ) );
- selectedUnits.addAll( dataSet.getOrganisationUnis() );
+ selectedUnits.addAll( dataSet.getOrganisationUnits() );
iterator.remove();
}
@@ -111,7 +111,7 @@
for ( String dataSetId : selectedDataSets )
{
DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) );
- tempUnits = dataSet.getOrganisationUnis();
+ tempUnits = dataSet.getOrganisationUnits();
if ( !(tempUnits.size() == selectedUnits.size() && tempUnits.containsAll( selectedUnits )) )
{