← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2256: (GIS) Export to image bug (data elements) fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2256 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-09-27 13:20:21 +0200
message:
  (GIS) Export to image bug (data elements) fixed.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js


--
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-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java	2010-09-03 14:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/ExportImageAction.java	2010-09-27 11:18:38 +0000
@@ -35,6 +35,9 @@
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.mapping.MappingService;
 import org.hisp.dhis.mapping.export.SVGDocument;
 import org.hisp.dhis.mapping.export.SVGUtils;
 import org.hisp.dhis.period.Period;
@@ -71,6 +74,20 @@
     {
         this.indicatorService = indicatorService;
     }
+    
+    private DataElementService dataElementService;
+    
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+    
+    private MappingService mappingService;
+    
+    public void setMappingService( MappingService mappingService )
+    {
+        this.mappingService = mappingService;
+    }
 
     // -------------------------------------------------------------------------
     // Output & input
@@ -151,14 +168,28 @@
         else
         {
             log.info( "Export map from request" );
-
+            
             Indicator _indicator = indicatorService.getIndicator( indicator );
-
+            
+            DataElement _dataElement = dataElementService.getDataElement( indicator );
+            
             svgDocument = new SVGDocument();
-
+            
             svgDocument.setTitle( title );
             svgDocument.setSvg( svg );
-            svgDocument.setIndicator( _indicator );
+            
+            if ( _indicator != null )
+            {
+                svgDocument.setIndicator( _indicator );
+                svgDocument.setDataElement( null );
+            }
+            
+            else
+            {
+                svgDocument.setIndicator( null );
+                svgDocument.setDataElement( _dataElement );
+            }
+            
             svgDocument.setPeriod( period );
             svgDocument.setLegends( legends );
             svgDocument.setIncludeLegends( includeLegends );

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java	2010-09-03 14:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java	2010-09-27 11:18:38 +0000
@@ -30,8 +30,8 @@
 import net.sf.json.JSONObject;
 import net.sf.json.JSONSerializer;
 
+import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.period.Period;
 
 /**
  * @author Tran Thanh Tri
@@ -54,6 +54,8 @@
     private String period;
 
     private Indicator indicator;
+    
+    private DataElement dataElement;
 
     private boolean includeLegends;
 
@@ -67,11 +69,13 @@
 
     public StringBuffer getSVGForImage()
     {
+        String indicatorName = this.indicator != null ? this.indicator.getName() : this.dataElement.getName();
+        
         String title_ = "<g id=\"title\" style=\"display: block; visibility: visible;\"><text id=\"title\" x=\"30\" y=\"15\" font-size=\"14\" font-weight=\"bold\"><tspan>"
             + this.title + "</tspan></text></g>";
 
         String indicator_ = "<g id=\"indicator\" style=\"display: block; visibility: visible;\"><text id=\"indicator\" x=\"30\" y=\"30\" font-size=\"12\"><tspan>"
-            + this.indicator.getName() + "</tspan></text></g>";
+            + indicatorName + "</tspan></text></g>";
 
         String period_ = "<g id=\"period\" style=\"display: block; visibility: visible;\"><text id=\"period\" x=\"30\" y=\"45\" font-size=\"12\"><tspan>"
             + this.period + "</tspan></text></g>";
@@ -253,6 +257,16 @@
         this.indicator = indicator;
     }
 
+    public DataElement getDataElement()
+    {
+        return dataElement;
+    }
+
+    public void setDataElement( DataElement dataElement )
+    {
+        this.dataElement = dataElement;
+    }
+
     public int getWidth()
     {
         return width;

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2010-09-09 19:19:51 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2010-09-27 11:18:38 +0000
@@ -365,6 +365,7 @@
 		scope="prototype">
 		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 		<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.mapping.action.ExportExcelAction" class="org.hisp.dhis.mapping.action.ExportExcelAction"

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-23 19:10:28 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-27 11:18:38 +0000
@@ -154,7 +154,7 @@
 Ext.onReady( function() {
     Ext.BLANK_IMAGE_URL = '../resources/ext/resources/images/default/s.gif';
 	/* Ext 3.2.0 override */
-	Ext.override(Ext.form.Field,{showField:function(){this.show();this.container.up('div.x-form-item').setDisplayed( true );},hideField:function(){this.hide();this.container.up('div.x-form-item').setDisplayed( false );}});
+	Ext.override(Ext.form.Field,{showField:function(){this.show();this.container.up('div.x-form-item').setDisplayed(true);},hideField:function(){this.hide();this.container.up('div.x-form-item').setDisplayed(false);}});
     /* Disallow right clicks */
 	document.body.oncontextmenu = function(){return false;};
 	/* Activate tooltip */
@@ -599,17 +599,14 @@
                         lcb = Ext.getCmp('maplegendtype_cb').getValue() == map_legend_type_automatic ? true : Ext.getCmp('maplegendset_cb').getValue() ? true : false;
                     }
                     else if (ACTIVEPANEL == thematicMap2) {
-                        vcb = Ext.getCmp('mapvaluetype_cb2').getValue() == map_value_type_indicator ? Ext.getCmp('indicator_cb2').getValue() : Ext.getCmp('dataelement_cb2').getValue();
-                        dcb = MAPDATETYPE == map_date_type_fixed ? Ext.getCmp('period_cb2').getValue() : Ext.getCmp('startdate_df2').getValue() && Ext.getCmp('startdate_df2').getValue() ? true : false;
-                        period = MAPDATETYPE == map_date_type_fixed ? Ext.getCmp('period_cb2').getRawValue() : new Date(Ext.getCmp('startdate_df2').getRawValue()).format('Y M j') + ' - ' + new Date(Ext.getCmp('enddate_df2').getRawValue()).format('Y M j');
-                        mcb = MAPSOURCE == map_source_type_database ? Ext.getCmp('map_tf2').getValue() : Ext.getCmp('map_cb2').getValue();
-                        lcb = Ext.getCmp('maplegendtype_cb2').getValue() == map_legend_type_automatic ? true : Ext.getCmp('maplegendset_cb2').getValue() ? true : false;
+                        Ext.message.msg(false,'Please use the <span class="x-msg-hl">polygon layer</span> for printing');
+                        return;
                     }
                     else {
                         Ext.message.msg(false, i18n_please_expand_layer_panel);
                         return;
-                    }   
-
+                    }
+                    
                     if (vcb && dcb && mcb && lcb) {
                     	
 						var svgElement = document.getElementsByTagName('svg')[0];

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2010-09-24 22:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2010-09-27 11:18:38 +0000
@@ -687,10 +687,10 @@
                                         }
                                         Ext.getCmp('colorA_cf').showField();
                                         Ext.getCmp('colorB_cf').showField();
