← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18365: Moved some sql view related methods from ResourceTableService to SqlViewService

 

------------------------------------------------------------
revno: 18365
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-02-20 15:46:12 +0100
message:
  Moved some sql view related methods from ResourceTableService  to SqlViewService
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java
  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/resourcetable/DefaultResourceTableService.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.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/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MaintenanceController.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.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/resourcetable/ResourceTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableService.java	2015-02-20 14:46:12 +0000
@@ -94,14 +94,4 @@
      * option combinations.
      */
     void generateDataElementCategoryOptionComboTable();
-    
-    /**
-     * Create all sql views in the database.
-     */
-    void createAllSqlViews();
-    
-    /**
-     * Drop all sql views in the database.
-     */
-    void dropAllSqlViews();
 }

=== 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	2015-02-18 12:16:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java	2015-02-20 14:46:12 +0000
@@ -86,7 +86,9 @@
 
     String createViewTable( SqlView sqlView );
 
-    void createAllViews();
+    void createAllSqlViews();
+    
+    void dropAllSqlViews();
     
     void dropViewTable( String viewName );
     

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java	2015-01-19 10:46:09 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/DefaultResourceTableService.java	2015-02-20 14:46:12 +0000
@@ -28,6 +28,21 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.dataapproval.DataApprovalLevelService.APPROVAL_LEVEL_UNAPPROVED;
+import static org.hisp.dhis.resourcetable.ResourceTableStore.TABLE_NAME_CATEGORY_OPTION_COMBO_NAME;
+import static org.hisp.dhis.resourcetable.ResourceTableStore.TABLE_NAME_DATA_ELEMENT_STRUCTURE;
+import static org.hisp.dhis.resourcetable.ResourceTableStore.TABLE_NAME_DATE_PERIOD_STRUCTURE;
+import static org.hisp.dhis.resourcetable.ResourceTableStore.TABLE_NAME_ORGANISATION_UNIT_STRUCTURE;
+import static org.hisp.dhis.resourcetable.ResourceTableStore.TABLE_NAME_PERIOD_STRUCTURE;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.calendar.Calendar;
@@ -55,21 +70,8 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.resourcetable.statement.CreateCategoryOptionGroupSetTableStatement;
-import org.hisp.dhis.sqlview.SqlView;
-import org.hisp.dhis.sqlview.SqlViewService;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.hisp.dhis.dataapproval.DataApprovalLevelService.APPROVAL_LEVEL_UNAPPROVED;
-import static org.hisp.dhis.resourcetable.ResourceTableStore.*;
-
 /**
  * @author Lars Helge Overland
  */
@@ -131,13 +133,6 @@
         this.periodService = periodService;
     }
 
-    private SqlViewService sqlViewService;
-
-    public void setSqlViewService( SqlViewService sqlViewService )
-    {
-        this.sqlViewService = sqlViewService;
-    }
-
     // -------------------------------------------------------------------------
     // OrganisationUnitStructure
     // -------------------------------------------------------------------------
@@ -512,34 +507,4 @@
 
         log.info( "Data element category option combo table generated" );
     }
-
-    // -------------------------------------------------------------------------
-    // SQL views
-    // -------------------------------------------------------------------------
-
-    @Override
-    public void createAllSqlViews()
-    {
-        List<SqlView> sqlViews = new ArrayList<>( sqlViewService.getAllSqlViewsNoAcl() );
-        Collections.sort( sqlViews, IdentifiableObjectNameComparator.INSTANCE );
-
-        for ( SqlView sqlView : sqlViews )
-        {
-            sqlViewService.createViewTable( sqlView );
-        }
-    }
-
-
-    @Override
-    public void dropAllSqlViews()
-    {
-        List<SqlView> views = new ArrayList<>( sqlViewService.getAllSqlViewsNoAcl() );
-        Collections.sort( views, IdentifiableObjectNameComparator.INSTANCE );
-        Collections.reverse( views );
-
-        for ( SqlView view : views )
-        {
-            sqlViewService.dropViewTable( view.getViewName() );
-        }
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/scheduling/ResourceTableTask.java	2015-02-20 14:46:12 +0000
@@ -36,6 +36,7 @@
 import org.hisp.dhis.resourcetable.ResourceTableService;
 import org.hisp.dhis.scheduling.TaskId;
 import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.sqlview.SqlViewService;
 import org.hisp.dhis.system.notification.NotificationLevel;
 import org.hisp.dhis.system.notification.Notifier;
 import org.hisp.dhis.system.util.Clock;
@@ -52,6 +53,9 @@
     private ResourceTableService resourceTableService;
     
     @Autowired
+    private SqlViewService sqlViewService;
+    
+    @Autowired
     private Notifier notifier;
 
     @Autowired
@@ -107,7 +111,7 @@
 
     private void generateAll()
     {
-        resourceTableService.dropAllSqlViews();
+        sqlViewService.dropAllSqlViews();
         resourceTableService.generateOrganisationUnitStructures();   
         resourceTableService.generateCategoryOptionComboNames();
         resourceTableService.generateCategoryOptionGroupSetTable();
@@ -119,6 +123,6 @@
         resourceTableService.generatePeriodTable();
         resourceTableService.generateDatePeriodTable();
         resourceTableService.generateDataElementCategoryOptionComboTable();
-        resourceTableService.createAllSqlViews();
+        sqlViewService.createAllSqlViews();
     }
 }

