← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17: Improved DHIS 1.4 XML export.

 

------------------------------------------------------------
revno: 17
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Mon 2009-03-09 15:42:31 +0100
message:
  Improved DHIS 1.4 XML export.
modified:
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/CalculatedDataElementAssociationConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/DataElementXSDConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/IndicatorTypeXSDConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/IndicatorXSDConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ixf/converter/DataConverter.java

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/CalculatedDataElementAssociationConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/CalculatedDataElementAssociationConverter.java	2009-03-09 14:11:42 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/CalculatedDataElementAssociationConverter.java	2009-03-09 14:42:31 +0000
@@ -36,7 +36,6 @@
 import org.amplecode.staxwax.reader.XMLReader;
 import org.amplecode.staxwax.writer.XMLWriter;
 import org.hisp.dhis.dataelement.CalculatedDataElement;
-import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataelement.Operand;
 import org.hisp.dhis.importexport.ExportParams;
@@ -87,23 +86,19 @@
 
     public void write( XMLWriter writer, ExportParams params )
     {
-        Collection<DataElement> elements = dataElementService.getDataElements( params.getCalculatedDataElements() );
+        Collection<CalculatedDataElement> elements = dataElementService.getCalculatedDataElements( params.getCalculatedDataElements() );
         
         if ( elements != null && elements.size() > 0 )
         {
-            CalculatedDataElement calculatedElement = null;
-            
-            for ( DataElement element : elements )
+            for ( CalculatedDataElement element : elements )
             {
-                calculatedElement = (CalculatedDataElement) element;
-                
-                Map<Operand, Double> factorMap = Dhis14ParsingUtils.getOperandFactors( calculatedElement );
+                Map<Operand, Double> factorMap = Dhis14ParsingUtils.getOperandFactors( element );
                 
                 for ( Entry<Operand, Double> entry : factorMap.entrySet() )
                 {
                     writer.openElement( ELEMENT_NAME );
                     
-                    writer.writeElement( FIELD_ID, String.valueOf( calculatedElement.getId() ) );
+                    writer.writeElement( FIELD_ID, String.valueOf( element.getId() ) );
                     writer.writeElement( FIELD_DATAELEMENT, String.valueOf( entry.getKey().getDataElementId() ) );
                     writer.writeElement( FIELD_FACTOR, String.valueOf( entry.getValue() ) );
                     

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/DataElementXSDConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/DataElementXSDConverter.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/DataElementXSDConverter.java	2009-03-09 14:42:31 +0000
@@ -57,7 +57,7 @@
     
     public void write( XMLWriter writer, ExportParams params )
     {
-        if ( params.getDataElements().size() > 0 )
+        if ( params.getDataElements() != null && params.getDataElements().size() > 0 )
         {
             writer.openElement( "xsd:element", "name", "DataElement" );
             

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/IndicatorTypeXSDConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/IndicatorTypeXSDConverter.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/IndicatorTypeXSDConverter.java	2009-03-09 14:42:31 +0000
@@ -57,7 +57,7 @@
     
     public void write( XMLWriter writer, ExportParams params )
     {
-        if ( params.getIndicators().size() > 0 )
+        if ( params.getIndicators() != null && params.getIndicators().size() > 0 )
         {
             writer.openElement( "xsd:element", "name", "IndicatorType" );
     

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/IndicatorXSDConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/IndicatorXSDConverter.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/xsd/IndicatorXSDConverter.java	2009-03-09 14:42:31 +0000
@@ -57,7 +57,7 @@
     
     public void write( XMLWriter writer, ExportParams params )
     {
-        if ( params.getIndicators().size() > 0 )
+        if ( params.getIndicators() != null && params.getIndicators().size() > 0 )
         {
             writer.openElement( "xsd:element", "name", "Indicator" );
             

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ixf/converter/DataConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ixf/converter/DataConverter.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ixf/converter/DataConverter.java	2009-03-09 14:42:31 +0000
@@ -144,10 +144,10 @@
             
             value.setOptionCombo( categoryOptionCombo );
 
-            Period period = new Period();          
+            final Period period = new Period();          
             value.setPeriod( period );
             
-            Source source = new OrganisationUnit();
+            final Source source = new OrganisationUnit();
             value.setSource( source );
 
             reader.moveToStartElement( FIELD_VALUE );



--

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.