-                                        Ext.getCmp('maplegendset_cb').hideField();       
-
-                                        this.classify(false, true);
+                                        Ext.getCmp('maplegendset_cb').hideField();
                                     }
+
+                                    this.classify(false, true);
                                 }
                             },
                             failure: function() {
@@ -791,10 +791,10 @@
                                         }
                                         Ext.getCmp('colorA_cf').showField();
                                         Ext.getCmp('colorB_cf').showField();
-                                        Ext.getCmp('maplegendset_cb').hideField();       
-
-                                        this.classify(false, true);
+                                        Ext.getCmp('maplegendset_cb').hideField();
                                     }
+
+                                    this.classify(false, true);
                                 }
                             },
                             failure: function() {

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-09-24 22:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-09-27 11:18:38 +0000
@@ -583,10 +583,10 @@
                                         }
                                         Ext.getCmp('colorA_cf2').showField();
                                         Ext.getCmp('colorB_cf2').showField();
-                                        Ext.getCmp('maplegendset_cb2').hideField();       
-
-                                        this.classify(false, true);
+                                        Ext.getCmp('maplegendset_cb2').hideField();  
                                     }
+
+                                    this.classify(false, true);
                                 }
                             },
                             failure: function() {
@@ -687,10 +687,10 @@
                                         }
                                         Ext.getCmp('colorA_cf2').showField();
                                         Ext.getCmp('colorB_cf2').showField();
-                                        Ext.getCmp('maplegendset_cb2').hideField();       
-
-                                        this.classify(false, true);
+                                        Ext.getCmp('maplegendset_cb2').hideField();  
                                     }
+
+                                    this.classify(false, true);
                                 }
                             },
                             failure: function() {