=== 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	2015-02-19 09:18:17 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java	2015-02-20 14:46:12 +0000
@@ -28,8 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
@@ -39,6 +42,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.IllegalQueryException;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.system.grid.ListGrid;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -157,9 +161,10 @@
     }
     
     @Override
-    public void createAllViews()
+    public void createAllSqlViews()
     {
-        Collection<SqlView> views = getAllSqlViews();
+        List<SqlView> views = new ArrayList<>( getAllSqlViewsNoAcl() );
+        Collections.sort( views, IdentifiableObjectNameComparator.INSTANCE );
         
         for ( SqlView view : views )
         {
@@ -170,6 +175,23 @@
         }
     }
 
+
+    @Override
+    public void dropAllSqlViews()
+    {
+        List<SqlView> views = new ArrayList<>( getAllSqlViewsNoAcl() );
+        Collections.sort( views, IdentifiableObjectNameComparator.INSTANCE );
+        Collections.reverse( views );
+
+        for ( SqlView view : views )
+        {
+            if ( !view.isQuery() )
+            {
+                dropViewTable( view.getViewName() );
+            }
+        }
+    }
+    
     @Override
     public Grid getSqlViewGrid( SqlView sqlView, Map<String, String> criteria, Map<String, String> variables )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2015-02-17 13:27:11 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml	2015-02-20 14:46:12 +0000
@@ -17,7 +17,6 @@
     <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
     <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
-    <property name="sqlViewService" ref="org.hisp.dhis.sqlview.SqlViewService" />
   </bean>
   
   <!-- Data integrity -->

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java	2015-01-23 17:23:01 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java	2015-02-20 14:46:12 +0000
@@ -169,7 +169,7 @@
     @Override
     public void generateResourceTables()
     {
-        resourceTableService.dropAllSqlViews();
+        sqlViewService.dropAllSqlViews();
         resourceTableService.generateOrganisationUnitStructures();        
         resourceTableService.generateCategoryOptionComboNames();
         resourceTableService.generateCategoryOptionGroupSetTable();
@@ -181,7 +181,7 @@
         resourceTableService.generatePeriodTable();
         resourceTableService.generateDatePeriodTable();
         resourceTableService.generateDataElementCategoryOptionComboTable();
-        resourceTableService.createAllSqlViews();
+        sqlViewService.createAllSqlViews();
     }
     
     // -------------------------------------------------------------------------
@@ -285,14 +285,14 @@
     
     private void swapTables( List<AnalyticsTable> tables )
     {
-        resourceTableService.dropAllSqlViews();
+        sqlViewService.dropAllSqlViews();
         
         for ( AnalyticsTable table : tables )
         {
             tableManager.swapTable( table );
         }
         
-        resourceTableService.createAllSqlViews();
+        sqlViewService.createAllSqlViews();
     }
     
     /**

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MaintenanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MaintenanceController.java	2015-02-17 06:00:52 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MaintenanceController.java	2015-02-20 14:46:12 +0000
@@ -113,7 +113,7 @@
     @PreAuthorize( "hasRole('ALL') or hasRole('F_PERFORM_MAINTENANCE')" )
     public void createSqlViews()
     {
-        sqlViewService.createAllViews();
+        sqlViewService.createAllSqlViews();
     }
     
     @RequestMapping( value = "/categoryOptionComboUpdate", method = { RequestMethod.PUT, RequestMethod.POST } )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java	2015-02-13 15:23:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java	2015-02-20 14:46:12 +0000
@@ -207,7 +207,7 @@
         
         if ( clearAnalytics )
         {
-            resourceTableService.dropAllSqlViews();
+            sqlViewService.dropAllSqlViews();
             analyticsTableService.dropTables();
             completenessTableService.dropTables();
             completenessTargetTableService.dropTables();
@@ -273,7 +273,7 @@
         
         if ( createSqlViews )
         {
-            sqlViewService.createAllViews();
+            sqlViewService.createAllSqlViews();
             
             log.info( "'" + username + "': Created SQL views" );
         }