← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3499: added targetlinelabel, also adds targetlinelabel to tablealteror since hbm2ddl couldn't add it

 

------------------------------------------------------------
revno: 3499
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-05-02 14:54:28 +0200
message:
  added targetlinelabel, also adds targetlinelabel to tablealteror since hbm2ddl couldn't add it
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm


--
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-api/src/main/java/org/hisp/dhis/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2011-04-18 12:06:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2011-05-02 12:54:28 +0000
@@ -48,50 +48,61 @@
     private static final long serialVersionUID = 2570074075484545534L;
 
     public static final String DIMENSION_PERIOD = "period";
+
     public static final String DIMENSION_ORGANISATIONUNIT = "organisationUnit";
+
     public static final String DIMENSION_INDICATOR = "indicator";
-    
+
     public static final String TYPE_BAR = "bar";
+
     public static final String TYPE_BAR3D = "bar3d";
+
     public static final String TYPE_LINE = "line";
+
     public static final String TYPE_LINE3D = "line3d";
+
     public static final String TYPE_PIE = "pie";
+
     public static final String TYPE_PIE3D = "pie3d";
 
     public static final String SIZE_NORMAL = "normal";
+
     public static final String SIZE_WIDE = "wide";
+
     public static final String SIZE_TALL = "tall";
-        
+
     private int id;
-    
+
     private String title;
-    
+
     private String type;
-    
+
     private String size;
-    
+
     private String dimension;
-    
+
     private Boolean hideLegend;
-    
+
     private Boolean verticalLabels;
-    
+
     private Boolean horizontalPlotOrientation;
-    
+
     private Boolean regression;
-    
+
     private Boolean targetLine;
 
     private Double targetLineValue;
 
+    private String targetLineLabel;
+
     private List<Indicator> indicators = new ArrayList<Indicator>();
 
     private List<Period> periods = new ArrayList<Period>();
-    
+
     private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
-    
+
     private RelativePeriods relatives;
-    
+
     private Boolean userOrganisationUnit;
 
     // -------------------------------------------------------------------------
@@ -101,38 +112,38 @@
     private transient I18nFormat format;
 
     private List<Period> relativePeriods = new ArrayList<Period>();
-    
+
     private List<Period> allPeriods = new ArrayList<Period>();
-    
+
     private OrganisationUnit organisationUnit;
-    
+
     private List<OrganisationUnit> allOrganisationUnits = new ArrayList<OrganisationUnit>();
-    
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
 
     public Chart()
-    {   
+    {
     }
-    
+
     public Chart( String title )
     {
         this.title = title;
     }
-    
+
     public void init()
     {
         allPeriods.addAll( periods );
         allPeriods.addAll( relativePeriods );
         allOrganisationUnits.addAll( organisationUnits );
-        
+
         if ( organisationUnit != null )
         {
             allOrganisationUnits.add( organisationUnit );
         }
     }
-    
+
     // -------------------------------------------------------------------------
     // hashCode, equals, toString
     // -------------------------------------------------------------------------
@@ -150,22 +161,22 @@
         {
             return true;
         }
-        
+
         if ( object == null )
         {
             return false;
         }
-        
+
         if ( getClass() != object.getClass() )
         {
             return false;
         }
-        
+
         Chart other = (Chart) object;
-        
+
         return title.equals( other.getTitle() );
     }
