=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessConfiguration.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessConfiguration.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessConfiguration.java 1970-01-01 00:00:00 +0000 @@ -1,91 +0,0 @@ -package org.hisp.dhis.completeness; - -/* - * 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 java.io.Serializable; -import java.util.Calendar; -import java.util.Date; - -import org.hisp.dhis.period.Period; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class DataSetCompletenessConfiguration - implements Serializable -{ - private Integer days; - - private Calendar cal = Calendar.getInstance(); - - // ------------------------------------------------------------------------- - // Constructors - // ------------------------------------------------------------------------- - - public DataSetCompletenessConfiguration() - { - } - - public DataSetCompletenessConfiguration( Integer days ) - { - this.days = days; - } - - // ------------------------------------------------------------------------- - // Logic methods - // ------------------------------------------------------------------------- - - public Date getDeadline( Period period ) - { - Date date = null; - - if ( period != null ) - { - if ( days != null && cal != null ) - { - cal.clear(); - cal.setTime( period.getEndDate() ); - cal.add( Calendar.DAY_OF_MONTH, days ); - - date = cal.getTime(); - } - else - { - date = period.getEndDate(); - } - } - - return date; - } - - // ------------------------------------------------------------------------- - // Getters - // ------------------------------------------------------------------------- - - public Integer getDays() - { - return days; - } -} === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java 2011-02-03 20:42:05 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java 2011-02-18 20:20:07 +0000 @@ -31,7 +31,6 @@ import java.util.Date; import org.hisp.dhis.dataset.DataSet; -import org.hisp.dhis.external.configuration.NoConfigurationFoundException; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.RelativePeriods; @@ -102,20 +101,6 @@ DataSetCompletenessResult getDataSetCompleteness( Period period, Date deadline, OrganisationUnit unit, DataSet dataSet ); /** - * Sets the configuration for the data completeness functionality. - * @param configuration the configuration object. - */ - void setConfiguration( DataSetCompletenessConfiguration configuration ); - - /** - * Gets the configuration for the data completeness functionality. - * @return the configuration for the data completeness functionality. - * @throws NoConfigurationFoundException - */ - DataSetCompletenessConfiguration getConfiguration() - throws NoConfigurationFoundException; - - /** * Creates an index on the aggregateddatasetcompleteness table. */ void createIndex(); === modified file 'dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/SystemSettingManager.java' --- dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/SystemSettingManager.java 2011-02-01 11:03:47 +0000 +++ dhis-2/dhis-services/dhis-service-options/src/main/java/org/hisp/dhis/options/SystemSettingManager.java 2011-02-18 20:20:07 +0000 @@ -53,6 +53,7 @@ final String KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED = "dataEntryFormCompleted"; final String KEY_FACTOR_OF_DEVIATION = "factorDeviation"; final String KEY_AGGREGATION_STRATEGY = "aggregationStrategy"; + final String KEY_COMPLETENESS_OFFSET = "completenessOffset"; final String KEY_PATIENT_EXCEL_TEMPLATE_FILE_NAME = "patientExcelTemplateFileName"; final String KEY_CHR_IMAGE_DIRECTORY = "chrImageDirectory"; @@ -65,6 +66,7 @@ final String AGGREGATION_STRATEGY_REAL_TIME = "real_time"; final String AGGREGATION_STRATEGY_BATCH = "batch"; final String DEFAULT_AGGREGATION_STRATEGY = AGGREGATION_STRATEGY_REAL_TIME; + final int DEFAULT_COMPLETENESS_OFFSET = 15; void saveSystemSetting( String name, Serializable value ); === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java 2011-02-03 20:42:05 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java 2011-02-18 20:20:07 +0000 @@ -27,9 +27,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.io.InputStream; -import java.io.OutputStream; +import static org.hisp.dhis.options.SystemSettingManager.DEFAULT_COMPLETENESS_OFFSET; +import static org.hisp.dhis.options.SystemSettingManager.KEY_COMPLETENESS_OFFSET; + import java.util.ArrayList; +import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.List; @@ -38,17 +40,14 @@ import org.amplecode.quick.BatchHandlerFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hisp.dhis.completeness.DataSetCompletenessConfiguration; import org.hisp.dhis.completeness.DataSetCompletenessResult; import org.hisp.dhis.completeness.DataSetCompletenessService; import org.hisp.dhis.completeness.DataSetCompletenessStore; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; -import org.hisp.dhis.external.configuration.ConfigurationManager; -import org.hisp.dhis.external.location.LocationManager; -import org.hisp.dhis.external.location.LocationManagerException; import org.hisp.dhis.jdbc.batchhandler.DataSetCompletenessResultBatchHandler; +import org.hisp.dhis.options.SystemSettingManager; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.Period; @@ -69,24 +68,6 @@ private static final Log log = LogFactory.getLog( AbstractDataSetCompletenessService.class ); // ------------------------------------------------------------------------- - // Properties - // ------------------------------------------------------------------------- - - private String configDir; - - public void setConfigDir( String configDir ) - { - this.configDir = configDir; - } - - private String configFile; - - public void setConfigFile( String configFile ) - { - this.configFile = configFile; - } - - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -131,19 +112,12 @@ { this.completenessStore = completenessStore; } - - protected LocationManager locationManager; - - public void setLocationManager( LocationManager locationManager ) - { - this.locationManager = locationManager; - } - - protected ConfigurationManager configurationManager; - - public void setConfigurationManager( ConfigurationManager configurationManager ) - { - this.configurationManager = configurationManager; + + private SystemSettingManager systemSettingManager; + + public void setSystemSettingManager( SystemSettingManager systemSettingManager ) + { + this.systemSettingManager = systemSettingManager; } // ------------------------------------------------------------------------- @@ -181,7 +155,7 @@ { log.info( "Data completeness export process started" ); - DataSetCompletenessConfiguration config = getConfiguration(); + int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET, DEFAULT_COMPLETENESS_OFFSET ); completenessStore.deleteDataSetCompleteness( dataSetIds, periodIds, organisationUnitIds ); @@ -216,7 +190,7 @@ { if ( intersectingPeriod.getPeriodType().equals( dataSet.getPeriodType() ) ) { - deadline = config != null ? config.getDeadline( intersectingPeriod ) : null; + deadline = getDeadline( intersectingPeriod, days ); result = getDataSetCompleteness( intersectingPeriod, deadline, unit, dataSet ); @@ -245,7 +219,8 @@ { final Period period = periodService.getPeriod( periodId ); - Date deadline = getConfiguration() != null ? getConfiguration().getDeadline( period ) : null; + int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET, DEFAULT_COMPLETENESS_OFFSET ); + Date deadline = getDeadline( period, days ); final Collection children = organisationUnitService.getOrganisationUnitWithChildren( organisationUnitId ); @@ -280,7 +255,8 @@ { final Period period = periodService.getPeriod( periodId ); - Date deadline = getConfiguration() != null ? getConfiguration().getDeadline( period ) : null; + int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET, DEFAULT_COMPLETENESS_OFFSET ); + Date deadline = getDeadline( period, days ); final DataSet dataSet = dataSetService.getDataSet( dataSetId ); @@ -334,39 +310,7 @@ return result; } - - // ------------------------------------------------------------------------- - // Configuration - // ------------------------------------------------------------------------- - - public void setConfiguration( DataSetCompletenessConfiguration configuration ) - { - try - { - OutputStream out = locationManager.getOutputStream( configFile, configDir ); - - configurationManager.setConfiguration( configuration, out ); - } - catch ( LocationManagerException ex ) - { - throw new RuntimeException( "Failed to set configuration", ex ); - } - } - - public DataSetCompletenessConfiguration getConfiguration() - { - try - { - InputStream in = locationManager.getInputStream( configFile, configDir ); - - return configurationManager.getConfiguration( in, DataSetCompletenessConfiguration.class ); - } - catch ( LocationManagerException ex ) - { - return null; - } - } - + // ------------------------------------------------------------------------- // Index // ------------------------------------------------------------------------- @@ -380,4 +324,26 @@ { completenessStore.dropIndex(); } + + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- + + private Date getDeadline( Period period, int days ) + { + Calendar cal = Calendar.getInstance(); + + Date date = null; + + if ( period != null ) + { + cal.clear(); + cal.setTime( period.getEndDate() ); + cal.add( Calendar.DAY_OF_MONTH, days ); + + date = cal.getTime(); + } + + return date; + } } === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-02-17 16:39:32 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-02-18 20:20:07 +0000 @@ -141,8 +141,6 @@ - - @@ -154,8 +152,8 @@ ref="org.hisp.dhis.period.PeriodService"/> - - + $i18n.getString( "data_analysis_factor" )

