=== modified file 'local/vn/dhis-service-spreadsheet-reporting/pom.xml' --- local/vn/dhis-service-spreadsheet-reporting/pom.xml 2012-08-06 17:09:13 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/pom.xml 2012-11-26 09:12:15 +0000 @@ -6,7 +6,7 @@ org.hisp.dhis dhis-services - 2.10-SNAPSHOT + 2.11-SNAPSHOT dhis-service-spreadsheet-reporting === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReport.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReport.java 2012-11-16 11:04:48 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReport.java 2012-11-26 09:12:15 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.reportsheet; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportService.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportService.java 2012-05-12 15:59:33 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportService.java 2012-11-26 09:12:15 +0000 @@ -1,5 +1,7 @@ +package org.hisp.dhis.reportsheet; + /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,7 +26,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.hisp.dhis.reportsheet; import java.util.Collection; import java.util.Map; @@ -58,6 +59,8 @@ public ExportReport getExportReport( String name ); + public ExportReport getExportReportByDataSet( DataSet dataSet ); + public Collection getExportReportsByOrganisationUnit( OrganisationUnit organisationUnit ); public Collection getAllExportReport(); @@ -125,12 +128,12 @@ public PeriodColumn getPeriodColumn( Integer id ); public void updatePeriodColumn( PeriodColumn periodColumn ); - + public String validateEmportItems( ExportReport exportReport, I18n i18n ); - + // ------------------------------------------------------------------------- // Others // ------------------------------------------------------------------------- - + public Map getPeriodTypeIdentifierMap( Collection reports ); } === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportStore.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportStore.java 2011-08-04 08:39:55 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportStore.java 2012-11-26 09:12:15 +0000 @@ -1,5 +1,7 @@ +package org.hisp.dhis.reportsheet; + /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,7 +26,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.hisp.dhis.reportsheet; import java.util.Collection; @@ -55,6 +56,8 @@ public ExportReport getExportReport( String name ); + public ExportReport getExportReportByDataSet( DataSet dataSet ); + public Collection getExportReportsByOrganisationUnit( OrganisationUnit organisationUnit ); public Collection getAllExportReport(); === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/hibernate/HibernateExportReportStore.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/hibernate/HibernateExportReportStore.java 2012-04-16 03:00:30 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/hibernate/HibernateExportReportStore.java 2012-11-26 09:12:15 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.reportsheet.hibernate; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -428,4 +428,17 @@ query.executeUpdate(); } + + public ExportReport getExportReportByDataSet( DataSet dataSet ) + { + Session session = sessionFactory.getCurrentSession(); + + Criteria criteria = session.createCriteria( ExportReport.class ); + + criteria.createAlias( "dataSets", "d" ); + + criteria.add( Restrictions.eq( "d.id", dataSet.getId() ) ); + + return (ExportReport) criteria.uniqueResult(); + } } === modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/impl/DefaultExportReportService.java' --- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/impl/DefaultExportReportService.java 2012-07-02 09:36:27 +0000 +++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/impl/DefaultExportReportService.java 2012-11-26 09:12:15 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.reportsheet.impl; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -540,4 +540,9 @@ return idMap; } + + public ExportReport getExportReportByDataSet( DataSet dataSet ) + { + return i18n( i18nService, exportReportStore.getExportReportByDataSet( dataSet ) ); + } } === modified file 'local/vn/dhis-service-vn/pom.xml' --- local/vn/dhis-service-vn/pom.xml 2012-08-06 17:09:13 +0000 +++ local/vn/dhis-service-vn/pom.xml 2012-11-26 09:12:15 +0000 @@ -6,7 +6,7 @@ org.hisp.dhis dhis-services - 2.10-SNAPSHOT + 2.11-SNAPSHOT dhis-service-vn === modified file 'local/vn/dhis-web-spreadsheet-reporting/pom.xml' --- local/vn/dhis-web-spreadsheet-reporting/pom.xml 2012-08-06 17:09:13 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/pom.xml 2012-11-26 09:12:15 +0000 @@ -6,7 +6,7 @@ org.hisp.dhis dhis-web - 2.10-SNAPSHOT + 2.11-SNAPSHOT dhis-web-spreadsheet-reporting === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateExcelReportSupport.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateExcelReportSupport.java 2012-05-03 10:04:29 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateExcelReportSupport.java 2012-11-26 09:12:15 +0000 @@ -26,7 +26,6 @@ * (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.period.Period; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.reportsheet.ExportReport; @@ -49,13 +48,13 @@ { statementManager.initialise(); - Period period = PeriodType.createPeriodExternalId( selectionManager.getSelectedPeriodIndex() ); + selectedPeriod = PeriodType.createPeriodExternalId( selectionManager.getSelectedPeriodIndex() ); ExportReport exportReport = exportReportService.getExportReport( selectionManager.getSelectedReportId() ); - this.installPeriod( period ); + this.installPeriod(); - executeGenerateOutputFile( exportReport, period ); + executeGenerateOutputFile( exportReport ); this.complete(); @@ -75,6 +74,6 @@ * @param exportReport * @param organisationUnit */ - protected abstract void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected abstract void executeGenerateOutputFile( ExportReport exportReport ) throws Exception; } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateMultiExcelReportSupport.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateMultiExcelReportSupport.java 2012-05-04 09:50:39 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateMultiExcelReportSupport.java 2012-11-26 09:12:15 +0000 @@ -31,7 +31,6 @@ import org.hisp.dhis.dataelement.LocalDataElementService; import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.reportsheet.CategoryOptionAssociationService; import org.hisp.dhis.reportsheet.ExportReport; @@ -70,9 +69,9 @@ { statementManager.initialise(); - Period period = PeriodType.createPeriodExternalId( selectionManager.getSelectedPeriodIndex() ); + selectedPeriod = PeriodType.createPeriodExternalId( selectionManager.getSelectedPeriodIndex() ); - this.installPeriod( period ); + this.installPeriod(); List reports = new ArrayList(); @@ -81,7 +80,7 @@ reports.add( exportReportService.getExportReport( Integer.parseInt( id ) ) ); } - executeGenerateOutputFile( reports, period ); + executeGenerateOutputFile( reports ); this.complete(); @@ -101,6 +100,6 @@ * @param reports * @param organisationUnit */ - protected abstract void executeGenerateOutputFile( List reports, Period period ) + protected abstract void executeGenerateOutputFile( List reports ) throws Exception; } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java 2012-11-01 07:20:12 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java 2012-11-26 09:12:15 +0000 @@ -167,6 +167,8 @@ protected InputStream inputStream; + private boolean generateByDataSet; + // ------------------------------------------------------------------------- // Local variables // ------------------------------------------------------------------------- @@ -207,6 +209,8 @@ protected Date endSixMonthly; + protected Period selectedPeriod; + // ------------------------------------------------------------------------- // Excel format // ------------------------------------------------------------------------- @@ -218,7 +222,7 @@ protected Font csFont10Normal; protected Font csFont11Bold; - + protected Font csFont11Normal; protected Font csFont12NormalCenter; @@ -226,7 +230,7 @@ protected CellStyle csNumber; protected CellStyle csFormulaBold; - + protected CellStyle csFormulaNormal; protected CellStyle csText; @@ -271,6 +275,11 @@ return inputStream; } + public boolean getGenerateByDataSet() + { + return generateByDataSet; + } + // ------------------------------------------------------------------------- // Supporting methods // ------------------------------------------------------------------------- @@ -366,13 +375,13 @@ } - protected void installPeriod( Period period ) + protected void installPeriod() { Calendar calendar = Calendar.getInstance(); // Daily (or Monthly) period - startDate = period.getStartDate(); - endDate = period.getEndDate(); + startDate = selectedPeriod.getStartDate(); + endDate = selectedPeriod.getEndDate(); // So-far-this-month firstDayOfMonth = getFirstDayOfMonth( startDate ); @@ -382,13 +391,13 @@ // Last 2 months + this month = last 3 month last3MonthStartDate = getTimeRoll( startDate, Calendar.MONTH, -2 ); last3MonthStartDate = getTimeRoll( last3MonthStartDate, Calendar.DATE, -1 ); - last3MonthEndDate = period.getEndDate(); + last3MonthEndDate = selectedPeriod.getEndDate(); // Last 6 month period // Last 5 months + this month = last 6 month last6MonthStartDate = getTimeRoll( startDate, Calendar.MONTH, -5 ); last6MonthStartDate = getTimeRoll( last6MonthStartDate, Calendar.DATE, -1 ); - last6MonthEndDate = period.getEndDate(); + last6MonthEndDate = selectedPeriod.getEndDate(); // Quarterly startQuaterly = getStartQuaterly( startDate ); @@ -408,7 +417,7 @@ endDateOfYear = getLastDayOfYear( calendar.get( Calendar.YEAR ) ); } - protected void installReadTemplateFile( ExportReport exportReport, Period period, Object object ) + protected void installReadTemplateFile( ExportReport exportReport, Object object ) throws Exception { this.outputReportFile = new File( reportLocationManager.getExportReportTemporaryDirectory(), currentUserService @@ -422,7 +431,7 @@ this.initExcelFormat(); this.installDefaultExcelFormat(); - + this.initFormulaEvaluating(); if ( exportReport.getOrganisationRow() != null && exportReport.getOrganisationColumn() != null ) @@ -445,7 +454,7 @@ if ( exportReport.getPeriodRow() != null && exportReport.getPeriodColumn() != null ) { ExcelUtils.writeValueByPOI( exportReport.getPeriodRow(), exportReport.getPeriodColumn(), format - .formatPeriod( period ), ExcelUtils.TEXT, sheetPOI, csTextWithoutBorder ); + .formatPeriod( selectedPeriod ), ExcelUtils.TEXT, sheetPOI, csTextWithoutBorder ); } } @@ -458,25 +467,32 @@ String result = ""; Collection periods = new ArrayList(); - if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) ) - { - periods = periodService.getPeriodsBetweenDates( periodService.getPeriodTypeByName( DailyPeriodType.NAME ), - startDate, startDate ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) ) - { - periods = periodService.getPeriodsBetweenDates( - periodService.getPeriodTypeByName( MonthlyPeriodType.NAME ), startDate, endDate ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) ) - { - periods = periodService.getPeriodsBetweenDates( periodService - .getPeriodTypeByName( QuarterlyPeriodType.NAME ), startQuaterly, endQuaterly ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) ) - { - periods = periodService.getPeriodsBetweenDates( periodService.getPeriodTypeByName( YearlyPeriodType.NAME ), - firstDayOfYear, endDateOfYear ); + if ( generateByDataSet ) + { + periods = periodService.getPeriodsBetweenDates( selectedPeriod.getPeriodType(), startDate, endDate ); + } + else + { + if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) ) + { + periods = periodService.getPeriodsBetweenDates( periodService + .getPeriodTypeByName( DailyPeriodType.NAME ), startDate, startDate ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) ) + { + periods = periodService.getPeriodsBetweenDates( periodService + .getPeriodTypeByName( MonthlyPeriodType.NAME ), startDate, endDate ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) ) + { + periods = periodService.getPeriodsBetweenDates( periodService + .getPeriodTypeByName( QuarterlyPeriodType.NAME ), startQuaterly, endQuaterly ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) ) + { + periods = periodService.getPeriodsBetweenDates( periodService + .getPeriodTypeByName( YearlyPeriodType.NAME ), firstDayOfYear, endDateOfYear ); + } } for ( Period p : periods ) @@ -495,25 +511,32 @@ String result = ""; Collection periods = new ArrayList(); - if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) ) - { - periods = periodService.getPeriodsBetweenDates( periodService.getPeriodTypeByName( DailyPeriodType.NAME ), - startDate, startDate ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) ) - { - periods = periodService.getPeriodsBetweenDates( - periodService.getPeriodTypeByName( MonthlyPeriodType.NAME ), startDate, endDate ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) ) - { - periods = periodService.getPeriodsBetweenDates( periodService - .getPeriodTypeByName( QuarterlyPeriodType.NAME ), startDate, endDate ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) ) - { - periods = periodService.getPeriodsBetweenDates( periodService.getPeriodTypeByName( YearlyPeriodType.NAME ), - startDate, endDate ); + if ( generateByDataSet ) + { + periods = periodService.getPeriodsBetweenDates( selectedPeriod.getPeriodType(), startDate, endDate ); + } + else + { + if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) ) + { + periods = periodService.getPeriodsBetweenDates( periodService + .getPeriodTypeByName( DailyPeriodType.NAME ), startDate, startDate ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) ) + { + periods = periodService.getPeriodsBetweenDates( periodService + .getPeriodTypeByName( MonthlyPeriodType.NAME ), startDate, endDate ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) ) + { + periods = periodService.getPeriodsBetweenDates( periodService + .getPeriodTypeByName( QuarterlyPeriodType.NAME ), startDate, endDate ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) ) + { + periods = periodService.getPeriodsBetweenDates( periodService + .getPeriodTypeByName( YearlyPeriodType.NAME ), startDate, endDate ); + } } for ( Period p : periods ) @@ -534,62 +557,69 @@ { double value = 0.0; - if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) ) - { - value = calculateExpression( generateExpression( exportItem, startDate, startDate, organisationUnit, - dataElementService, categoryService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_MONTH ) ) - { - value = calculateExpression( generateExpression( exportItem, firstDayOfMonth, endDate, organisationUnit, - dataElementService, categoryService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_QUARTER ) ) - { - value = calculateExpression( generateExpression( exportItem, startQuaterly, endDate, organisationUnit, - dataElementService, categoryService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_YEAR ) ) - { - value = calculateExpression( generateExpression( exportItem, firstDayOfYear, endDate, organisationUnit, - dataElementService, categoryService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) ) + if ( generateByDataSet ) { value = calculateExpression( generateExpression( exportItem, startDate, endDate, organisationUnit, dataElementService, categoryService, aggregationService ) ); } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_3_MONTH ) ) - { - value = calculateExpression( generateExpression( exportItem, last3MonthStartDate, last3MonthEndDate, - organisationUnit, dataElementService, categoryService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_6_MONTH ) ) - { - value = calculateExpression( generateExpression( exportItem, last6MonthStartDate, last6MonthEndDate, - organisationUnit, dataElementService, categoryService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) ) - { - value = calculateExpression( generateExpression( exportItem, startQuaterly, endQuaterly, organisationUnit, - dataElementService, categoryService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SIX_MONTH ) ) - { - value = calculateExpression( generateExpression( exportItem, startSixMonthly, endSixMonthly, - organisationUnit, dataElementService, categoryService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.THREE_SIX_NINE_TWELVE_MONTH ) ) - { - value = calculateExpression( generateExpression( exportItem, firstDayOfYear, endQuaterly, organisationUnit, - dataElementService, categoryService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) ) - { - value = calculateExpression( generateExpression( exportItem, firstDayOfYear, endDateOfYear, - organisationUnit, dataElementService, categoryService, aggregationService ) ); - } - + else + { + if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) ) + { + value = calculateExpression( generateExpression( exportItem, startDate, startDate, organisationUnit, + dataElementService, categoryService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_MONTH ) ) + { + value = calculateExpression( generateExpression( exportItem, firstDayOfMonth, endDate, + organisationUnit, dataElementService, categoryService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_QUARTER ) ) + { + value = calculateExpression( generateExpression( exportItem, startQuaterly, endDate, organisationUnit, + dataElementService, categoryService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_YEAR ) ) + { + value = calculateExpression( generateExpression( exportItem, firstDayOfYear, endDate, organisationUnit, + dataElementService, categoryService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) ) + { + value = calculateExpression( generateExpression( exportItem, startDate, endDate, organisationUnit, + dataElementService, categoryService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_3_MONTH ) ) + { + value = calculateExpression( generateExpression( exportItem, last3MonthStartDate, last3MonthEndDate, + organisationUnit, dataElementService, categoryService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_6_MONTH ) ) + { + value = calculateExpression( generateExpression( exportItem, last6MonthStartDate, last6MonthEndDate, + organisationUnit, dataElementService, categoryService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) ) + { + value = calculateExpression( generateExpression( exportItem, startQuaterly, endQuaterly, + organisationUnit, dataElementService, categoryService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SIX_MONTH ) ) + { + value = calculateExpression( generateExpression( exportItem, startSixMonthly, endSixMonthly, + organisationUnit, dataElementService, categoryService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.THREE_SIX_NINE_TWELVE_MONTH ) ) + { + value = calculateExpression( generateExpression( exportItem, firstDayOfYear, endQuaterly, + organisationUnit, dataElementService, categoryService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) ) + { + value = calculateExpression( generateExpression( exportItem, firstDayOfYear, endDateOfYear, + organisationUnit, dataElementService, categoryService, aggregationService ) ); + } + } return value; } @@ -601,57 +631,64 @@ { double value = 0.0; - if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) ) - { - value = calculateExpression( generateIndicatorExpression( exportItem, startDate, startDate, - organisationUnit, indicatorService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) ) + if ( generateByDataSet ) { value = calculateExpression( generateIndicatorExpression( exportItem, startDate, endDate, organisationUnit, indicatorService, aggregationService ) ); } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_QUARTER ) ) - { - value = calculateExpression( generateIndicatorExpression( exportItem, startQuaterly, endDate, - organisationUnit, indicatorService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_YEAR ) ) - { - value = calculateExpression( generateIndicatorExpression( exportItem, firstDayOfYear, endDate, - organisationUnit, indicatorService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_3_MONTH ) ) - { - value = calculateExpression( generateIndicatorExpression( exportItem, last3MonthStartDate, - last3MonthEndDate, organisationUnit, indicatorService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_6_MONTH ) ) - { - value = calculateExpression( generateIndicatorExpression( exportItem, last6MonthStartDate, - last6MonthEndDate, organisationUnit, indicatorService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) ) - { - value = calculateExpression( generateIndicatorExpression( exportItem, startQuaterly, endQuaterly, - organisationUnit, indicatorService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SIX_MONTH ) ) - { - value = calculateExpression( generateIndicatorExpression( exportItem, startSixMonthly, endSixMonthly, - organisationUnit, indicatorService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.THREE_SIX_NINE_TWELVE_MONTH ) ) - { - value = calculateExpression( generateIndicatorExpression( exportItem, firstDayOfYear, endQuaterly, - organisationUnit, indicatorService, aggregationService ) ); - } - else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) ) - { - value = calculateExpression( generateIndicatorExpression( exportItem, firstDayOfYear, endDateOfYear, - organisationUnit, indicatorService, aggregationService ) ); - } - + else + { + if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) ) + { + value = calculateExpression( generateIndicatorExpression( exportItem, startDate, startDate, + organisationUnit, indicatorService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) ) + { + value = calculateExpression( generateIndicatorExpression( exportItem, startDate, endDate, + organisationUnit, indicatorService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_QUARTER ) ) + { + value = calculateExpression( generateIndicatorExpression( exportItem, startQuaterly, endDate, + organisationUnit, indicatorService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_YEAR ) ) + { + value = calculateExpression( generateIndicatorExpression( exportItem, firstDayOfYear, endDate, + organisationUnit, indicatorService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_3_MONTH ) ) + { + value = calculateExpression( generateIndicatorExpression( exportItem, last3MonthStartDate, + last3MonthEndDate, organisationUnit, indicatorService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_6_MONTH ) ) + { + value = calculateExpression( generateIndicatorExpression( exportItem, last6MonthStartDate, + last6MonthEndDate, organisationUnit, indicatorService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) ) + { + value = calculateExpression( generateIndicatorExpression( exportItem, startQuaterly, endQuaterly, + organisationUnit, indicatorService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SIX_MONTH ) ) + { + value = calculateExpression( generateIndicatorExpression( exportItem, startSixMonthly, endSixMonthly, + organisationUnit, indicatorService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.THREE_SIX_NINE_TWELVE_MONTH ) ) + { + value = calculateExpression( generateIndicatorExpression( exportItem, firstDayOfYear, endQuaterly, + organisationUnit, indicatorService, aggregationService ) ); + } + else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) ) + { + value = calculateExpression( generateIndicatorExpression( exportItem, firstDayOfYear, endDateOfYear, + organisationUnit, indicatorService, aggregationService ) ); + } + } return value; } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java 2012-10-02 04:32:52 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java 2012-11-26 09:12:15 +0000 @@ -68,11 +68,11 @@ return organisationGroupId; } - private boolean showSubItem; + private Boolean showSubItem; public boolean isShowSubItem() { - return showSubItem; + return (showSubItem == null) ? false : showSubItem; } public void setShowSubItem( boolean showSubItem ) @@ -80,6 +80,18 @@ this.showSubItem = showSubItem; } + private Boolean generateByDefault; + + public boolean getGenerateByDefault() + { + return (generateByDefault == null) ? false : generateByDefault; + } + + public void setGenerateByDefault( Boolean generateByDefault ) + { + this.generateByDefault = generateByDefault; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateMultiReportAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateMultiReportAction.java 2012-11-01 07:20:12 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateMultiReportAction.java 2012-11-26 09:12:15 +0000 @@ -47,7 +47,6 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitLevel; -import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.AttributeValueGroupOrder; import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder; import org.hisp.dhis.reportsheet.DataElementGroupOrder; @@ -72,14 +71,14 @@ private static final String PREFIX_FORMULA_SUM = "SUM("; @Override - protected void executeGenerateOutputFile( List reports, Period period ) + protected void executeGenerateOutputFile( List reports ) throws Exception { OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo(); Collection exportItems = null; - this.installReadTemplateFile( reports.get( 0 ), period, organisationUnit ); + this.installReadTemplateFile( reports.get( 0 ), organisationUnit ); for ( ExportReport report : reports ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java 2012-10-29 10:31:16 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java 2012-11-26 09:12:15 +0000 @@ -40,7 +40,6 @@ import org.hisp.dhis.dataelement.DataElementFormNameComparator; import org.hisp.dhis.dataelement.LocalDataElementService; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.AttributeValueGroupOrder; import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReport; @@ -60,19 +59,19 @@ private LocalDataElementService localDataElementService; @Override - protected void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected void executeGenerateOutputFile( ExportReport exportReport ) throws Exception { OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); ExportReportAttribute exportReportInstance = (ExportReportAttribute) exportReport; - this.installReadTemplateFile( exportReportInstance, period, organisationUnit ); + this.installReadTemplateFile( exportReportInstance, organisationUnit ); DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo(); Collection exportReportItems = null; - + for ( Integer sheetNo : exportReportService.getSheets( selectionManager.getSelectedReportId() ) ) { Sheet sheet = this.templateWorkbook.getSheetAt( sheetNo - 1 ); @@ -81,7 +80,7 @@ this.generateOutPutFile( defaultOptionCombo, exportReportInstance, exportReportItems, organisationUnit, sheet ); - + this.recalculatingFormula( sheet ); } @@ -145,7 +144,7 @@ { int id = Integer.parseInt( exportItem.getExpression().split( "@" )[0].replace( "[", "" ) ); String value = exportItem.getExpression().split( "@" )[1].replace( "]", "" ); - + for ( DataElement de : dataElements ) { if ( localDataElementService.getDataElementCount( de.getId(), id, value ) > 0 ) === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportCategoryAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportCategoryAction.java 2012-11-01 07:20:12 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportCategoryAction.java 2012-11-26 09:12:15 +0000 @@ -33,7 +33,6 @@ import org.apache.poi.ss.usermodel.Sheet; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.DataElementGroupOrder; import org.hisp.dhis.reportsheet.DataElementGroupOrderService; import org.hisp.dhis.reportsheet.ExportItem; @@ -58,14 +57,14 @@ private DataElementGroupOrderService dataElementGroupOrderService; @Override - protected void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected void executeGenerateOutputFile( ExportReport exportReport ) throws Exception { OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); ExportReportCategory exportReportInstance = (ExportReportCategory) exportReport; - this.installReadTemplateFile( exportReportInstance, period, organisationUnit ); + this.installReadTemplateFile( exportReportInstance, organisationUnit ); Collection exportReportItems = null; List orderedGroups = null; === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java 2012-11-01 07:20:12 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java 2012-11-26 09:12:15 +0000 @@ -31,7 +31,6 @@ import org.apache.poi.ss.usermodel.Sheet; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReport; import org.hisp.dhis.reportsheet.ExportReportNormal; @@ -48,14 +47,14 @@ extends AbstractGenerateExcelReportSupport { @Override - protected void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected void executeGenerateOutputFile( ExportReport exportReport ) throws Exception { OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); ExportReportNormal exportReportInstance = (ExportReportNormal) exportReport; - this.installReadTemplateFile( exportReportInstance, period, organisationUnit ); + this.installReadTemplateFile( exportReportInstance, organisationUnit ); Collection exportReportItems = null; === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2012-11-16 11:04:48 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2012-11-26 09:12:15 +0000 @@ -42,7 +42,6 @@ import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReport; import org.hisp.dhis.reportsheet.ExportReportOrganizationGroupListing; @@ -88,7 +87,7 @@ // ------------------------------------------------------------------------- @Override - protected void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected void executeGenerateOutputFile( ExportReport exportReport ) throws Exception { OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); @@ -100,7 +99,7 @@ prepareChildrenGroupMap( exportReportInstance, organisationUnit, orgUnitGroupAtLevels ); - this.installReadTemplateFile( exportReportInstance, period, organisationUnit ); + this.installReadTemplateFile( exportReportInstance, organisationUnit ); Collection exportReportItems = null; === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java 2012-10-29 10:31:16 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java 2012-11-26 09:12:15 +0000 @@ -32,7 +32,6 @@ import org.apache.poi.ss.usermodel.Sheet; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReport; import org.hisp.dhis.reportsheet.ExportReportPeriodColumnListing; @@ -52,17 +51,17 @@ extends AbstractGenerateExcelReportSupport { @Override - protected void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected void executeGenerateOutputFile( ExportReport exportReport ) throws Exception { OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); ExportReportPeriodColumnListing exportReportInstance = (ExportReportPeriodColumnListing) exportReport; - this.installReadTemplateFile( exportReportInstance, period, organisationUnit ); + this.installReadTemplateFile( exportReportInstance, organisationUnit ); Collection exportReportItems = null; - + for ( Integer sheetNo : exportReportService.getSheets( selectionManager.getSelectedReportId() ) ) { Sheet sheet = this.templateWorkbook.getSheetAt( sheetNo - 1 ); @@ -71,10 +70,10 @@ this.generateOutPutFile( exportReportInstance.getPeriodColumns(), exportReportItems, organisationUnit, sheet ); - + this.recalculatingFormula( sheet ); } - + /** * Garbage */ @@ -98,21 +97,25 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) ) { - // value = this.getDataValue( reportItem, organisationUnit ); + // value = this.getDataValue( reportItem, + // organisationUnit ); value = MathUtils.calculateExpression( ExpressionUtils.generateExpression( reportItem, p - .getStartdate(), p.getEnddate(), organisationUnit, dataElementService, categoryService, aggregationService ) ); + .getStartdate(), p.getEnddate(), organisationUnit, dataElementService, categoryService, + aggregationService ) ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_VALUETYPE_TEXT ) ) { - String result = this.getTextValue( reportItem, organisationUnit, p.getStartdate(), p.getEnddate() ); + String result = this.getTextValue( reportItem, organisationUnit, p.getStartdate(), p + .getEnddate() ); ExcelUtils.writeValueByPOI( reportItem.getRow(), reportItem.getColumn(), result, ExcelUtils.TEXT, sheet, this.csText ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) ) { - // value = this.getIndicatorValue( reportItem, organisationUnit ); + // value = this.getIndicatorValue( reportItem, + // organisationUnit ); value = MathUtils.calculateExpression( ExpressionUtils.generateIndicatorExpression( reportItem, p.getStartdate(), p.getEnddate(), organisationUnit, indicatorService, aggregationService ) ); === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java 2012-11-01 07:20:12 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java 2012-11-26 09:12:15 +0000 @@ -34,7 +34,6 @@ import org.hisp.dhis.dataelement.DataElementCategoryOption; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder; import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReport; @@ -55,14 +54,14 @@ private OptionComboAssociationService optionComboAssociationService; @Override - protected void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected void executeGenerateOutputFile( ExportReport exportReport ) throws Exception { OrganisationUnit unit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); ExportReportVerticalCategory exportReportInstance = (ExportReportVerticalCategory) exportReport; - this.installReadTemplateFile( exportReportInstance, period, unit ); + this.installReadTemplateFile( exportReportInstance, unit ); Collection exportReportItems = null; === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java 2012-09-19 02:22:55 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java 2012-11-26 09:12:15 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.reportsheet.exporting.action; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,8 +29,16 @@ import java.io.File; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.period.CalendarPeriodType; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.reportsheet.ExportReport; import org.hisp.dhis.reportsheet.ExportReportService; import org.hisp.dhis.reportsheet.ReportLocationManager; @@ -55,6 +63,13 @@ this.exportReportService = exportReportService; } + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + private SelectionManager selectionManager; public void setSelectionManager( SelectionManager selectionManager ) @@ -69,6 +84,20 @@ this.reportLocationManager = reportLocationManager; } + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + + private CompleteDataSetRegistrationService dataSetRegistrationService; + + public void setDataSetRegistrationService( CompleteDataSetRegistrationService dataSetRegistrationService ) + { + this.dataSetRegistrationService = dataSetRegistrationService; + } + // ------------------------------------------------------------------------- // Input & Output // ------------------------------------------------------------------------- @@ -94,6 +123,20 @@ this.periodIndex = periodIndex; } + private Boolean generateByDataSet = false; + + public void setGenerateByDataSet( Boolean generateByDataSet ) + { + this.generateByDataSet = generateByDataSet; + } + + private Integer selectedDataSetId; + + public void setSelectedDataSetId( Integer selectedDataSetId ) + { + this.selectedDataSetId = selectedDataSetId; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -101,6 +144,29 @@ public String execute() throws Exception { + if ( generateByDataSet ) + { + DataSet dataSet = dataSetService.getDataSet( selectedDataSetId ); + + if ( dataSet == null ) + { + message = i18n.getString( "specified_data_set_unavailable" ); + + return ERROR; + } + + ExportReport exportReport = exportReportService.getExportReportByDataSet( dataSet ); + + if ( exportReport == null ) + { + message = i18n.getString( "specified_data_set_unassign_to_export_report" ); + + return ERROR; + } + + exportReportIds[0] = exportReport.getId() + "_"; + } + if ( exportReportIds == null || exportReportIds.length == 0 ) { message = i18n.getString( "specify_export_report" ); @@ -138,6 +204,33 @@ // return ERROR; // } + Period period = periodService.getPeriodByExternalId( periodIndex ); + + for ( DataSet ds : exportReport.getDataSets() ) + { + CalendarPeriodType periodType = (CalendarPeriodType) ds.getPeriodType(); + + List periods = periodType.generatePeriods( period.getStartDate() ); + Collection persistedPeriods = periodService.getPeriodsByPeriodType( periodType ); + + periods.retainAll( persistedPeriods ); + + for ( Period p : periods ) + { + for ( OrganisationUnit o : ds.getSources() ) + { + if ( dataSetRegistrationService.getCompleteDataSetRegistration( ds, p, o ) == null ) + { + message = i18n.getString( "org_unit_with_name" ) + " \"" + o.getDisplayName() + " \"."; + message += i18n.getString( "data_set_with_name" ) + " \"" + ds.getDisplayName() + "\" "; + message += i18n.getString( "uncompleted" ); + + return ERROR; + } + } + } + } + File templateFile = new File( templateDirectory, exportReport.getExcelTemplateFile() ); if ( templateFile == null || !templateFile.exists() ) === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportCategoryAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportCategoryAction.java 2012-11-01 07:20:12 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportCategoryAction.java 2012-11-26 09:12:15 +0000 @@ -37,11 +37,10 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; -import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.DataElementGroupOrder; +import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReport; import org.hisp.dhis.reportsheet.ExportReportCategory; -import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.exporting.AbstractGenerateExcelReportSupport; import org.hisp.dhis.reportsheet.utils.ExcelUtils; @@ -80,7 +79,7 @@ // ------------------------------------------------------------------------- @Override - protected void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected void executeGenerateOutputFile( ExportReport exportReport ) throws Exception { OrganisationUnitGroup organisationUnitGroup = organisationUnitGroupService @@ -88,7 +87,7 @@ ExportReportCategory exportReportInstance = (ExportReportCategory) exportReport; - this.installReadTemplateFile( exportReportInstance, period, organisationUnitGroup ); + this.installReadTemplateFile( exportReportInstance, organisationUnitGroup ); for ( Integer sheetNo : exportReportService.getSheets( selectionManager.getSelectedReportId() ) ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportNormalAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportNormalAction.java 2011-08-04 08:39:55 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportNormalAction.java 2012-11-26 09:12:15 +0000 @@ -35,9 +35,8 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; -import org.hisp.dhis.period.Period; +import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReport; -import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReportNormal; import org.hisp.dhis.reportsheet.exporting.AbstractGenerateExcelReportSupport; import org.hisp.dhis.reportsheet.utils.ExcelUtils; @@ -76,7 +75,7 @@ // ------------------------------------------------------------------------- @Override - protected void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected void executeGenerateOutputFile( ExportReport exportReport ) throws Exception { OrganisationUnitGroup organisationUnitGroup = organisationUnitGroupService @@ -88,7 +87,7 @@ Collection exportItems = exportReportInstance.getExportItems(); - this.installReadTemplateFile( exportReportInstance, period, organisationUnitGroup ); + this.installReadTemplateFile( exportReportInstance, organisationUnitGroup ); for ( ExportItem exportItem : exportItems ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportOrgGroupListingAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportOrgGroupListingAction.java 2012-11-01 07:20:12 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportOrgGroupListingAction.java 2012-11-26 09:12:15 +0000 @@ -37,7 +37,6 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; -import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReport; import org.hisp.dhis.reportsheet.ExportReportOrganizationGroupListing; @@ -79,7 +78,7 @@ // ------------------------------------------------------------------------- @Override - protected void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected void executeGenerateOutputFile( ExportReport exportReport ) throws Exception { OrganisationUnitGroup organisationUnitGroup = organisationUnitGroupService @@ -87,7 +86,7 @@ ExportReportOrganizationGroupListing exportReportInstance = (ExportReportOrganizationGroupListing) exportReport; - this.installReadTemplateFile( exportReportInstance, period, organisationUnitGroup ); + this.installReadTemplateFile( exportReportInstance, organisationUnitGroup ); for ( Integer sheetNo : exportReportService.getSheets( selectionManager.getSelectedReportId() ) ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportPeriodColumnListingAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportPeriodColumnListingAction.java 2012-05-11 19:42:32 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportPeriodColumnListingAction.java 2012-11-26 09:12:15 +0000 @@ -34,11 +34,10 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.reportsheet.PeriodColumn; +import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReport; -import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReportPeriodColumnListing; +import org.hisp.dhis.reportsheet.PeriodColumn; import org.hisp.dhis.reportsheet.exporting.AbstractGenerateExcelReportSupport; import org.hisp.dhis.reportsheet.utils.ExcelUtils; import org.hisp.dhis.reportsheet.utils.ExpressionUtils; @@ -80,7 +79,7 @@ // ------------------------------------------------------------------------- @Override - protected void executeGenerateOutputFile( ExportReport exportReport, Period period ) + protected void executeGenerateOutputFile( ExportReport exportReport ) throws Exception { OrganisationUnitGroup organisationUnitGroup = organisationUnitGroupService @@ -88,7 +87,7 @@ ExportReportPeriodColumnListing exportReportInstance = (ExportReportPeriodColumnListing) exportReport; - this.installReadTemplateFile( exportReportInstance, period, organisationUnitGroup ); + this.installReadTemplateFile( exportReportInstance, organisationUnitGroup ); for ( Integer sheetNo : exportReportService.getSheets( selectionManager.getSelectedReportId() ) ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/SetupExportItemFormAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/SetupExportItemFormAction.java 2012-07-09 09:16:24 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/SetupExportItemFormAction.java 2012-11-26 09:12:15 +0000 @@ -27,6 +27,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -39,6 +40,9 @@ import org.hisp.dhis.reportsheet.ExportItem; import org.hisp.dhis.reportsheet.ExportReport; import org.hisp.dhis.reportsheet.ExportReportService; +import org.hisp.dhis.reportsheet.ReportLocationManager; +import org.hisp.dhis.reportsheet.state.SelectionManager; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -74,6 +78,22 @@ this.exportReportService = exportReportService; } + @Autowired + private SelectionManager selectionManager; + + public void setSelectionManager( SelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + @Autowired + private ReportLocationManager reportLocationManager; + + public void setReportLocationManager( ReportLocationManager reportLocationManager ) + { + this.reportLocationManager = reportLocationManager; + } + // ------------------------------------------------------------------------- // Input // ------------------------------------------------------------------------- @@ -139,6 +159,12 @@ { exportReport = this.exportReportService.getExportReport( this.exportReportId ); + if ( exportReport != null ) + { + selectionManager.setDownloadFilePath( reportLocationManager.getExportReportTemplateDirectory().getPath() + + File.separator + exportReport.getExcelTemplateFile() ); + } + dataElementGroups = new ArrayList( dataElementService.getAllDataElementGroups() ); Collections.sort( dataElementGroups, new IdentifiableObjectNameComparator() ); @@ -154,5 +180,4 @@ return SUCCESS; } - -} +} \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java 2012-07-12 10:18:47 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java 2012-11-26 09:12:15 +0000 @@ -28,6 +28,7 @@ */ import java.util.Date; +import java.util.Set; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; @@ -130,7 +131,8 @@ // Supportive methods // ------------------------------------------------------------------------- - protected void addDataValue( OrganisationUnit unit, Period period, String expression, String value ) + protected void addDataValue( OrganisationUnit unit, Period period, String expression, String value, + Set oldList, Set newList ) { value = value.replaceAll( "\\.", "" ).replace( ",", "." ); @@ -149,9 +151,13 @@ { dataValue = new DataValue( dataElement, period, unit, value, storedBy, new Date(), null, optionCombo ); dataValueService.addDataValue( dataValue ); + + newList.add( dataValue ); } else { + oldList.add( dataValue ); + dataValue.setValue( value ); dataValue.setTimestamp( new Date() ); dataValue.setStoredBy( storedBy ); === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataCategoryAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataCategoryAction.java 2012-04-26 06:08:03 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataCategoryAction.java 2012-11-26 09:12:15 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.reportsheet.importing.action; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,12 +27,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.HashSet; +import java.util.Set; + +import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.importing.ImportDataGeneric; /** - * @author Chau Thu Tran * @author Dang Duy Hieu * @version $Id$ */ @@ -46,9 +49,16 @@ public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds ) { + Set oldDataValues = new HashSet(); + Set newDataValues = new HashSet(); + for ( int i = 0; i < importItemIds.length; i++ ) { - addDataValue( organisationUnit, period, importItemIds[i].split( "_" )[0], importItemIds[i].split( "_" )[1] ); + addDataValue( organisationUnit, period, importItemIds[i].split( "_" )[0], importItemIds[i].split( "_" )[1], + oldDataValues, newDataValues ); } + + selectionManager.setOldDataValueList( oldDataValues ); + selectionManager.setNewDataValueList( newDataValues ); } } \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataNormalAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataNormalAction.java 2012-04-26 06:08:03 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataNormalAction.java 2012-11-26 09:12:15 +0000 @@ -27,12 +27,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.HashSet; +import java.util.Set; + +import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.importing.ImportDataGeneric; /** - * @author Chau Thu Tran * @author Dang Duy Hieu * @version $Id$ */ @@ -46,9 +49,16 @@ public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds ) { + Set oldDataValues = new HashSet(); + Set newDataValues = new HashSet(); + for ( int i = 0; i < importItemIds.length; i++ ) { - addDataValue( organisationUnit, period, importItemIds[i].split( "_" )[0], importItemIds[i].split( "_" )[1] ); + addDataValue( organisationUnit, period, importItemIds[i].split( "_" )[0], importItemIds[i].split( "_" )[1], + oldDataValues, newDataValues ); } + + selectionManager.setOldDataValueList( oldDataValues ); + selectionManager.setNewDataValueList( newDataValues ); } } \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataOrganizationGroupAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataOrganizationGroupAction.java 2012-04-26 06:08:03 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataOrganizationGroupAction.java 2012-11-26 09:12:15 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.reportsheet.importing.action; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,12 +27,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.HashSet; +import java.util.Set; + +import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.importing.ImportDataGeneric; /** - * @author Chau Thu Tran * @author Dang Duy Hieu * @version $Id$ */ @@ -47,12 +50,19 @@ @Override public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds ) { + Set oldDataValues = new HashSet(); + Set newDataValues = new HashSet(); + for ( int i = 0; i < importItemIds.length; i++ ) { OrganisationUnit o = organisationUnitService.getOrganisationUnit( Integer.parseInt( importItemIds[i] .split( "-" )[0] ) ); - addDataValue( o, period, importItemIds[i].split( "_" )[1], importItemIds[i].split( "_" )[2] ); + addDataValue( o, period, importItemIds[i].split( "_" )[1], importItemIds[i].split( "_" )[2], oldDataValues, + newDataValues ); } + + selectionManager.setOldDataValueList( oldDataValues ); + selectionManager.setNewDataValueList( newDataValues ); } } === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/RollbackImportingAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/RollbackImportingAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/RollbackImportingAction.java 2012-11-26 09:12:15 +0000 @@ -0,0 +1,80 @@ +package org.hisp.dhis.reportsheet.importing.action; + +/* + * Copyright (c) 2004-2012, 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 java.util.Set; + +import org.hisp.dhis.datavalue.DataValue; +import org.hisp.dhis.datavalue.DataValueService; +import org.hisp.dhis.reportsheet.state.SelectionManager; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ + +public class RollbackImportingAction + implements Action +{ + @Autowired + private SelectionManager selectionManager; + + @Autowired + private DataValueService dataValueService; + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + Set oldDataValues = selectionManager.getOldDataValueList(); + Set newDataValues = selectionManager.getNewDataValueList(); + + if ( oldDataValues != null ) + { + for ( DataValue dv : oldDataValues ) + { + dataValueService.updateDataValue( dv ); + } + } + + if ( newDataValues != null ) + { + for ( DataValue dv : newDataValues ) + { + dataValueService.deleteDataValue( dv ); + } + } + + return SUCCESS; + } +} \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/state/DefaultSelectionManager.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/state/DefaultSelectionManager.java 2012-09-19 02:22:55 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/state/DefaultSelectionManager.java 2012-11-26 09:12:15 +0000 @@ -29,6 +29,9 @@ import java.util.List; import java.util.Map; +import java.util.Set; + +import org.hisp.dhis.datavalue.DataValue; import com.opensymphony.xwork2.ActionContext; @@ -55,6 +58,10 @@ private static final String SESSION_KEY_LIST_ORDERED_GROUP = "SESSION_KEY_LIST_ORDERED_GROUP"; + private static final String SESSION_KEY_OLD_DATA_VALUE_LIST = "SESSION_KEY_OLD_DATA_VALUE_LIST"; + + private static final String SESSION_KEY_NEW_DATA_VALUE_LIST = "SESSION_KEY_NEW_DATA_VALUE_LIST"; + public String getDownloadFilePath() { return (String) getSession().get( SESSION_KEY_FILE_DOWNLOAD ); @@ -127,7 +134,7 @@ getSession().put( SESSION_KEY_LIST_OBJECT, objects ); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List getOrderedGroupList() { return (List) getSession().get( SESSION_KEY_LIST_ORDERED_GROUP ); @@ -149,4 +156,28 @@ { getSession().put( SESSION_KEY_SELECTED_PERIOD_ID, periodIndex ); } + + @SuppressWarnings("unchecked") + public Set getNewDataValueList() + { + return (Set) getSession().get( SESSION_KEY_NEW_DATA_VALUE_LIST ); + } + + @SuppressWarnings("unchecked") + public Set getOldDataValueList() + { + return (Set) getSession().get( SESSION_KEY_OLD_DATA_VALUE_LIST ); + } + + @SuppressWarnings("unchecked") + public void setNewDataValueList( Set dataValues ) + { + getSession().put( SESSION_KEY_NEW_DATA_VALUE_LIST, dataValues ); + } + + @SuppressWarnings("unchecked") + public void setOldDataValueList( Set dataValues ) + { + getSession().put( SESSION_KEY_OLD_DATA_VALUE_LIST, dataValues ); + } } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/state/SelectionManager.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/state/SelectionManager.java 2012-09-19 02:22:55 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/state/SelectionManager.java 2012-11-26 09:12:15 +0000 @@ -27,6 +27,9 @@ package org.hisp.dhis.reportsheet.state; import java.util.List; +import java.util.Set; + +import org.hisp.dhis.datavalue.DataValue; /** * @author Tran Thanh Tri @@ -41,28 +44,36 @@ public String getUploadFilePath(); public void setUploadFilePath( String path ); - + public void setSelectedReportId( Integer id ); - + public Integer getSelectedReportId(); - + public String getRenameFilePath(); public void setRenameFilePath( String path ); - + public String getSelectedPeriodIndex(); - + public void setSelectedPeriodIndex( String periodIndex ); - + public void setBookmarkType( String type ); - + public String getBookmarkType(); - + public String[] getListObject(); - + public void setListObject( String[] objects ); - + public List getOrderedGroupList(); public void setOrderedGroupList( List objects ); + + public Set getOldDataValueList(); + + public void setOldDataValueList( Set dataValues ); + + public Set getNewDataValueList(); + + public void setNewDataValueList( Set dataValues ); } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-11-16 11:04:48 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-11-26 09:12:15 +0000 @@ -594,6 +594,12 @@ scope="prototype"> + + + + + + === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties 2012-11-16 11:04:48 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties 2012-11-26 09:12:15 +0000 @@ -374,4 +374,9 @@ add_multi_organisation_unit = Add Multi-org-unit filter_on_section = Filter on section do_not_show_sub_item = Don't show sub-items in group -permission_notification = You don't have any permission in this Export report. Please contact with \ No newline at end of file +permission_notification = You don't have any permission in this Export report. Please contact with +org_unit_with_name = Organisation unit +data_set_with_name = Data set +uncompleted = uncompleted +specified_data_set_unavailable = Selected data set is not exist +specified_data_set_unassign_to_export_report = Selected data set is not assign to any Export report \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties 2012-11-16 11:04:48 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties 2012-11-26 09:12:15 +0000 @@ -404,4 +404,9 @@ filter_on_section=L\u1ecdc theo nh\u00f3m do_not_show_sub_item = Kh\u00f4ng hi\u1ec3n th\u1ecb chi ti\u1ebft trong nh\u00f3m permission_notification = B\u1ea1n kh\u00f4ng c\u00f3 quy\u1ec1n thao t\u00e1c tr\u00ean b\u00e1o c\u00e1o Xu\u1ea5t n\u00e0y. Vui l\u00f2ng li\u00ean h\u1ec7 v\u1edbi -via_email = th\u00f4ng qua th\u01b0 \u0111i\u1ec7n t\u1eed \ No newline at end of file +via_email = th\u00f4ng qua th\u01b0 \u0111i\u1ec7n t\u1eed +org_unit_with_name = \u0110\u01a1n v\u1ecb +data_set_with_name = Bi\u1ec3u nh\u1eadp +uncompleted = ch\u01b0a ho\u00e0n t\u1ea5t +specified_data_set_unavailable = M\u1eabu b\u00e1o c\u00e1o n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i +specified_data_set_unassign_to_export_report = M\u1eabu b\u00e1o c\u00e1o n\u00e0y ch\u01b0a \u0111\u01b0\u1ee3c g\u00e1n v\u00e0o b\u1ea5t k\u1ef3 bi\u1ec3u Xu\u1ea5t n\u00e0o \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2012-11-19 04:33:42 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2012-11-26 09:12:15 +0000 @@ -766,19 +766,19 @@ - generateReportAttribute.action + generateReportAttribute.action?generateByDataSet=${generateByDataSet} - generateReportCategory.action + generateReportCategory.action?generateByDataSet=${generateByDataSet} - generateReportVerticalCategory.action + generateReportVerticalCategory.action?generateByDataSet=${generateByDataSet} - generateReportNormal.action + generateReportNormal.action?generateByDataSet=${generateByDataSet} - generateReportOrgGroupListing.action?showSubItem=${showSubItem} + generateReportOrgGroupListing.action?generateByDataSet=${generateByDataSet}&showSubItem=${showSubItem} - generateReportPeriodColumnListing.action + generateReportPeriodColumnListing.action?generateByDataSet=${generateByDataSet} - generateMultiReport.action + generateMultiReport.action?generateByDataSet=${generateByDataSet} - generatePreviewAttribute.action + generatePreviewAttribute.action?generateByDataSet=${generateByDataSet} - generatePreviewCategory.action + generatePreviewCategory.action?generateByDataSet=${generateByDataSet} - generatePreviewVerticalCategory.action + generatePreviewVerticalCategory.action?generateByDataSet=${generateByDataSet} - generatePreviewNormal.action + generatePreviewNormal.action?generateByDataSet=${generateByDataSet} - generatePreviewOrgGroupListing.action?showSubItem=${showSubItem} + generatePreviewOrgGroupListing.action?generateByDataSet=${generateByDataSet}&showSubItem=${showSubItem} - generatePreviewPeriodColumnListing.action + generatePreviewPeriodColumnListing.action?generateByDataSet=${generateByDataSet} - generatePreviewMultiReport.action + generatePreviewMultiReport.action?generateByDataSet=${generateByDataSet} /dhis-web-commons/ajax/jsonResponseInput.vm + F_EXCEL_IMPORTING style/style.css, style/previewStyle.css - F_EXCEL_IMPORT_DATA + F_EXCEL_IMPORTING /main.vm /dhis-web-spreadsheet-reporting/import/importReportAssociation.vm - /dhis-web-spreadsheet-reporting/menu.vm + /dhis-web-spreadsheet-reporting/menu.vm + F_EXCEL_IMPORT_REPORT_ASSOCIATION @@ -1403,7 +1405,7 @@ /dhis-web-spreadsheet-reporting/responseExportReportPreview.vm - /dhis-web-commons/ajax/xmlResponseError.vm + /dhis-web-commons/ajax/xmlResponseError.vm @@ -1417,6 +1419,7 @@ importDataOrganizationGroup.action generateExportReportPeriodColumnListingAjax.action + F_EXCEL_IMPORTING /dhis-web-commons/ajax/jsonResponseError.vm + plainTextError /dhis-web-commons/ajax/jsonResponseError.vm + plainTextError /dhis-web-commons/ajax/jsonResponseError.vm + plainTextError + + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + /dhis-web-commons/ajax/jsonResponseError.vm + plainTextError + F_EXCEL_IMPORTING