-    
+
     @Override
     public String toString()
     {
@@ -180,32 +191,32 @@
     {
         return this.type != null && this.type.equals( type );
     }
-    
+
     public boolean isSize( String size )
     {
         return this.size != null && this.size.equals( size );
     }
-    
+
     public boolean isDimension( String dimension )
     {
         return this.dimension != null && this.dimension.equals( dimension );
     }
-    
+
     public boolean isHideLegend()
     {
         return hideLegend != null && hideLegend;
     }
-    
+
     public boolean isVerticalLabels()
     {
         return verticalLabels != null && verticalLabels;
     }
-    
+
     public boolean isHorizontalPlotOrientation()
     {
         return horizontalPlotOrientation != null && horizontalPlotOrientation;
     }
-    
+
     public boolean isRegression()
     {
         return regression != null && regression;
@@ -215,17 +226,17 @@
     {
         return targetLine != null && targetLine;
     }
-    
+
     public int getWidth()
     {
         return isSize( SIZE_WIDE ) ? 1000 : 700;
     }
-    
+
     public int getHeight()
     {
         return isSize( SIZE_TALL ) ? 800 : 500;
     }
-    
+
     public boolean isUserOrganisationUnit()
     {
         return userOrganisationUnit != null && userOrganisationUnit;
@@ -239,12 +250,12 @@
     {
         return title;
     }
-    
+
     public void setName( String name )
     {
         this.title = name;
     }
-    
+
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------
@@ -353,12 +364,26 @@
     {
         this.targetLineValue = targetLineValue;
     }
-    
+
     public Double getTargetLineValue()
     {
         return targetLineValue;
     }
-    
+
+    public void setTargetLineLabel( String targetLineLabel )
+    {
+        this.targetLineLabel = targetLineLabel;
+    }
+
+    public String getTargetLineLabel()
+    {
+        if(targetLineLabel == null || targetLineLabel.length() == 0) {
+            targetLineLabel = "Target Line";
+        }
+        
+        return targetLineLabel;
+    }
+
     public List<Indicator> getIndicators()
     {
         return indicators;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2011-05-02 12:54:28 +0000
@@ -227,7 +227,7 @@
         executeSql( "ALTER TABLE aggregateddatavalue DROP COLUMN modified");
         executeSql( "ALTER TABLE aggregatedindicatorvalue DROP COLUMN modified ");
         executeSql( "UPDATE indicatortype SET indicatornumber=false WHERE indicatornumber is null" );
-        
+
         // remove outdated relative periods
         
         executeSql( "ALTER TABLE reporttable DROP COLUMN last3months" );
@@ -279,6 +279,9 @@
         executeSql( "ALTER TABLE datavaluearchive DROP CONSTRAINT fk_datavaluearchive_sourceid" );
         executeSql( "ALTER TABLE organisationunit DROP CONSTRAINT fke509dd5ef1c932ed" );
         executeSql( "DROP TABLE source CASCADE" );        
+
+        // add columns to chart
+        executeSql( "ALTER TABLE chart ADD COLUMN targetlinelabel varchar(255)" );
         
         log.info( "Tables updated" );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2011-04-21 15:15:12 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2011-05-02 12:54:28 +0000
@@ -80,9 +80,13 @@
 import org.hisp.dhis.user.User;
 import org.jfree.chart.ChartFactory;
 import org.jfree.chart.JFreeChart;
+import org.jfree.chart.LegendItem;
+import org.jfree.chart.LegendItemCollection;
+import org.jfree.chart.LegendItemSource;
 import org.jfree.chart.axis.CategoryAxis;
 import org.jfree.chart.axis.CategoryLabelPositions;
 import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.block.Arrangement;
 import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
 import org.jfree.chart.plot.CategoryPlot;
 import org.jfree.chart.plot.DatasetRenderingOrder;
@@ -100,6 +104,7 @@
 import org.jfree.chart.title.TextTitle;
 import org.jfree.data.category.CategoryDataset;
 import org.jfree.data.category.DefaultCategoryDataset;
+import org.jfree.ui.RectangleInsets;
 import org.jfree.util.TableOrder;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -539,17 +544,21 @@
             plot.setRenderer( 1, lineRenderer );
         }
 
+        JFreeChart jFreeChart = new JFreeChart( chart.getTitle(), titleFont, plot, !chart.isHideLegend() );
+
         if ( chart.isTargetLine() )
         {
             Marker marker = new ValueMarker( chart.getTargetLineValue() );
             marker.setPaint( Color.BLACK );
-            marker.setStroke( new BasicStroke( 1.2f ) );
+            marker.setStroke( new BasicStroke( 1.1f ) );
+            marker.setLabel( chart.getTargetLineLabel() );
+            marker.setLabelOffset( new RectangleInsets( -10, 40, 0, 0 ) );
+            marker.setLabelFont( subTitleFont );
 
             plot.addRangeMarker( marker );
         }
 
-        JFreeChart jFreeChart = new JFreeChart( chart.getTitle(), titleFont, plot, !chart.isHideLegend() );
-
+        
         if ( subTitle )
         {
             jFreeChart.addSubtitle( getSubTitle( chart, chart.getFormat() ) );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2011-04-24 12:17:55 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2011-05-02 12:54:28 +0000
@@ -32,6 +32,8 @@
 
     <property name="targetLineValue" />
 
+    <property name="targetLineLabel" />
+
     <list name="indicators" table="chart_indicators">
       <cache usage="read-write" />
       <key column="chartid" />

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm	2011-03-20 21:45:37 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm	2011-05-02 12:54:28 +0000
@@ -38,34 +38,39 @@
   #set( $count = $count + 1 )
   <tr>
     <td  style="#if( $mark == 1 )background-color:#e0e0e0;#end padding-right:50px;">
-      <span id="value[$dataElement.id].name" title="$!encoder.htmlEncode( $dataElement.description )">$encoder.htmlEncode( $dataElement.name )</span><span id="value[$dataElement.id].type" class="hidden">$dataElement.getDetailedNumberType()</span>
+      <span id="value[$dataElement.id].name" title="$!encoder.htmlEncode( $dataElement.description )">$encoder.htmlEncode( $dataElement.name )</span>
+      <span id="value[$dataElement.id].type" class="hidden">$dataElement.getDetailedNumberType()</span>
     </td>
+
     #foreach( $optionCombo in $optionCombos )
-    #set( $minMax = false )
-    #set( $minMax = $minMaxMap.get( "$dataElement.id:$optionCombo.id" ) )
-    #set( $dataValue = false )
-    #set( $dataValue = $dataValueMap.get( "$dataElement.id:$optionCombo.id" ) )
-    #set( $dataEntryId = "value[$dataElement.id].value:value[$optionCombo.id].value" )
-    #set( $minMaxError = false )
-    #if( $dataElement.type == "int" && $dataValue && $minMax )
-      #if( $integer.parseInt( $dataValue.value ) < $minMax.min || $integer.parseInt( $dataValue.value ) > $minMax.max )
-      #set( $minMaxError = true )
-      #end
-    #end
-    <span id="value[${dataElement.id}:${optionCombo.id}].min" class="hidden">$!minMax.min</span><span id="value[${dataElement.id}:${optionCombo.id}].max" class="hidden">$!minMax.max</span>
-    <td>
-    #if( $dataElement.type == "bool" )
-    <span id="value[option$optionCombo.id].name" style="display:none">$optionCombo.name</span>
-    <select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) onchange="saveBoolean($dataElement.id,$optionCombo.id, this )"  #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
-      <option value="">[$i18n.getString( "no_value" )]</option>
-      <option value="true" #if( $dataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
-      <option value="false" #if( $dataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>
-    </select>
-    #else
-    <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveVal(${dataElement.id},${optionCombo.id})" ondblclick="viewHist(${dataElement.id},${optionCombo.id})" #else disabled="disabled"#end onkeyup="return keyPress(event,this)" class="entryField #if( $minMaxError ) minmax#end" tabindex="$tabIndex" #if( $locked )disabled="disabled"#end>
-    #end
-    </td>
-    #set( $tabIndex = $tabIndex + 1 )
+	    #set( $minMax = false )
+	    #set( $minMax = $minMaxMap.get( "$dataElement.id:$optionCombo.id" ) )
+	    #set( $dataValue = false )
+	    #set( $dataValue = $dataValueMap.get( "$dataElement.id:$optionCombo.id" ) )
+	    #set( $dataEntryId = "value[$dataElement.id].value:value[$optionCombo.id].value" )
+	    #set( $minMaxError = false )
+	    #if( $dataElement.type == "int" && $dataValue && $minMax )
+	      #if( $integer.parseInt( $dataValue.value ) < $minMax.min || $integer.parseInt( $dataValue.value ) > $minMax.max )
+	      	#set( $minMaxError = true )
+	      #end
+	    #end
+
+	    <span id="value[${dataElement.id}:${optionCombo.id}].min" class="hidden">$!minMax.min</span>
+	    <span id="value[${dataElement.id}:${optionCombo.id}].max" class="hidden">$!minMax.max</span>
+
+	    <td>
+	    #if( $dataElement.type == "bool" )
+		    <span id="value[option$optionCombo.id].name" style="display:none">$optionCombo.name</span>
+		    <select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) onchange="saveBoolean($dataElement.id,$optionCombo.id, this )"  #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
+		      <option value="">[$i18n.getString( "no_value" )]</option>
+		      <option value="true" #if( $dataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
+		      <option value="false" #if( $dataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>
+		    </select>
+	    #else
+		    <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveVal(${dataElement.id},${optionCombo.id})" ondblclick="viewHist(${dataElement.id},${optionCombo.id})" #else disabled="disabled"#end onkeyup="return keyPress(event,this)" class="entryField #if( $minMaxError ) minmax#end" tabindex="$tabIndex" #if( $locked )disabled="disabled"#end>
+	    #end
+	    </td>
+	    #set( $tabIndex = $tabIndex + 1 )
     #end
   </tr>
   #end

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2011-03-18 12:29:01 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/history.vm	2011-05-02 12:54:28 +0000
@@ -22,9 +22,9 @@
 	<tr>		
 		<!-- Column 1 - Comment and Followup -->
 		<td valign="top">			
-			<h4>$i18n.getString( "dataelement_comment" )</h4>       
+			<h4>$i18n.getString( "dataelement_comment" )</h4>
 			#if( $showComment == 'true' )
-			##comment       
+			##comment
 			    <select id="value[$dataElementHistory.dataElement.id:$dataElementHistory.optionCombo.id].comments" #if( $auth.hasAccess( "dhis-web-dataentry", "saveComment" ) ) onchange="commentSelected()" #else disabled="disabled" #end #if( $dataValue.comment && !$standardComments.contains( $dataValue.comment ) ) style="display:none; width:100%" #end#if( $locked ) disabled="disabled"#end>
 			        <option value="">[$i18n.getString( "no_comment" )]</option>
 			        <option value="custom">[$i18n.getString( "custom_comment" )]</option>
@@ -35,7 +35,7 @@
 			    <input id="value[$dataElementHistory.dataElement.id:$dataElementHistory.optionCombo.id].comment" type="text" value="$!encoder.htmlEncode( $dataValue.comment )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveComment" ))
 			        onblur="commentLeft()" #else disabled="disabled" #end style="width:100% #if( !$dataValue.comment || $standardComments.contains( $dataValue.comment )) ;display:none #end"/>
 			#end
