← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6756: (DV) Favorite rename/overwrite bugs fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 6756 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-04-26 14:04:54 +0000
message:
  (DV) Favorite rename/overwrite bugs fixed.
added:
  dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/UpdateChartNameAction.java
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml
  dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java
  dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.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-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	2012-04-21 09:33:17 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2012-04-26 13:36:44 +0000
@@ -15,7 +15,9 @@
     </id>
 
     <property name="name" column="name" not-null="true" length="230" />
+	  
     <property name="uid" column="uid" length="11" />
+	  
     <property name="lastUpdated" type="timestamp" />
 
     <property name="domainAxisLabel" />

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java	2012-04-19 13:58:20 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/AddOrUpdateChartAction.java	2012-04-26 13:36:44 +0000
@@ -27,7 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.hisp.dhis.chart.Chart;
@@ -147,21 +146,21 @@
         this.filter = filter;
     }
 
-    private List<Integer> indicatorIds = new ArrayList<Integer>();
+    private List<Integer> indicatorIds;
 
     public void setIndicatorIds( List<Integer> indicatorIds )
     {
         this.indicatorIds = indicatorIds;
     }
 
-    private List<Integer> dataElementIds = new ArrayList<Integer>();
+    private List<Integer> dataElementIds;
 
     public void setDataElementIds( List<Integer> dataElementIds )
     {
         this.dataElementIds = dataElementIds;
     }
 
