dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16756
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6452: Split the id scheme property into dataElementIdScheme and orgUnitIdScheme for data value set. The...
------------------------------------------------------------
revno: 6452
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-03-30 13:04:07 +0200
message:
Split the id scheme property into dataElementIdScheme and orgUnitIdScheme for data value set. These can be provided as input params or as xml attributes on the dataValueSet element. Xml attr will override input param.
modified:
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/utils/DataValueSetMapper.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.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/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java 2012-03-29 21:52:27 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSet.java 2012-03-30 11:04:07 +0000
@@ -34,16 +34,23 @@
import org.hisp.dhis.dxf2.datavalue.DataValue;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonUnwrapped;
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
-{
- public enum IdentificationStrategy { INTERNAL, UID, CODE };
+{
+ //--------------------------------------------------------------------------
+ // Options
+ //--------------------------------------------------------------------------
- public static final IdentificationStrategy DEFAULT_STRATEGY = IdentificationStrategy.UID;
+ private String dataElementIdScheme;
+
+ private String orgUnitIdScheme;
+
+ //--------------------------------------------------------------------------
+ // Properties
+ //--------------------------------------------------------------------------
private String dataSet;
@@ -55,6 +62,34 @@
private List<DataValue> dataValues = new ArrayList<DataValue>();
+ //--------------------------------------------------------------------------
+ // Getters and setters
+ //--------------------------------------------------------------------------
+
+ @JsonProperty()
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public String getDataElementIdScheme()
+ {
+ return dataElementIdScheme;
+ }
+
+ public void setDataElementIdScheme( String dataElementIdScheme )
+ {
+ this.dataElementIdScheme = dataElementIdScheme;
+ }
+
+ @JsonProperty()
+ @JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
+ public String getOrgUnitIdScheme()
+ {
+ return orgUnitIdScheme;
+ }
+
+ public void setOrgUnitIdScheme( String orgUnitIdScheme )
+ {
+ this.orgUnitIdScheme = orgUnitIdScheme;
+ }
+
@JsonProperty()
@JacksonXmlProperty( isAttribute=true, namespace = Dxf2Namespace.NAMESPACE )
public String getDataSet()
=== modified file '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/DataValueSetService.java 2012-03-29 16:45:18 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DataValueSetService.java 2012-03-30 11:04:07 +0000
@@ -36,5 +36,5 @@
{
ImportSummary saveDataValueSet( DataValueSet dataValueSet );
- ImportSummary saveDataValueSet( DataValueSet dataValueSet, IdentifiableProperty idScheme, boolean dryRun, ImportStrategy strategy );
+ ImportSummary saveDataValueSet( DataValueSet dataValueSet, IdentifiableProperty dataElementIdScheme, IdentifiableProperty orgUnitIdScheme, boolean dryRun, ImportStrategy strategy );
}
=== modified file '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/DefaultDataValueSetService.java 2012-03-29 22:07:52 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java 2012-03-30 11:04:07 +0000
@@ -84,23 +84,26 @@
@Transactional
public ImportSummary saveDataValueSet( DataValueSet dataValueSet )
{
- return saveDataValueSet( dataValueSet, IdentifiableProperty.UID, false, ImportStrategy.NEW_AND_UPDATES );
+ return saveDataValueSet( dataValueSet, IdentifiableProperty.UID, IdentifiableProperty.UID, false, ImportStrategy.NEW_AND_UPDATES );
}
@Transactional
- public ImportSummary saveDataValueSet( DataValueSet dataValueSet, IdentifiableProperty idScheme, boolean dryRun, ImportStrategy strategy )
+ public ImportSummary saveDataValueSet( DataValueSet dataValueSet, IdentifiableProperty dataElementIdScheme, IdentifiableProperty orgUnitIdScheme, boolean dryRun, ImportStrategy strategy )
{
ImportSummary summary = new ImportSummary();
- Map<String, DataElement> dataElementMap = identifiableObjectManager.getIdMap( DataElement.class, idScheme );
- Map<String, OrganisationUnit> orgUnitMap = identifiableObjectManager.getIdMap( OrganisationUnit.class, idScheme );
+ dataElementIdScheme = dataValueSet.getDataElementIdScheme() != null ? IdentifiableProperty.valueOf( dataValueSet.getDataElementIdScheme().toUpperCase() ) : dataElementIdScheme;
+ orgUnitIdScheme = dataValueSet.getOrgUnitIdScheme() != null ? IdentifiableProperty.valueOf( dataValueSet.getOrgUnitIdScheme().toUpperCase() ) : orgUnitIdScheme;
+
+ Map<String, DataElement> dataElementMap = identifiableObjectManager.getIdMap( DataElement.class, dataElementIdScheme );
+ Map<String, OrganisationUnit> orgUnitMap = identifiableObjectManager.getIdMap( OrganisationUnit.class, orgUnitIdScheme );
Map<String, DataElementCategoryOptionCombo> categoryOptionComboMap = identifiableObjectManager.getIdMap( DataElementCategoryOptionCombo.class, IdentifiableProperty.UID );
- DataSet dataSet = dataValueSet.getDataSet() != null ? identifiableObjectManager.getObject( DataSet.class, idScheme, dataValueSet.getDataSet() ) : null;
+ DataSet dataSet = dataValueSet.getDataSet() != null ? identifiableObjectManager.getObject( DataSet.class, IdentifiableProperty.UID, dataValueSet.getDataSet() ) : null;
Date completeDate = getDefaultDate( dataValueSet.getCompleteDate() );
Period period = PeriodType.getPeriodFromIsoString( dataValueSet.getPeriod() );
- OrganisationUnit orgUnit = dataValueSet.getOrgUnit() != null ? identifiableObjectManager.getObject( OrganisationUnit.class, idScheme, dataValueSet.getOrgUnit() ) : null;
+ OrganisationUnit orgUnit = dataValueSet.getOrgUnit() != null ? identifiableObjectManager.getObject( OrganisationUnit.class, orgUnitIdScheme, dataValueSet.getOrgUnit() ) : null;
if ( dataSet != null )
{
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/DataValueSetMapper.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/DataValueSetMapper.java 2012-03-29 21:52:27 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/DataValueSetMapper.java 2012-03-30 11:04:07 +0000
@@ -43,7 +43,18 @@
{
private static final String XMLNS = "xmlns";
private static final String NS = "http://dhis2.org/schema/dxf/2.0";
-
+
+ //--------------------------------------------------------------------------
+ // Options
+ //--------------------------------------------------------------------------
+
+ private static final String FIELD_DATAELEMENTIDSCHEME = "dataElementIdScheme";
+ private static final String FIELD_ORGUNITIDSCHEME = "orgUnitIdScheme";
+
+ //--------------------------------------------------------------------------
+ // Properties
+ //--------------------------------------------------------------------------
+
private static final String FIELD_DATAVALUESET = "dataValueSet";
private static final String FIELD_DATAVALUE = "dataValue";
private static final String FIELD_DATASET = "dataSet";
@@ -95,6 +106,9 @@
DataValueSet dataValueSet = new DataValueSet();
+ dataValueSet.setDataElementIdScheme( reader.getAttributeValue( FIELD_DATAELEMENTIDSCHEME ) );
+ dataValueSet.setOrgUnitIdScheme( reader.getAttributeValue( FIELD_ORGUNITIDSCHEME ) );
+
dataValueSet.setDataSet( reader.getAttributeValue( FIELD_DATASET ) );
dataValueSet.setCompleteDate( reader.getAttributeValue( FIELD_COMPLETEDATE ) );
dataValueSet.setPeriod( reader.getAttributeValue( FIELD_PERIOD ) );
=== 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-28 16:04:53 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java 2012-03-30 11:04:07 +0000
@@ -92,9 +92,9 @@
return viewClasses.get( viewName );
}
- //---------------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
// Global pre-configured instances of ObjectMapper and XmlMapper
- //---------------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
public static ObjectMapper getJsonMapper()
{
@@ -106,9 +106,9 @@
return xmlMapper;
}
- //---------------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
// JSON
- //---------------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
public static void toJson( OutputStream output, Object value ) throws IOException
{
@@ -136,9 +136,9 @@
return (T) jsonMapper.readValue( input, clazz );
}
- //---------------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
// XML
- //---------------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
public static void toXml( OutputStream output, Object value ) throws IOException
{
=== 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-29 21:52:27 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2012-03-30 11:04:07 +0000
@@ -77,21 +77,23 @@
@RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml"} )
@PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_ADD')" )
- public void postDataValueSet( @RequestParam(required=false, defaultValue="UID") String idScheme,
+ public void postDataValueSet( @RequestParam(required=false, defaultValue="UID") String dataElementIdScheme,
+ @RequestParam(required=false, defaultValue="UID") String orgUnitIdScheme,
@RequestParam(required=false) boolean dryRun,
@RequestParam(required=false, defaultValue="NEW_AND_UPDATES") String strategy,
HttpServletResponse response,
InputStream input,
Model model ) throws IOException
{
- IdentifiableProperty _idScheme = IdentifiableProperty.valueOf( idScheme.toUpperCase() );
+ IdentifiableProperty _dataElementidScheme = IdentifiableProperty.valueOf( dataElementIdScheme.toUpperCase() );
+ IdentifiableProperty _orgUnitIdScheme = IdentifiableProperty.valueOf( orgUnitIdScheme.toUpperCase() );
ImportStrategy _strategy = ImportStrategy.valueOf( strategy.toUpperCase() );
DataValueSet dataValueSet = DataValueSetMapper.fromXml( input );
- ImportSummary summary = dataValueSetService.saveDataValueSet( dataValueSet, _idScheme, dryRun, _strategy );
+ ImportSummary summary = dataValueSetService.saveDataValueSet( dataValueSet, _dataElementidScheme, _orgUnitIdScheme, dryRun, _strategy );
- log.info( "Data values " + dataValueSet + " saved using id scheme: " + _idScheme + ", dry run: " + dryRun + ", strategy: " + _strategy );
+ log.info( "Data values " + dataValueSet + " saved, data element id scheme: " + _dataElementidScheme + ", org unit id scheme: " + _orgUnitIdScheme + ", dry run: " + dryRun + ", strategy: " + _strategy );
response.setContentType( CONTENT_TYPE_XML );
JacksonUtils.toXml( response.getOutputStream(), summary );