← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10564: Sql view, using dhis sql views instead of database views as basis when dropping all views

 

------------------------------------------------------------
revno: 10564
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-04-15 19:17:31 +0200
message:
  Sql view, using dhis sql views instead of database views as basis when dropping all views
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewExpandStore.java
  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/jdbc/JdbcSqlViewExpandStore.java


--
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/SqlViewExpandStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewExpandStore.java	2013-03-29 11:56:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewExpandStore.java	2013-04-15 17:17:31 +0000
@@ -1,6 +1,5 @@
 package org.hisp.dhis.sqlview;
 
-import java.util.List;
 import java.util.Map;
 
 import org.hisp.dhis.common.Grid;
@@ -13,12 +12,6 @@
 {
     String ID = SqlViewExpandStore.class.getName();
 
-    // -------------------------------------------------------------------------
-    // SqlView expanded
-    // -------------------------------------------------------------------------
-
-    List<String> getAllSqlViewNames();
-
     boolean isViewTableExists( String viewTableName );
 
     String createView( SqlView sqlViewInstance );

=== 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-03-29 11:56:00 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java	2013-04-15 17:17:31 +0000
@@ -196,14 +196,14 @@
     @Override
     public void dropAllSqlViewTables()
     {
-        List<String> sqlViewNames = sqlViewExpandStore.getAllSqlViewNames();
-        
-        Collections.sort( sqlViewNames );
-        Collections.reverse( sqlViewNames );
-        
-        for ( String viewName : sqlViewNames )
+        List<SqlView> views = sqlViewStore.getAllOrderedName();
+        
+        Collections.sort( views, IdentifiableObjectNameComparator.INSTANCE );
+        Collections.reverse( views );
+        
+        for ( SqlView view : views )
         {
-            dropViewTable( viewName );
+            dropViewTable( view.getViewName() );
         }
     }
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java	2013-03-29 11:56:00 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java	2013-04-15 17:17:31 +0000
@@ -32,8 +32,6 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
@@ -75,31 +73,6 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public List<String> getAllSqlViewNames()
-    {
-        List<String> viewNames = new ArrayList<String>();
-
-        try
-        {
-            DatabaseMetaData mtdt = jdbcTemplate.getDataSource().getConnection().getMetaData();
-
-            ResultSet rs = mtdt.getTables( null, null, SqlView.PREFIX_VIEWNAME + "%", types );
-
-            while ( rs.next() )
-            {
-                viewNames.add( rs.getString( "TABLE_NAME" ) );
-            }
-        }
-        catch ( SQLException e )
-        {
-            e.printStackTrace();
-        }
-
-        return viewNames;
-
-    }
-
-    @Override
     public boolean isViewTableExists( String viewTableName )
     {
         try