=== 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 2010-08-24 07:43:37 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewExpandStore.java 2010-09-16 10:04:16 +0000 @@ -22,7 +22,7 @@ boolean createView( SqlView sqlViewInstance ); - void dropView( Object object ); + void dropViewTable( String sqlViewName ); void setUpDataSqlViewTable( SqlViewTable sqlViewTable, String viewTableName ); === 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 2010-08-24 07:43:37 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViewService.java 2010-09-16 10:04:16 +0000 @@ -67,14 +67,17 @@ boolean isViewTableExists( String viewTableName ); + boolean createAllViewTables(); + boolean createViewTable( SqlView sqlViewInstance ); - void dropViewTable( Object object ); + void dropViewTable( String viewName ); + + void dropAllSqlViewTables(); SqlViewTable getDataSqlViewTable( String viewTableName ); String testSqlGrammar( String sql ); String setUpJoinQuery( Collection tableList ); - } === 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 2010-08-24 07:43:37 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/DefaultSqlViewService.java 2010-09-16 10:04:16 +0000 @@ -103,16 +103,16 @@ return query.replaceAll( ";\\s+", ";" ).replaceAll( ";+", ";" ).replaceAll( "\\s+", " " ).trim(); } + // ------------------------------------------------------------------------- + // SqlView expanded + // ------------------------------------------------------------------------- + @Override public String setUpViewTableName( String input ) { return sqlViewExpandStore.setUpViewTableName( input ); } - // ------------------------------------------------------------------------- - // SqlView expanded - // ------------------------------------------------------------------------- - @Override public Collection getAllSqlViewNames() { @@ -126,6 +126,24 @@ } @Override + public boolean createAllViewTables() + { + boolean success = true; + + for ( SqlView sqlView : getAllSqlViews() ) + { + setUpViewTableName( sqlView.getName() ); + + if ( !createViewTable( sqlView ) ) + { + success = false; + } + } + + return success; + } + + @Override public boolean createViewTable( SqlView sqlViewInstance ) { return sqlViewExpandStore.createView( sqlViewInstance ); @@ -160,9 +178,17 @@ } @Override - public void dropViewTable( Object object ) + public void dropViewTable( String sqlViewTableName ) { - sqlViewExpandStore.dropView( object ); + sqlViewExpandStore.dropViewTable( sqlViewTableName ); } + @Override + public void dropAllSqlViewTables() + { + for ( String viewName : getAllSqlViewNames() ) + { + dropViewTable( viewName ); + } + } } \ 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 2010-08-25 06:53:37 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/sqlview/jdbc/JdbcSqlViewExpandStore.java 2010-09-16 10:04:16 +0000 @@ -27,8 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.system.util.ReflectionUtils.isCollection; - import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; @@ -192,22 +190,6 @@ return true; } - @SuppressWarnings( "unchecked" ) - public void dropView( Object object ) - { - if ( isCollection( object ) ) - { - for ( String viewName : (Collection) object ) - { - dropViewTable( viewName ); - } - } - else if ( object != null ) - { - dropViewTable( (String) object ); - } - } - @Override public void setUpDataSqlViewTable( SqlViewTable sqlViewTable, String viewTableName ) { @@ -263,6 +245,25 @@ } @Override + public void dropViewTable( String viewName ) + { + final StatementHolder holder = statementManager.getHolder(); + + try + { + holder.getStatement().executeUpdate( PREFIX_DROPVIEW_QUERY + viewName ); + } + catch ( SQLException ex ) + { + throw new RuntimeException( "Failed to drop view: " + viewName, ex ); + } + finally + { + holder.close(); + } + } + + @Override public String setUpJoinQuery( Collection tableList ) { String joinQuery = ""; @@ -1092,23 +1093,4 @@ return input; } - - private void dropViewTable( String viewName ) - { - final StatementHolder holder = statementManager.getHolder(); - - try - { - holder.getStatement().executeUpdate( PREFIX_DROPVIEW_QUERY + viewName ); - } - catch ( SQLException ex ) - { - throw new RuntimeException( "Failed to drop view: " + viewName, ex ); - } - finally - { - holder.close(); - } - } - } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java 2010-09-16 08:49:51 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java 2010-09-16 10:04:16 +0000 @@ -27,7 +27,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.hisp.dhis.resourcetable.ResourceTableService; +import org.hisp.dhis.sqlview.SqlViewService; import com.opensymphony.xwork2.ActionSupport; @@ -38,10 +41,19 @@ public class GenerateResourceTableAction extends ActionSupport { + private static final Log log = LogFactory.getLog( GenerateResourceTableAction.class ); + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- - + + private SqlViewService sqlViewService; + + public void setSqlViewService( SqlViewService sqlViewService ) + { + this.sqlViewService = sqlViewService; + } + private ResourceTableService resourceTableService; public void setResourceTableService( ResourceTableService resourceTableService ) @@ -102,6 +114,10 @@ public String execute() throws Exception { + sqlViewService.dropAllSqlViewTables(); + + log.info( "Dropped all sql views" ); + if ( organisationUnit ) { resourceTableService.generateOrganisationUnitStructures(); @@ -132,6 +148,12 @@ resourceTableService.generateCategoryOptionComboNames(); } + log.info( "Generated resource tables" ); + + sqlViewService.createAllViewTables(); + + log.info( "Created all views" ); + return SUCCESS; } } === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/DropAllSqlViewTablesAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/DropAllSqlViewTablesAction.java 2010-08-24 07:43:37 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/DropAllSqlViewTablesAction.java 1970-01-01 00:00:00 +0000 @@ -1,156 +0,0 @@ -package org.hisp.dhis.dataadmin.action.sqlview; - -/* - * 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 org.hisp.dhis.sqlview.SqlViewService; - -import com.opensymphony.xwork2.ActionSupport; - -/** - * @author Dang Duy Hieu - * @version $Id DropAllSqlViewTablesAction.java July 07, 2010$ - */ -public class DropAllSqlViewTablesAction - extends ActionSupport -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private SqlViewService sqlViewService; - - public void setSqlViewService( SqlViewService sqlViewService ) - { - this.sqlViewService = sqlViewService; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private boolean organisationUnit; - - public void setOrganisationUnit( boolean organisationUnit ) - { - this.organisationUnit = organisationUnit; - } - - private boolean groupSet; - - public void setGroupSet( boolean groupSet ) - { - this.groupSet = groupSet; - } - - private boolean dataElementGroupSetStructure; - - public void setDataElementGroupSetStructure( boolean dataElementGroupSetStructure ) - { - this.dataElementGroupSetStructure = dataElementGroupSetStructure; - } - - private boolean indicatorGroupSetStructure; - - public void setIndicatorGroupSetStructure( boolean indicatorGroupSetStructure ) - { - this.indicatorGroupSetStructure = indicatorGroupSetStructure; - } - - private boolean organisationUnitGroupSetStructure; - - public void setOrganisationUnitGroupSetStructure( boolean organisationUnitGroupSetStructure ) - { - this.organisationUnitGroupSetStructure = organisationUnitGroupSetStructure; - } - - private boolean categoryStructure; - - public void setCategoryStructure( boolean categoryStructure ) - { - this.categoryStructure = categoryStructure; - } - - private boolean categoryOptionComboName; - - public void setCategoryOptionComboName( boolean categoryOptionComboName ) - { - this.categoryOptionComboName = categoryOptionComboName; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - public boolean isOrganisationUnit() - { - return organisationUnit; - } - - public boolean isGroupSet() - { - return groupSet; - } - - public boolean isDataElementGroupSetStructure() - { - return dataElementGroupSetStructure; - } - - public boolean isIndicatorGroupSetStructure() - { - return indicatorGroupSetStructure; - } - - public boolean isOrganisationUnitGroupSetStructure() - { - return organisationUnitGroupSetStructure; - } - - public boolean isCategoryStructure() - { - return categoryStructure; - } - - public boolean isCategoryOptionComboName() - { - return categoryOptionComboName; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - sqlViewService.dropViewTable( sqlViewService.getAllSqlViewNames() ); - - return SUCCESS; - } - -} === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/RegenerateAllSqlViewTablesAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/RegenerateAllSqlViewTablesAction.java 2010-08-24 07:43:37 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/sqlview/RegenerateAllSqlViewTablesAction.java 1970-01-01 00:00:00 +0000 @@ -1,108 +0,0 @@ -package org.hisp.dhis.dataadmin.action.sqlview; - -/* - * 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 org.hisp.dhis.i18n.I18n; -import org.hisp.dhis.sqlview.SqlView; -import org.hisp.dhis.sqlview.SqlViewService; - -import com.opensymphony.xwork2.ActionSupport; - -/** - * Drops all sql-view tables first do regenerate the selected resource tables - * and all of sql-view tables - * - * @author Dang Duy Hieu - * @version $Id RegenerateAllSqlViewTablesAction.java July 06, 2010$ - */ -public class RegenerateAllSqlViewTablesAction - extends ActionSupport -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private SqlViewService sqlViewService; - - public void setSqlViewService( SqlViewService sqlViewService ) - { - this.sqlViewService = sqlViewService; - } - - private I18n i18n; - - public void setI18n( I18n i18n ) - { - this.i18n = i18n; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private String message; - - public String getMessage() - { - return message; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - { - message = ""; - - for ( SqlView sqlView : sqlViewService.getAllSqlViews() ) - { - String viewName = sqlViewService.setUpViewTableName( sqlView.getName() ); - - if ( !sqlViewService.createViewTable( sqlView ) ) - { - message = i18n.getString( "failed_to_create_view_table_for" ) + ": " + sqlView.getName(); - - return ERROR; - } - - message += "
[ " + viewName + " ]"; - } - - if ( message.equals( "" ) ) - { - message = i18n.getString( "there_is_no_view_created" ); - } - else - { - message = i18n.getString( "view_tables_created" ) + ": " + message; - } - - return SUCCESS; - } -} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2010-09-15 13:42:47 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2010-09-16 10:04:16 +0000 @@ -60,8 +60,7 @@ - @@ -73,12 +72,11 @@ - - + + @@ -91,8 +89,7 @@ - - - - - - - - - /dhis-web-maintenance-dataadmin/resourceTableForm.vm /dhis-web-maintenance-dataadmin/menu.vm - javascript/sqlView.js + javascript/resourceTable.js + + + + /dhis-web-maintenance-dataadmin/responseSuccess.vm @@ -451,23 +456,6 @@ F_SQLVIEW_MANAGEMENT - - generateResourceTables - F_SQLVIEW_REGENERATE - - - - regenerateAllSqlViewTables.action - - - - displayResourceTableForm - displayResourceTableForm - - /dhis-web-maintenance-dataadmin/jsonResourceProperties.vm === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/resourceTable.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/resourceTable.js 2010-09-16 09:02:40 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/resourceTable.js 2010-09-16 10:04:16 +0000 @@ -1,4 +1,6 @@ +var selected = false; + function generateResourceTable() { var organisationUnit = document.getElementById( "organisationUnit" ).checked; @@ -37,3 +39,15 @@ { setMessage( i18n_resource_tables_generated ); } + +function toggleAll() +{ + selected = !selected; + + document.getElementById( "organisationUnit" ).checked = selected; + document.getElementById( "dataElementGroupSetStructure" ).checked = selected; + document.getElementById( "indicatorGroupSetStructure" ).checked = selected; + document.getElementById( "organisationUnitGroupSetStructure" ).checked = selected; + document.getElementById( "categoryStructure" ).checked = selected; + document.getElementById( "categoryOptionComboName" ).checked = selected; +} === 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 2010-09-16 09:02:40 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/sqlView.js 2010-09-16 10:04:16 +0000 @@ -76,67 +76,6 @@ ); } -function selectOrUnselectALL() -{ - var listRadio = document.getElementsByName('resourceTableCheckBox'); - - for (var i = 0 ; i < listRadio.length ; i++) { - - listRadio.item(i).checked = checkingStatus; - } - - // If true, its means the items unselected yet - if ( checkingStatus ) - { - $("#selectAllButton").val( i18n_unselect_all ); - } - else - { - $("#selectAllButton").val( i18n_select_all ); - } - checkingStatus = !checkingStatus; -} - -// ----------------------------------------------------------------------- -// Re-generating for the resource tables and the view ones -// ----------------------------------------------------------------------- - -function validateRegenerateResourceView() -{ - var params = ""; - var organisationUnit = byId( "organisationUnit" ).checked; - var dataElementGroupSetStructure = byId( "dataElementGroupSetStructure" ).checked; - var indicatorGroupSetStructure = byId( "indicatorGroupSetStructure" ).checked; - var organisationUnitGroupSetStructure = byId( "organisationUnitGroupSetStructure" ).checked; - var categoryStructure = byId( "categoryStructure" ).checked; - var categoryOptionComboName = byId( "categoryOptionComboName" ).checked; - - if ( organisationUnit || dataElementGroupSetStructure || indicatorGroupSetStructure || - organisationUnitGroupSetStructure || categoryStructure || categoryOptionComboName ) - { - setWaitMessage( i18n_regenerating_resource_tables_and_views ); - - var submitForm = byId("regenerateResourceViewForm") - - params += (organisationUnit == true ? "organisationUnit=true&" : ""); - params += (dataElementGroupSetStructure == true ? "dataElementGroupSetStructure=true&" : ""); - params += (indicatorGroupSetStructure == true ? "indicatorGroupSetStructure=true&" : ""); - params += (organisationUnitGroupSetStructure == true ? "organisationUnitGroupSetStructure=true&" : ""); - params += (categoryStructure == true ? "categoryStructure=true&" : ""); - params += (categoryOptionComboName == true ? "categoryOptionComboName=true&" : ""); - - submitForm.action +="?"+params; - submitForm.submit(); - } - else - { - setMessage( i18n_select_options ); - - return false; - } - -} - // ----------------------------------------------------------------------- // View data from the specified view table // ----------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/resourceTableForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/resourceTableForm.vm 2010-09-16 08:49:51 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/resourceTableForm.vm 2010-09-16 10:04:16 +0000 @@ -1,13 +1,3 @@ -

$i18n.getString( "resource_table" ) #openHelp( "resourceTables" )

@@ -46,8 +36,8 @@ @@ -57,16 +47,7 @@ - -
- - + +