-    private List<Integer> dataSetIds = new ArrayList<Integer>();
+    private List<Integer> dataSetIds;
 
     public void setDataSetIds( List<Integer> dataSetIds )
     {
@@ -343,7 +342,7 @@
     public String execute()
         throws Exception
     {
-        Chart chart = null;
+        Chart chart;
 
         if ( uid != null )
         {
@@ -352,57 +351,39 @@
         else
         {
             chart = new Chart();
-        }
 
-        if ( name != null )
-        {
             chart.setName( name );
         }
 
-        if ( type != null )
-        {
-            chart.setType( type );
-        }
-
-        if ( series != null )
-        {
-            chart.setSeries( series );
-        }
-
-        if ( category != null )
-        {
-            chart.setCategory( category );
-        }
-
-        if ( filter != null )
-        {
-            chart.setFilter( filter );
-        }
+        chart.setType( type );
+        chart.setSeries( series );
+        chart.setCategory( category );
+        chart.setFilter( filter );
+
+        chart.getIndicators().clear();
 
         if ( indicatorIds != null )
         {
-            chart.getIndicators().clear();
-
             for ( Integer id : indicatorIds )
             {
                 chart.getIndicators().add( indicatorService.getIndicator( id ) );
             }
         }
 
+        chart.getDataElements().clear();
+
         if ( dataElementIds != null )
         {
-            chart.getDataElements().clear();
-
             for ( Integer id : dataElementIds )
             {
                 chart.getDataElements().add( dataElementService.getDataElement( id ) );
             }
         }
 
+        chart.getDataSets().clear();
+
         if ( dataSetIds != null )
         {
-            chart.getDataSets().clear();
-
             for ( Integer id : dataSetIds )
             {
                 chart.getDataSets().add( dataSetService.getDataSet( id ) );
@@ -426,75 +407,43 @@
             chart.setRelatives( rp );
         }
 
+        chart.getOrganisationUnits().clear();
+
         if ( organisationUnitIds != null )
         {
-            chart.getOrganisationUnits().clear();
-
             for ( Integer id : organisationUnitIds )
             {
                 chart.getOrganisationUnits().add( organisationUnitService.getOrganisationUnit( id ) );
             }
         }
 
-        if ( organisationUnitGroupSetId != null )
-        {
-            chart.setOrganisationUnitGroupSet( organisationUnitGroupService
-                .getOrganisationUnitGroupSet( organisationUnitGroupSetId ) );
-        }
-
-        if ( system == null )
-        {
-            chart.setUser( currentUserService.getCurrentUser() );
-        }
-        else
-        {
-            chart.setUser( null );
-        }
-
-        if ( trendLine != null )
-        {
-            chart.setRegression( trendLine );
-        }
-
-        if ( hideSubtitle != null )
-        {
-            chart.setHideSubtitle( hideSubtitle );
-        }
-
-        if ( hideLegend != null )
-        {
-            chart.setHideLegend( hideLegend );
-        }
-
-        if ( userOrganisationUnit != null )
-        {
-            chart.setUserOrganisationUnit( userOrganisationUnit );
-        }
-
-        if ( userOrganisationUnitChildren != null )
-        {
-            chart.setUserOrganisationUnitChildren( userOrganisationUnitChildren );
-        }
-
-        if ( showData != null )
-        {
-            chart.setShowData( showData );
-        }
-
-        if ( domainAxisLabel != null )
-        {
-            chart.setDomainAxisLabel( domainAxisLabel );
-        }
-
-        if ( rangeAxisLabel != null )
-        {
-            chart.setRangeAxisLabel( rangeAxisLabel );
-        }
+        chart.setOrganisationUnitGroupSet( organisationUnitGroupSetId != null ? organisationUnitGroupService
+            .getOrganisationUnitGroupSet( organisationUnitGroupSetId ) : null );
+
+        chart.setUser( system == null ? currentUserService.getCurrentUser() : null );
+
+        chart.setRegression( trendLine );
+
+        chart.setHideSubtitle( hideSubtitle );
+
+        chart.setHideLegend( hideLegend );
+
+        chart.setUserOrganisationUnit( userOrganisationUnit );
+
+        chart.setUserOrganisationUnitChildren( userOrganisationUnitChildren );
+
+        chart.setShowData( showData );
+
+        chart.setDomainAxisLabel( domainAxisLabel );
+
+        chart.setRangeAxisLabel( rangeAxisLabel );
 
         chart.setTargetLineValue( targetLineValue );
+
         chart.setTargetLineLabel( targetLineLabel );
 
         chart.setBaseLineValue( baseLineValue );
+
         chart.setBaseLineLabel( baseLineLabel );
 
         chartService.saveOrUpdate( chart );

=== added file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/UpdateChartNameAction.java'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/UpdateChartNameAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/UpdateChartNameAction.java	2012-04-26 13:55:41 +0000
@@ -0,0 +1,88 @@
+package org.hisp.dhis.visualizer.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.chart.Chart;
+import org.hisp.dhis.chart.ChartService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public class UpdateChartNameAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ChartService chartService;
+
+    public void setChartService( ChartService chartService )
+    {
+        this.chartService = chartService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private String uid;
+
+    public void setUid( String uid )
+    {
+        this.uid = uid;
+    }
+
+    private String name;
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        if ( uid != null && name != null )
+        {
+            Chart chart = chartService.getChart( uid );
+
+            chart.setName( name );
+
+            chartService.saveOrUpdate( chart );
+        }
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml	2012-03-09 02:29:32 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/META-INF/dhis/beans.xml	2012-04-26 13:36:44 +0000
@@ -67,6 +67,12 @@
         <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
     </bean>
 
+    <bean id="org.hisp.dhis.visualizer.action.UpdateChartNameAction"
+        class="org.hisp.dhis.visualizer.action.UpdateChartNameAction"
+        scope="prototype">
+        <property name="chartService" ref="org.hisp.dhis.chart.ChartService" />
+    </bean>
+
     <bean id="org.hisp.dhis.visualizer.action.GetSystemAndCurrentUserChartsAction"
         class="org.hisp.dhis.visualizer.action.GetSystemAndCurrentUserChartsAction"
         scope="prototype">

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/struts.xml	2012-01-25 10:30:44 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/struts.xml	2012-04-26 13:55:41 +0000
@@ -65,6 +65,12 @@
                 /dhis-web-visualizer/void.vm</result>
         </action>
 
+        <action name="updateChartName"
+            class="org.hisp.dhis.visualizer.action.UpdateChartNameAction">
+            <result name="success" type="velocity-json">
+                /dhis-web-visualizer/void.vm</result>
+        </action>
+
         <action name="getSystemAndCurrentUserCharts"
             class="org.hisp.dhis.visualizer.action.GetSystemAndCurrentUserChartsAction">
             <result name="success" type="velocity-json">

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js	2012-04-18 11:33:06 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/app.js	2012-04-26 13:55:41 +0000
@@ -116,7 +116,8 @@
             organisationunitgroupset_get: 'getOrganisationUnitGroupSets.action',
             organisationunitchildren_get: 'getOrganisationUnitChildren.action',
             favorite_addorupdate: 'addOrUpdateChart.action',
-            favorite_addorupdatesystem: 'addOrUpdateSystemChart.action',            
+            favorite_addorupdatesystem: 'addOrUpdateSystemChart.action',
+            favorite_updatename: 'updateChartName.action',
             favorite_get: 'charts/',
             favorite_getall: 'getSystemAndCurrentUserCharts.action',
             favorite_delete: 'deleteCharts.action'
@@ -1273,7 +1274,7 @@
                     var r = DV.cmp.favorite.grid.getSelectionModel().getSelection()[0];
                     var url = DV.cmp.favorite.system.getValue() ? DV.conf.finals.ajax.favorite_addorupdatesystem : DV.conf.finals.ajax.favorite_addorupdate;
                     Ext.Ajax.request({
-                        url: DV.conf.finals.ajax.path_visualizer + url,
+                        url: DV.conf.finals.ajax.path_visualizer + DV.conf.finals.ajax.favorite_updatename,
                         method: 'POST',
                         params: {uid: r.data.id, name: name},
                         success: function() {