-			
+
 			<br/><br/>
 			<h4>$i18n.getString( "followup" )</h4>
 			

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java	2011-04-14 13:06:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java	2011-05-02 12:54:28 +0000
@@ -166,6 +166,12 @@
         this.targetLineValue = targetLineValue;
     }
 
+    private String targetLineLabel;
+    
+    public void setTargetLineLabel( String targetLineLabel ) {
+        this.targetLineLabel = targetLineLabel;
+    }
+
     private boolean userOrganisationUnit;
 
     public void setUserOrganisationUnit( boolean userOrganisationUnit )
@@ -277,6 +283,7 @@
         chart.setRegression( regression );
         chart.setTargetLine( targetLine );
         chart.setTargetLineValue( targetLineValue );
+        chart.setTargetLineLabel( targetLineLabel );
         chart.setUserOrganisationUnit( userOrganisationUnit );
         chart.setIndicators( indicators );
         chart.setPeriods( periods );

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-04-18 12:06:28 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-05-02 12:54:28 +0000
@@ -205,6 +205,7 @@
 include_regression= Include regression
 include_target_line= Include target line
 target_line_value= Target line value
+target_line_label= Target line label
 select = Select
 criteria = Criteria
 this_indicator_and_periods = This indicator and periods

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm	2011-04-18 12:06:28 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addChartForm.vm	2011-05-02 12:54:28 +0000
@@ -2,11 +2,18 @@
 	jQuery(document).ready(function() {
 		if( jQuery("#targetLine").attr("checked") !== true )
 		{
-			jQuery("#targetLineValueTr").hide();
+			jQuery("#targetLineValue").attr("disabled", "disabled");
+			jQuery("#targetLineLabel").attr("disabled", "disabled");
 		}
-	
+
 		jQuery("#targetLine").change(function() {
-			jQuery("#targetLineValueTr").toggle();		
+			if(jQuery("#targetLineValue").attr("disabled")) {
+				jQuery("#targetLineValue").removeAttr("disabled");
+				jQuery("#targetLineLabel").removeAttr("disabled");
+			} else {
+				jQuery("#targetLineValue").attr("disabled", "disabled");
+				jQuery("#targetLineLabel").attr("disabled", "disabled");
+			}
 		});
 	});
 
@@ -85,10 +92,14 @@
         <td><label for="targetLine">$i18n.getString( "include_target_line" )</label></td>
         <td><input type="checkbox" id="targetLine" name="targetLine" value="true"#if( $!chart.targetLine ) checked#end></td>
     </tr>
-    <tr id="targetLineValueTr">
+    <tr>
         <td><label for="targetLineValue">$i18n.getString( "target_line_value" )</label></td>
         <td><input type="text" id="targetLineValue" name="targetLineValue" style="width:80px" value="$!chart.targetLineValue"></td>
     </tr>
+    <tr>
+        <td><label for="targetLineLabel">$i18n.getString( "target_line_label" )</label></td>
+        <td><input type="text" id="targetLineLabel" name="targetLineLabel" style="width:80px" value="$!chart.targetLineLabel"></td>
+    </tr>
     #if ( $currentUser && $currentUser.hasOrganisationUnit() )
     <tr>
         <td><label for="userOrganisationUnit">$i18n.getString( "user_organisation_unit" )</label></td>