← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2300: update/add file in excel reporting

 

------------------------------------------------------------
revno: 2300
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Mon 2010-10-04 10:09:23 +0700
message:
  update/add file in excel reporting
added:
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartUserRoleAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartUserRoleFormAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/jchart/JChart.java
  dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/jchart/hibernate/JChart.hbm.xml
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/AddJChartAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties


--
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/jchart/JChart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/jchart/JChart.java	2010-10-01 03:04:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/jchart/JChart.java	2010-10-04 03:09:23 +0000
@@ -46,6 +46,8 @@
 
 public class JChart
 {
+    public static final String PERIOD_CATEGORY = "PERIOD_CATEGORY";
+    public static final String ORGANISATION_UNIT_CATEGORY = "ORGANISATION_UNIT_CATEGORY";
 
     public static final String LOAD_PERIOD_AUTO = "LOAD_PERIOD_AUTO";
 
@@ -55,6 +57,8 @@
 
     private String title;
 
+    private String categoryType;
+
     private Set<JChartSeries> series = new HashSet<JChartSeries>();
 
     private Set<Period> periods = new HashSet<Period>();
@@ -154,6 +158,16 @@
         this.id = id;
     }
 
+    public String getCategoryType()
+    {
+        return categoryType;
+    }
+
+    public void setCategoryType( String categoryType )
+    {
+        this.categoryType = categoryType;
+    }
+
     public String getTitle()
     {
         return title;

=== modified file 'dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/jchart/hibernate/JChart.hbm.xml'
--- dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/jchart/hibernate/JChart.hbm.xml	2010-10-01 03:04:13 +0000
+++ dhis-2/dhis-services/dhis-service-excel-reporting/src/main/resources/org/hisp/dhis/jchart/hibernate/JChart.hbm.xml	2010-10-04 03:09:23 +0000
@@ -13,7 +13,9 @@
 
 		<property name="title" not-null="true" />				
 		
-		<property name="loadPeriodBy" column="loadperiodby" not-null="true"/>		
+		<property name="loadPeriodBy" column="loadperiodby"/>
+		
+		<property name="categoryType" column="categorytype" not-null="true"/>	
 		
 		<many-to-one name="periodType" column="periodtypeid" class="org.hisp.dhis.period.PeriodType" 
 		foreign-key="fk_jchart_periodtypeid" not-null="true" lazy="false"/>	

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/AddJChartAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/AddJChartAction.java	2010-09-30 09:37:41 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/AddJChartAction.java	2010-10-04 03:09:23 +0000
@@ -80,7 +80,6 @@
     {
         this.title = title;
     }
-  
 
     private String legend;
 
@@ -89,6 +88,13 @@
         this.legend = legend;
     }
 
+    private String categoryType;
+
+    public void setCategoryType( String categoryType )
+    {
+        this.categoryType = categoryType;
+    }
+
     private String loadPeriodBy;
 
     public void setLoadPeriodBy( String loadPeriodBy )
@@ -136,10 +142,11 @@
         throws Exception
     {
         JChart jChart = new JChart();
-        jChart.setTitle( title );       
+        jChart.setTitle( title );
         jChart.setLegend( legend );
         jChart.setLoadPeriodBy( loadPeriodBy );
         jChart.setPeriodType( periodService.getPeriodTypeByName( periodType ) );
+        jChart.setCategoryType( categoryType );
 
         for ( int i = 0; i < indicatorIds.size(); i++ )
         {
@@ -150,7 +157,7 @@
             jChart.addSeries( s );
         }
 
-        if ( loadPeriodBy.equals( JChart.LOAD_PERIOD_SELECTED ) )
+        if ( categoryType.equals( JChart.PERIOD_CATEGORY ) && loadPeriodBy.equals( JChart.LOAD_PERIOD_SELECTED ) )
         {
 
             for ( Integer id : periodIds )

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartAction.java	2010-09-30 09:37:41 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartAction.java	2010-10-04 03:09:23 +0000
@@ -87,7 +87,7 @@
     public void setTitle( String title )
     {
         this.title = title;
-    }  
+    }
 
     private String legend;
 
@@ -138,6 +138,13 @@
         this.colors = colors;
     }
 
+    private String categoryType;
+
+    public void setCategoryType( String categoryType )
+    {
+        this.categoryType = categoryType;
+    }
+
     @Override
     public String execute()
         throws Exception
@@ -146,10 +153,11 @@
 
         PeriodType pt = periodService.getPeriodTypeByName( periodType );
 
