← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19539: Removed some hard coded strings

 

------------------------------------------------------------
revno: 19539
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-07-03 18:24:16 +0100
message:
  Removed some hard coded strings
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXConstants.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXConstants.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXConstants.java	2015-06-18 12:59:02 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXConstants.java	2015-07-03 17:24:16 +0000
@@ -43,12 +43,14 @@
     final String ROOT = "adx";
 
     final String GROUP = "group";
+
+    final String DATASET = "dataSet";
     
     final String PERIOD = "period";
     
     final String ORGUNIT = "orgUnit";
     
-    final String DATAELEMENT = "dataelement";
+    final String DATAELEMENT = "dataElement";
 
     final String DATAVALUE = "dataValue";
 

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java	2015-07-03 16:55:12 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java	2015-07-03 17:24:16 +0000
@@ -205,14 +205,14 @@
 
         Map<String, String> groupAttributes = readAttributes( adxReader );
 
-        if (!groupAttributes.containsKey( "period"))
+        if (!groupAttributes.containsKey( ADXConstants.PERIOD))
         {
-            throw new ADXException("'period' attribute is required on 'group'");
+            throw new ADXException( ADXConstants.PERIOD + " attribute is required on 'group'");
         }
         
-        if (!groupAttributes.containsKey( "orgUnit"))
+        if (!groupAttributes.containsKey( ADXConstants.ORGUNIT))
         {
-            throw new ADXException("'orgUnit' attribute is required on 'group'");
+            throw new ADXException( ADXConstants.ORGUNIT + " attribute is required on 'group'");
         }
 
         // translate adx period to dxf2
@@ -222,14 +222,14 @@
         dxfWriter.writeAttribute( "period", period.getIsoDate() );
 
         // process adx group attributes
-        if (!groupAttributes.containsKey( "attributeOptionCombo") && groupAttributes.containsKey( "dataSet"))
+        if (!groupAttributes.containsKey( ADXConstants.ATTOPTCOMBO) && groupAttributes.containsKey( ADXConstants.DATASET ))
         {
             log.debug( "No attributeOptionCombo present.  Check dataSet for attribute categorycombo");
             
-            DataSet dataSet = identifiableObjectManager.getObject( DataSet.class, dataElementIdScheme, groupAttributes.get( "dataSet"));
-            groupAttributes.put( "dataSet", dataSet.getUid());
+            DataSet dataSet = identifiableObjectManager.getObject( DataSet.class, dataElementIdScheme, groupAttributes.get( ADXConstants.DATASET ));
+            groupAttributes.put( ADXConstants.DATASET, dataSet.getUid());
             DataElementCategoryCombo attributeCombo = dataSet.getCategoryCombo();
-            attributesToDXF("attributeOptionCombo", attributeCombo, groupAttributes, dataElementIdScheme);
+            attributesToDXF(ADXConstants.ATTOPTCOMBO, attributeCombo, groupAttributes, dataElementIdScheme);
         }
         
         // write the remaining attributes through to dxf stream
@@ -253,33 +253,33 @@
     {
         Map<String, String> dvAttributes = readAttributes( adxReader );
 
-        if (!dvAttributes.containsKey( "dataElement"))
+        if (!dvAttributes.containsKey( ADXConstants.DATAELEMENT ))
         {
-            throw new ADXException("'dataElement' attribute is required on 'dataValue'");
+            throw new ADXException(ADXConstants.DATAELEMENT + " attribute is required on 'dataValue'");
         }
         
-        if (!dvAttributes.containsKey( "value"))
+        if (!dvAttributes.containsKey( ADXConstants.VALUE))
         {
-            throw new ADXException("'value' attribute is required on 'dataValue'");
+            throw new ADXException(ADXConstants.VALUE + " attribute is required on 'dataValue'");
         }
         
         IdentifiableProperty dataElementIdScheme = importOptions.getDataElementIdScheme();
 
         dxfWriter.writeStartElement( "dataValue" );
         
-        DataElement dataElement = identifiableObjectManager.getObject( DataElement.class, dataElementIdScheme, dvAttributes.get( "dataElement") );
+        DataElement dataElement = identifiableObjectManager.getObject( DataElement.class, dataElementIdScheme, dvAttributes.get( ADXConstants.DATAELEMENT ));
         DataElementCategoryCombo categoryCombo = dataElement.getCategoryCombo();
             
-        attributesToDXF("categoryOptionCombo", categoryCombo, dvAttributes, dataElementIdScheme);
+        attributesToDXF(ADXConstants.CATOPTCOMBO, categoryCombo, dvAttributes, dataElementIdScheme);
         
         // if dataelement type is string we need to pick out the 'annotation' element
         if (dataElement.getType().equals( DataElement.VALUE_TYPE_STRING ))
         {
-            adxReader.moveToStartElement( "annotation", "datavalue");
-            if (adxReader.isStartElement("annotation"))
+            adxReader.moveToStartElement( ADXConstants.ANNOTATION, ADXConstants.DATAVALUE );
+            if (adxReader.isStartElement(ADXConstants.ANNOTATION ))
             {
                 String textValue = adxReader.getElementValue();
-                dvAttributes.put( "value", textValue);
+                dvAttributes.put( ADXConstants.VALUE, textValue);
             }
             else
             {