← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1193: Fixed bug: Dashbord did not redirect properly for Jasper reports.

 

------------------------------------------------------------
revno: 1193
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-12-09 16:39:36 +0100
message:
  Fixed bug: Dashbord did not redirect properly for Jasper reports.
modified:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/ReportContentProvider.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml


--
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-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/ReportContentProvider.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/ReportContentProvider.java	2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/ReportContentProvider.java	2009-12-09 15:39:36 +0000
@@ -27,6 +27,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.report.Report.TYPE_BIRT;
+import static org.hisp.dhis.report.Report.TYPE_DEFAULT;
+import static org.hisp.dhis.report.Report.TYPE_JASPER;
 import static org.hisp.dhis.util.ContextUtils.getBaseUrl;
 
 import java.util.Collections;
@@ -38,9 +41,11 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.ServletActionContext;
 import org.hisp.dhis.dashboard.DashboardContent;
 import org.hisp.dhis.dashboard.DashboardService;
 import org.hisp.dhis.external.configuration.NoConfigurationFoundException;
+import org.hisp.dhis.options.SystemSettingManager;
 import org.hisp.dhis.report.Report;
 import org.hisp.dhis.report.ReportManager;
 import org.hisp.dhis.report.comparator.ReportComparator;
@@ -48,8 +53,6 @@
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 
-import org.apache.struts2.ServletActionContext;
-
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -61,6 +64,7 @@
     
     private static final String SEPARATOR = "/";
     private static final String BASE_QUERY = "frameset?__report=";
+    private static final String JASPER_BASE_URL = "../dhis-web-reporting/renderReport.action?template=";
     
     // -------------------------------------------------------------------------
     // Dependencies
@@ -72,6 +76,13 @@
     {
         this.currentUserService = currentUserService;
     }
+    
+    private SystemSettingManager systemSettingManager;
+
+    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+    {
+        this.systemSettingManager = systemSettingManager;
+    }
 
     private DashboardService dashboardService;
 
@@ -107,30 +118,43 @@
         if ( user != null )
         {
             DashboardContent dashboardContent = dashboardService.getDashboardContent( user );
-                        
-            try
+            
+            String framework = (String) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_REPORT_FRAMEWORK, TYPE_DEFAULT );
+            
+            List<Report> reports = dashboardContent.getReports();
+            
+            if ( framework.equals( TYPE_JASPER ) )
             {
-                ReportConfiguration config = reportManager.getConfiguration();
-                
-                HttpServletRequest request = ServletActionContext.getRequest();
-                
-                String birtURL = getBaseUrl( request ) + config.getDirectory() + SEPARATOR + BASE_QUERY;
-                
-                List<Report> reports = dashboardContent.getReports();
-                
                 for ( Report report : reports )
                 {
-                    report.setUrl( birtURL + report.getDesign() );
-                }
-                
-                Collections.sort( reports, new ReportComparator() );
-                
-                content.put( key, reports );
-            }
-            catch ( NoConfigurationFoundException ex )
-            {
-                log.error( "Report configuration not set" );
-            }
+                    report.setUrl( JASPER_BASE_URL + report.getDesign() );
+                }
+            }
+            else if ( framework.equals( TYPE_BIRT ) )
+            {            
+                try
+                {
+                    ReportConfiguration config = reportManager.getConfiguration();
+                    
+                    HttpServletRequest request = ServletActionContext.getRequest();
+                    
+                    String birtURL = getBaseUrl( request ) + config.getDirectory() + SEPARATOR + BASE_QUERY;
+                    
+                    for ( Report report : reports )
+                    {
+                        report.setUrl( birtURL + report.getDesign() );
+                    }
+                    
+                }
+                catch ( NoConfigurationFoundException ex )
+                {
+                    log.error( "Report configuration not set" );
+                }
+            }
+
+            Collections.sort( reports, new ReportComparator() );
+            
+            content.put( key, reports );
         }
         
         return content;

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml	2009-11-23 17:06:09 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml	2009-12-09 15:39:36 +0000
@@ -9,6 +9,7 @@
   <bean id="reportContentProvider" 
     class="org.hisp.dhis.dashboard.provider.ReportContentProvider">
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService"/>
+	<property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager"/>
     <property name="dashboardService" ref="org.hisp.dhis.dashboard.DashboardService"/>
     <property name="reportManager" ref="org.hisp.dhis.report.ReportManager"/>
     <property name="key" value="reports"/>
@@ -83,15 +84,9 @@
           <ref local="mapViewContentProvider"/>
         </entry>
         <entry>
-          <key><value>olap_url</value></key>
-          <ref local="olapUrlContentProvider"/>
-        </entry>
-        <!-- 
-        <entry>
           <key><value>rss_health</value></key>
           <ref local="rssHealthContentProvider"/>
         </entry>
-        -->
       </map>
     </property>
   </bean>