=== 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 2013-01-23 11:54:42 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java 2013-02-05 11:36:19 +0000 @@ -27,14 +27,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import com.opensymphony.xwork2.Action; 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 org.hisp.dhis.user.CurrentUserService; -import com.opensymphony.xwork2.Action; - /** * @author Lars Helge Overland * @version $Id$ @@ -43,7 +42,7 @@ implements Action { private static final Log log = LogFactory.getLog( GenerateResourceTableAction.class ); - + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -61,11 +60,11 @@ { this.resourceTableService = resourceTableService; } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + private boolean organisationUnit; public void setOrganisationUnit( boolean organisationUnit ) @@ -79,7 +78,7 @@ { this.dataElementGroupSetStructure = dataElementGroupSetStructure; } - + private boolean indicatorGroupSetStructure; public void setIndicatorGroupSetStructure( boolean indicatorGroupSetStructure ) @@ -93,7 +92,7 @@ { this.organisationUnitGroupSetStructure = organisationUnitGroupSetStructure; } - + private boolean categoryStructure; public void setCategoryStructure( boolean categoryStructure ) @@ -101,20 +100,20 @@ this.categoryStructure = categoryStructure; } - private boolean categoryOptionComboName; + private boolean categoryOptionComboName; public void setCategoryOptionComboName( boolean categoryOptionComboName ) { this.categoryOptionComboName = categoryOptionComboName; } - + private boolean dataElementStructure; public void setDataElementStructure( boolean dataElementStructure ) { this.dataElementStructure = dataElementStructure; } - + private boolean periodStructure; public void setPeriodStructure( boolean periodStructure ) @@ -129,63 +128,72 @@ this.currentUserService = currentUserService; } + private String message; + + public String getMessage() + { + return message; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- - public String execute() + public String execute() throws Exception { sqlViewService.dropAllSqlViewTables(); - + log.info( "'" + currentUserService.getCurrentUsername() + "': Dropped all sql views" ); - + if ( organisationUnit ) { resourceTableService.generateOrganisationUnitStructures(); } - + if ( dataElementGroupSetStructure ) { resourceTableService.generateDataElementGroupSetTable(); } - + if ( indicatorGroupSetStructure ) { resourceTableService.generateIndicatorGroupSetTable(); } - + if ( organisationUnitGroupSetStructure ) { resourceTableService.generateOrganisationUnitGroupSetTable(); } - + if ( categoryStructure ) { resourceTableService.generateCategoryTable(); } - + if ( categoryOptionComboName ) { resourceTableService.generateCategoryOptionComboNames(); } - + if ( dataElementStructure ) { resourceTableService.generateDataElementTable(); } - + if ( periodStructure ) { resourceTableService.generatePeriodTable(); } - + log.info( "'" + currentUserService.getCurrentUsername() + "': Generated resource tables" ); - + sqlViewService.createAllViewTables(); - + log.info( "'" + currentUserService.getCurrentUsername() + "': Created all views" ); - + + message = "Generated resource tables"; + return SUCCESS; } }