- + +

+ +

$i18n.getString( "days_after_period_timeliness" )

+ +

+

=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessConfigurationAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessConfigurationAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessConfigurationAction.java 1970-01-01 00:00:00 +0000 @@ -1,97 +0,0 @@ -package org.hisp.dhis.reporting.completeness.action; - -/* - * 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.completeness.DataSetCompletenessConfiguration; -import org.hisp.dhis.completeness.DataSetCompletenessService; -import org.hisp.dhis.external.configuration.NoConfigurationFoundException; -import org.hisp.dhis.i18n.I18n; - -import com.opensymphony.xwork2.Action; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class GetDataCompletenessConfigurationAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private DataSetCompletenessService completenessService; - - public void setCompletenessService( DataSetCompletenessService completenessService ) - { - this.completenessService = completenessService; - } - - private I18n i18n; - - public void setI18n( I18n i18n ) - { - this.i18n = i18n; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private DataSetCompletenessConfiguration configuration; - - public DataSetCompletenessConfiguration getConfiguration() - { - return configuration; - } - - private String message; - - public String getMessage() - { - return message; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - { - try - { - configuration = completenessService.getConfiguration(); - } - catch ( NoConfigurationFoundException ex ) - { - message = i18n.getString( "set_configuration" ); - } - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/SetDataCompletenessConfigurationAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/SetDataCompletenessConfigurationAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/SetDataCompletenessConfigurationAction.java 1970-01-01 00:00:00 +0000 @@ -1,76 +0,0 @@ -package org.hisp.dhis.reporting.completeness.action; - -/* - * 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.completeness.DataSetCompletenessConfiguration; -import org.hisp.dhis.completeness.DataSetCompletenessService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class SetDataCompletenessConfigurationAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private DataSetCompletenessService completenessService; - - public void setCompletenessService( DataSetCompletenessService completenessService ) - { - this.completenessService = completenessService; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private int days; - - public void setDays( int days ) - { - this.days = days; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - { - DataSetCompletenessConfiguration config = new DataSetCompletenessConfiguration( days ); - - completenessService.setConfiguration( config ); - - return SUCCESS; - } -} === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-02-03 20:15:02 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-02-18 20:20:07 +0000 @@ -410,21 +410,7 @@
- - - - - - - - - + /dhis-web-commons/ajax/htmlGrid.vm - - - /main.vm - /dhis-web-reporting/configureDataCompletenessForm.vm - /dhis-web-reporting/menu.vm - - - - displayViewDataCompletenessForm.action - === removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/configureDataCompletenessForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/configureDataCompletenessForm.vm 2009-03-03 16:46:36 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/configureDataCompletenessForm.vm 1970-01-01 00:00:00 +0000 @@ -1,28 +0,0 @@ - -

$i18n.getString( "data_completeness_configuration" )

- -
- - - - - - - - - - - - - -
$i18n.getString( "reporting_deadline" )
- -
- -$i18n.getString( "completeness_configuration_explanation" ). - -#if ( $message ) - $!message -#end === removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/configureReportForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/configureReportForm.vm 2009-03-03 16:46:36 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/configureReportForm.vm 1970-01-01 00:00:00 +0000 @@ -1,32 +0,0 @@ - -

$i18n.getString( 'report_configuration' )

- -
- - - - - - - - - - - - - - - - - -
$i18n.getString( "details" )
- -
- -$i18n.getString( "home_explanation" ). $i18n.getString( "directory_explanation" ). - -#if ( $message ) - $!message -#end === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm 2010-12-26 23:25:10 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm 2011-02-18 20:20:07 +0000 @@ -16,8 +16,7 @@
- -

+