← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9643: Cleanup of sql view functionality

 

------------------------------------------------------------
revno: 9643
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-01-28 18:38:11 +0200
message:
  Cleanup of sql view functionality
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.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/sqlview/SqlViewService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java	2012-07-21 13:43:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java	2013-01-28 16:38:11 +0000
@@ -81,8 +81,6 @@
 
     void dropAllSqlViewTables();
 
-    Grid getDataSqlViewGrid( String viewTableName );
-    
     Grid getDataSqlViewGrid( SqlView sqlView );
     
     String testSqlGrammar( String sql );

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java	2013-01-14 21:35:56 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java	2013-01-28 16:38:11 +0000
@@ -169,22 +169,16 @@
     }
 
     @Override
-    public Grid getDataSqlViewGrid( String viewTableName )
+    public Grid getDataSqlViewGrid( SqlView sqlView )
     {
         Grid sqlViewGrid = new ListGrid();
 
-        sqlViewExpandStore.setUpDataSqlViewTable( sqlViewGrid, viewTableName );
+        sqlViewExpandStore.setUpDataSqlViewTable( sqlViewGrid, sqlView.getViewName() );
 
         return sqlViewGrid;
     }
 
     @Override
-    public Grid getDataSqlViewGrid( SqlView sqlView )
-    {
-        return getDataSqlViewGrid( sqlView.getViewName() );
-    }
-
-    @Override
     public String testSqlGrammar( String sql )
     {
         return sqlViewExpandStore.testSqlGrammar( sql );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java	2012-04-09 03:25:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/ExportSqlViewResultAction.java	2013-01-28 16:38:11 +0000
@@ -28,6 +28,7 @@
  */
 
 import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.sqlview.SqlView;
 import org.hisp.dhis.sqlview.SqlViewService;
 
 import com.opensymphony.xwork2.Action;
@@ -58,27 +59,17 @@
     // Input
     // -------------------------------------------------------------------------
 
-    private String viewTableName;
-
-    public void setViewTableName( String viewTableName )
-    {
-        this.viewTableName = viewTableName;
-    }
-
-    public void setType( String type )
-    {
-        this.type = type;
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
     }
 
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
 
-    public String getViewTableName()
-    {
-        return viewTableName;
-    }
-
     private Grid grid;
 
     public Grid getGrid()
@@ -86,6 +77,13 @@
         return grid;
     }
 
+    private SqlView sqlView;
+    
+    public SqlView getSqlView()
+    {
+        return sqlView;
+    }
+
     private String type;
 
     public String getType()
@@ -93,13 +91,20 @@
         return type;
     }
 
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
     public String execute()
     {
-        grid = sqlViewService.getDataSqlViewGrid( viewTableName );
+        sqlView = sqlViewService.getSqlView( id );
+        
+        grid = sqlViewService.getDataSqlViewGrid( sqlView );
 
         return type != null ? type : DEFAULT_TYPE;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js	2012-04-27 16:45:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js	2013-01-28 16:38:11 +0000
@@ -83,7 +83,7 @@
 		{
 			if ( json.response == "success" )
 			{
-				window.location.href = "exportSqlView.action?viewTableName=" + json.message;
+				window.location.href = "exportSqlView.action?id=" + viewId;
 			}
 			else if ( json.response == "error" )
 			{
@@ -93,9 +93,9 @@
 	);
 }
 
-function exportSqlView( type )
+function exportSqlView( id, type )
 {
-	var url = "exportSqlView.action?type=" + type + "&viewTableName=" + $( "#viewTableName" ).val();
+	var url = "exportSqlView.action?id=" + id + "&type=" + type;
 
     window.location.href = url;
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm	2012-04-27 16:45:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/showDataSqlViewForm.vm	2013-01-28 16:38:11 +0000
@@ -7,14 +7,14 @@
 }
 </style>
 
-<h3>$i18n.getString( "view_data_for" ) "${viewTableName}"</h3>
+<h3>$i18n.getString( "view_data_for" ) &quot;${sqlView.name}&quot;</h3>
 
 <input type="hidden" id="viewTableName" value="${viewTableName}"/>
 
 <div>
-<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportSqlView( 'xls' )" style="width:140px"/>
-<input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="exportSqlView( 'csv' )" style="width:140px"/>
-<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportSqlView( 'pdf' )" style="width:140px"/>
+<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportSqlView( '${sqlView.id}', 'xls' )" style="width:140px"/>
+<input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="exportSqlView( '${sqlView.id}', 'csv' )" style="width:140px"/>
+<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportSqlView( '${sqlView.id}', 'pdf' )" style="width:140px"/>
 <input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='showSqlViewListForm.action'" style="width:140px"/>
 </div>
 <br/>