-        jChart.setTitle( title );        
+        jChart.setTitle( title );
         jChart.setLegend( legend );
         jChart.setLoadPeriodBy( loadPeriodBy );
         jChart.setPeriodType( periodService.getPeriodTypeByClass( pt.getClass() ) );
+        jChart.setCategoryType( categoryType );
 
         jChart.clearAllSeries();
 
@@ -164,13 +172,14 @@
 
         jChart.clearAllPeriod();
 
-        if ( loadPeriodBy.equals( JChart.LOAD_PERIOD_SELECTED ) )
+        if ( categoryType.equals( JChart.PERIOD_CATEGORY ) && loadPeriodBy.equals( JChart.LOAD_PERIOD_SELECTED ) )
         {
 
             for ( Integer id : periodIds )
             {
                 jChart.addPeriod( periodService.getPeriod( id ) );
             }
+
         }
 
         jchartService.updateJChart( jChart );

=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartUserRoleAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartUserRoleAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartUserRoleAction.java	2010-10-04 03:09:23 +0000
@@ -0,0 +1,101 @@
+package org.hisp.dhis.reportexcel.jchart.action;
+
+/*
+ * Copyright (c) 2004-2010, 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 java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.jchart.JChart;
+import org.hisp.dhis.jchart.JChartSevice;
+import org.hisp.dhis.user.UserStore;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Tran Thanh Tri
+ */
+
+public class UpdateJChartUserRoleAction
+    implements Action
+{
+    // -------------------------------------------
+    // Dependency
+    // -------------------------------------------
+
+    private JChartSevice jchartService;
+
+    public void setJchartService( JChartSevice jchartService )
+    {
+        this.jchartService = jchartService;
+    }
+
+    private UserStore userStore;
+
+    public void setUserStore( UserStore userStore )
+    {
+        this.userStore = userStore;
+    }
+
+    // -------------------------------------------
+    // Input
+    // -------------------------------------------
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    private List<Integer> userRoles = new ArrayList<Integer>();
+
+    public void setUserRoles( List<Integer> userRoles )
+    {
+        this.userRoles = userRoles;
+    }
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+
+        JChart jchart = jchartService.getJChart( id );
+
+        jchart.clearAllUserRoles();
+
+        for ( Integer i : userRoles )
+        {
+            jchart.addUserAuthorityGroup( userStore.getUserAuthorityGroup( i ) );
+        }
+        
+        jchartService.updateJChart( jchart );
+
+        return SUCCESS;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartUserRoleFormAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartUserRoleFormAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/jchart/action/UpdateJChartUserRoleFormAction.java	2010-10-04 03:09:23 +0000
@@ -0,0 +1,107 @@
+package org.hisp.dhis.reportexcel.jchart.action;
+
+/*
+ * Copyright (c) 2004-2010, 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 java.util.Collection;
+
+import org.hisp.dhis.jchart.JChart;
+import org.hisp.dhis.jchart.JChartSevice;
+import org.hisp.dhis.user.UserAuthorityGroup;
+import org.hisp.dhis.user.UserStore;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Tran Thanh Tri
+ */
+
+public class UpdateJChartUserRoleFormAction
+    implements Action
+{
+    // -------------------------------------------
+    // Dependency
+    // -------------------------------------------
+
+    private JChartSevice jchartService;
+
+    public void setJchartService( JChartSevice jchartService )
+    {
+        this.jchartService = jchartService;
+    }
+
+    private UserStore userStore;
+
+    public void setUserStore( UserStore userStore )
+    {
+        this.userStore = userStore;
+    }
+
+    // -------------------------------------------
+    // Input
+    // -------------------------------------------
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    // -------------------------------------------
+    // Output
+    // -------------------------------------------
+
+    private Collection<UserAuthorityGroup> userRoles;
+
+    public Collection<UserAuthorityGroup> getUserRoles()
+    {
+        return userRoles;
+    }
+
+    private JChart jchart;
+
+    public JChart getJchart()
+    {
+        return jchart;
+    }
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+
+        userRoles = userStore.getAllUserAuthorityGroups();
+
+        jchart = jchartService.getJChart( id );
+
+        userRoles.removeAll( jchart.getUserRoles() );
+
+        return SUCCESS;
+    }
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties	2010-09-30 09:37:41 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties	2010-10-04 03:09:23 +0000
@@ -284,4 +284,5 @@
 bar							= Bar
 color						= Color
 series						= Series
-select_organisation			= Please select organisation unit
\ No newline at end of file
+select_organisation			= Please select organisation unit
+category					= Category