dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29330
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14789: dvs-template: made it possible to turn off comment generator, don't display 'default' label when ...
------------------------------------------------------------
revno: 14789
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-04-11 13:58:24 +0700
message:
dvs-template: made it possible to turn off comment generator, don't display 'default' label when coc is default
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2014-04-11 06:20:27 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2014-04-11 06:58:24 +0000
@@ -180,6 +180,7 @@
@RequestParam( value = "dataElementIdScheme", defaultValue = "ID", required = false ) String dataElementIdScheme,
@RequestParam( value = "period", defaultValue = "", required = false ) String period,
@RequestParam( value = "orgUnit", defaultValue = "", required = false ) List<String> orgUnits,
+ @RequestParam( value = "comment", defaultValue = "true", required = false ) boolean comment,
HttpServletResponse response ) throws IOException
{
DataSet dataSet = getEntity( uid );
@@ -198,14 +199,19 @@
try
{
XMLStreamWriter staxWriter = generator.getStaxWriter();
- staxWriter.writeComment( "DataSet: " + dataSet.getDisplayName() + " (" + dataSet.getUid() + ")");
+
+ if ( comment )
+ {
+ staxWriter.writeComment( "DataSet: " + dataSet.getDisplayName() + " (" + dataSet.getUid() + ")" );
+ }
+
staxWriter.writeStartElement( "", "dataValueSet", DxfNamespaces.DXF_2_0 );
if ( orgUnits.isEmpty() )
{
for ( DataElement dataElement : dataSet.getDataElements() )
{
- writeDataValue( dataElement, "", period, staxWriter );
+ writeDataValue( dataElement, "", period, comment, staxWriter );
}
}
else
@@ -219,11 +225,14 @@
continue;
}
- staxWriter.writeComment( "OrgUnit: " + organisationUnit.getDisplayName() + " (" + organisationUnit.getUid() + ")" );
+ if ( comment )
+ {
+ staxWriter.writeComment( "OrgUnit: " + organisationUnit.getDisplayName() + " (" + organisationUnit.getUid() + ")" );
+ }
for ( DataElement dataElement : dataSet.getDataElements() )
{
- writeDataValue( dataElement, orgUnit, period, staxWriter );
+ writeDataValue( dataElement, orgUnit, period, comment, staxWriter );
}
}
}
@@ -237,13 +246,22 @@
}
}
- private void writeDataValue( DataElement dataElement, String orgUnit, String period, XMLStreamWriter staxWriter ) throws XMLStreamException
+ private void writeDataValue( DataElement dataElement, String orgUnit, String period, boolean comment, XMLStreamWriter staxWriter ) throws XMLStreamException
{
for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() )
{
- String label = dataElement.getDisplayName() + " " + categoryOptionCombo.getDisplayName();
-
- staxWriter.writeComment( "DataElement: " + label );
+ String label = dataElement.getDisplayName();
+
+ if ( !categoryOptionCombo.isDefault() )
+ {
+ label += " " + categoryOptionCombo.getDisplayName();
+ }
+
+ if ( comment )
+ {
+ staxWriter.writeComment( "DataElement: " + label );
+ }
+
staxWriter.writeStartElement( "", "dataValue", DxfNamespaces.DXF_2_0 );
staxWriter.writeAttribute( "dataElement", dataElement.getUid() );
staxWriter.writeAttribute( "categoryOptionCombo", categoryOptionCombo.getUid() );