← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12313: implement support for pr dataset timeliness, removed old support for system timeliness

 

------------------------------------------------------------
revno: 12313
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-09-30 12:39:35 +0200
message:
  implement support for pr dataset timeliness, removed old support for system timeliness
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/engine/DefaultDataSetCompletenessEngine.java
  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/CompulsoryDataSetCompletenessService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/RegistrationDataSetCompletenessService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java	2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessService.java	2013-09-30 10:39:35 +0000
@@ -45,7 +45,7 @@
     String ID = DataSetCompletenessService.class.getName();
 
     Future<?> exportDataSetCompleteness( Collection<DataSet> dataSets, Collection<Period> periods,
-        Collection<OrganisationUnit> units, int days );
+        Collection<OrganisationUnit> units );
 
     /**
      * Returns a Collection of DataSetCompletenessResults. The

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2013-09-30 10:39:35 +0000
@@ -145,6 +145,11 @@
     private int expiryDays;
 
     /**
+     * Days after period end to qualify for timely data submission
+     */
+    private int timelyDays;
+
+    /**
      * Indicating whether aggregation should be skipped.
      */
     private boolean skipAggregation;
@@ -604,6 +609,19 @@
     @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public int getTimelyDays()
+    {
+        return timelyDays;
+    }
+
+    public void setTimelyDays( int timelyDays )
+    {
+        this.timelyDays = timelyDays;
+    }
+
+    @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public boolean isSkipAggregation()
     {
         return skipAggregation;
@@ -729,8 +747,8 @@
     public void setDataElementDecoration( boolean dataElementDecoration )
     {
         this.dataElementDecoration = dataElementDecoration;
-    }    
-	
+    }
+
     @Override
     public void mergeWith( IdentifiableObject other )
     {
@@ -755,7 +773,7 @@
             renderHorizontally = dataSet.isRenderHorizontally();
 
             dataElementDecoration = dataSet.isDataElementDecoration();
- 
+
             removeAllDataElements();
 
             for ( DataElement dataElement : dataSet.getDataElements() )

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2013-09-18 12:45:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2013-09-30 10:39:35 +0000
@@ -57,7 +57,6 @@
     final String KEY_REPORT_TEMPLATE_DIRECTORY = "reportTemplateDirectory";
     final String KEY_GOOGLE_MAPS_API_KEY = "googleMapsAPIKey";
     final String KEY_FACTOR_OF_DEVIATION = "factorDeviation";
-    final String KEY_COMPLETENESS_OFFSET = "completenessOffset";
     final String KEY_PATIENT_EXCEL_TEMPLATE_FILE_NAME = "patientExcelTemplateFileName";
     final String KEY_DATAMART_TASK = "keyDataMartTask";
     final String KEY_DATASETCOMPLETENESS_TASK = "keyDataSetCompletenessTask";

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2013-09-19 14:08:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2013-09-30 10:39:35 +0000
@@ -408,6 +408,10 @@
         executeSql( "update dataset set expirydays = 0 where expirydays is null" );
         executeSql( "update expression set nullifblank = true where nullifblank is null" );
 
+        // move timelydays from system setting => dataset property
+        executeSql( "update dataset set timelydays = 15 where timelydays is null" );
+        executeSql( "delete from systemsetting where name='completenessOffset'" );
+
         executeSql( "update reporttable set reportingmonth = false where reportingmonth is null" );
         executeSql( "update reporttable set reportingbimonth = false where reportingbimonth is null" );
         executeSql( "update reporttable set reportingquarter = false where reportingquarter is null" );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml	2013-08-29 18:09:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml	2013-09-30 10:39:35 +0000
@@ -72,6 +72,8 @@
 
     <property name="expiryDays" />
 
+    <property name="timelyDays" />
+
     <property name="skipAggregation" />
 
     <many-to-one name="notificationRecipients" class="org.hisp.dhis.user.UserGroup"

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/engine/DefaultDataSetCompletenessEngine.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/engine/DefaultDataSetCompletenessEngine.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/engine/DefaultDataSetCompletenessEngine.java	2013-09-30 10:39:35 +0000
@@ -28,15 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_COMPLETENESS_OFFSET;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_COMPLETENESS_OFFSET;
-import static org.hisp.dhis.system.notification.NotificationLevel.INFO;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.Future;
-
 import org.hisp.dhis.completeness.DataSetCompletenessEngine;
 import org.hisp.dhis.completeness.DataSetCompletenessService;
 import org.hisp.dhis.completeness.DataSetCompletenessStore;
@@ -58,6 +49,13 @@
 import org.hisp.dhis.system.util.SystemUtils;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Future;
+
+import static org.hisp.dhis.system.notification.NotificationLevel.INFO;
+
 /**
  * @author Lars Helge Overland
  */
@@ -69,7 +67,7 @@
     // -------------------------------------------------------------------------
 
     private DataSetCompletenessService completenessService;
-    
+
     public void setCompletenessService( DataSetCompletenessService completenessService )
     {
         this.completenessService = completenessService;
@@ -126,16 +124,16 @@
     {
         Collection<Integer> dataSetIds = ConversionUtils.getIdentifiers( DataSet.class, dataSetService.getAllDataSets() );
         Collection<Integer> organisationUnitIds = ConversionUtils.getIdentifiers( OrganisationUnit.class, organisationUnitService.getAllOrganisationUnits() );
-        
+
         exportDataSetCompleteness( dataSetIds, periodIds, organisationUnitIds, id );
     }
-    
+
     @Transactional
     public void exportDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds,
         Collection<Integer> organisationUnitIds, TaskId id )
     {
         final int cpuCores = SystemUtils.getCpuCores();
-        
+
         Clock clock = new Clock().startClock().logTime( "Data completeness export process started, number of CPU cores: " + cpuCores + ", " + SystemUtils.getMemoryString() );
         notifier.notify( id, "Completeness export process started" );
 
@@ -143,9 +141,6 @@
 
         clock.logTime( "Dropped potential index" );
 
-        int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET,
-            DEFAULT_COMPLETENESS_OFFSET );
-
         completenessStore.deleteDataSetCompleteness( dataSetIds, periodIds, organisationUnitIds );
 
         clock.logTime( "Deleted existing completeness data" );
@@ -158,18 +153,18 @@
         dataSets = completenessStore.getDataSetsWithRegistrations( dataSets );
 
         FilterUtils.filter( dataSets, new DataSetWithOrganisationUnitsFilter() );
-        
+
         List<List<OrganisationUnit>> organisationUnitPages = new PaginatedList<OrganisationUnit>( organisationUnits ).setNumberOfPages( cpuCores ).getPages();
-        
+
         List<Future<?>> futures = new ArrayList<Future<?>>();
-        
+
         for ( List<OrganisationUnit> organisationUnitPage : organisationUnitPages )
         {
-            futures.add( completenessService.exportDataSetCompleteness( dataSets, periods, organisationUnitPage, days ) );
+            futures.add( completenessService.exportDataSetCompleteness( dataSets, periods, organisationUnitPage ) );
         }
-        
+
         ConcurrentUtils.waitForCompletion( futures );
-        
+
         completenessStore.createIndex();
 
         clock.logTime( "Created index" );

=== 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	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/AbstractDataSetCompletenessService.java	2013-09-30 10:39:35 +0000
@@ -28,16 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_COMPLETENESS_OFFSET;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_COMPLETENESS_OFFSET;
-import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Future;
-
 import org.amplecode.quick.BatchHandler;
 import org.amplecode.quick.BatchHandlerFactory;
 import org.apache.commons.collections.CollectionUtils;
@@ -62,9 +52,16 @@
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.Future;
+
+import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
+
 /**
  * @author Lars Helge Overland
- * @version $Id$
  */
 public abstract class AbstractDataSetCompletenessService
     implements DataSetCompletenessService
@@ -95,7 +92,7 @@
     {
         this.organisationUnitService = organisationUnitService;
     }
-    
+
     private OrganisationUnitGroupService organisationUnitGroupService;
 
     public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
@@ -130,7 +127,7 @@
     {
         this.systemSettingManager = systemSettingManager;
     }
-    
+
     // -------------------------------------------------------------------------
     // DataSetCompletenessService implementation
     // -------------------------------------------------------------------------
@@ -141,8 +138,7 @@
 
     protected abstract int getRegistrations( DataSet dataSet, Collection<Integer> relevantSources, Collection<Integer> periods );
 
-    protected abstract int getRegistrationsOnTime( DataSet dataSet, Collection<Integer> relevantSources, Collection<Integer> periods,
-        int completenessOffset );
+    protected abstract int getRegistrationsOnTime( DataSet dataSet, Collection<Integer> relevantSources, Collection<Integer> periods );
 
     protected abstract int getSources( DataSet dataSet, Collection<Integer> relevantSources, Period period );
 
@@ -152,18 +148,18 @@
 
     @Async
     public Future<?> exportDataSetCompleteness( Collection<DataSet> dataSets, Collection<Period> periods,
-        Collection<OrganisationUnit> units, int days )
-    {        
+        Collection<OrganisationUnit> units )
+    {
         BatchHandler<DataSetCompletenessResult> batchHandler = batchHandlerFactory
             .createBatchHandler( DataSetCompletenessResultBatchHandler.class ).init();
 
         OrganisationUnitHierarchy hierarchy = organisationUnitService.getOrganisationUnitHierarchy();
         hierarchy.prepareChildren( units );
-        
+
         for ( final DataSet dataSet : dataSets )
         {
             int dataSetFrequencyOrder = dataSet.getPeriodType().getFrequencyOrder();
-                
+
             for ( final OrganisationUnit unit : units )
             {
                 Collection<Integer> sources = hierarchy.getChildren( unit.getId() );
@@ -174,11 +170,10 @@
                 {
                     if ( period.getPeriodType() != null && period.getPeriodType().getFrequencyOrder() >= dataSetFrequencyOrder )
                     {
-                        final Collection<Integer> periodsBetweenDates = 
+                        final Collection<Integer> periodsBetweenDates =
                             aggregationCache.getPeriodsBetweenDatesPeriodType( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() );
-                        
-                        final DataSetCompletenessResult result = getDataSetCompleteness( period, 
-                            periodsBetweenDates, days, unit, relevantSources, dataSet );
+
+                        final DataSetCompletenessResult result = getDataSetCompleteness( period, periodsBetweenDates, unit, relevantSources, dataSet );
 
                         if ( result.getSources() > 0 )
                         {
@@ -192,20 +187,17 @@
         batchHandler.flush();
 
         aggregationCache.clearCache();
-        
+
         log.info( "Completeness export task done" );
-        
+
         return null;
     }
-    
+
     @Transactional
     public Collection<DataSetCompletenessResult> getDataSetCompleteness( int periodId, int organisationUnitId, Set<Integer> groupIds )
     {
         final Period period = periodService.getPeriod( periodId );
 
-        int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET,
-            DEFAULT_COMPLETENESS_OFFSET );
-
         final Collection<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren(
             organisationUnitId );
 
@@ -215,7 +207,7 @@
 
         for ( final DataSet dataSet : dataSets )
         {
-            final Collection<Integer> periodsBetweenDates = getIdentifiers( Period.class, 
+            final Collection<Integer> periodsBetweenDates = getIdentifiers( Period.class,
                 periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() ) );
 
             final Collection<Integer> relevantSources = getRelevantSources( dataSet, children, groupIds );
@@ -228,7 +220,7 @@
             {
                 result.setName( dataSet.getName() );
                 result.setRegistrations( getRegistrations( dataSet, relevantSources, periodsBetweenDates ) );
-                result.setRegistrationsOnTime( getRegistrationsOnTime( dataSet, relevantSources, periodsBetweenDates, days ) );
+                result.setRegistrationsOnTime( getRegistrationsOnTime( dataSet, relevantSources, periodsBetweenDates ) );
 
                 result.setDataSetId( dataSet.getId() );
                 result.setPeriodId( periodId );
@@ -248,12 +240,9 @@
         final DataSet dataSet = dataSetService.getDataSet( dataSetId );
 
         final Period period = periodService.getPeriod( periodId );
-        
+
         final Collection<Integer> periodsBetweenDates = getIdentifiers( Period.class, periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() ) );
 
-        int days = (Integer) systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET,
-            DEFAULT_COMPLETENESS_OFFSET );
-
         final Collection<DataSetCompletenessResult> results = new ArrayList<DataSetCompletenessResult>();
 
         for ( final Integer unitId : organisationUnitIds )
@@ -265,7 +254,7 @@
 
             final Collection<Integer> relevantSources = getRelevantSources( dataSet, children, groupIds );
 
-            final DataSetCompletenessResult result = getDataSetCompleteness( period, periodsBetweenDates, days, unit, relevantSources, dataSet );
+            final DataSetCompletenessResult result = getDataSetCompleteness( period, periodsBetweenDates, unit, relevantSources, dataSet );
 
             if ( result.getSources() > 0 )
             {
@@ -302,7 +291,7 @@
     // Supportive methods
     // -------------------------------------------------------------------------
 
-    private DataSetCompletenessResult getDataSetCompleteness( Period period, Collection<Integer> periodsBetweenDates, int completenessOffset, OrganisationUnit unit,
+    private DataSetCompletenessResult getDataSetCompleteness( Period period, Collection<Integer> periodsBetweenDates, OrganisationUnit unit,
         Collection<Integer> relevantSources, DataSet dataSet )
     {
         final DataSetCompletenessResult result = new DataSetCompletenessResult();
@@ -313,7 +302,7 @@
         if ( result.getSources() > 0 )
         {
             result.setRegistrations( getRegistrations( dataSet, relevantSources, periodsBetweenDates ) );
-            result.setRegistrationsOnTime( getRegistrationsOnTime( dataSet, relevantSources, periodsBetweenDates, completenessOffset ) );
+            result.setRegistrationsOnTime( getRegistrationsOnTime( dataSet, relevantSources, periodsBetweenDates ) );
 
             result.setDataSetId( dataSet.getId() );
             result.setPeriodId( period.getId() );
@@ -324,7 +313,7 @@
         return result;
     }
 
-    @SuppressWarnings( "unchecked" )
+    @SuppressWarnings("unchecked")
     private Collection<Integer> getRelevantSources( DataSet dataSet, Collection<Integer> sources, Set<Integer> groupIds )
     {
         Collection<Integer> dataSetSources = ConversionUtils.getIdentifiers( OrganisationUnit.class,
@@ -339,7 +328,7 @@
                 dataSetSources.retainAll( ids );
             }
         }
-        
+
         return CollectionUtils.intersection( dataSetSources, sources );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/CompulsoryDataSetCompletenessService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/CompulsoryDataSetCompletenessService.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/CompulsoryDataSetCompletenessService.java	2013-09-30 10:39:35 +0000
@@ -46,9 +46,9 @@
     }
 
     @Override
-    public int getRegistrationsOnTime( DataSet dataSet, Collection<Integer> relevantSources, Collection<Integer> periods, int completenessOffset )
+    public int getRegistrationsOnTime( DataSet dataSet, Collection<Integer> relevantSources, Collection<Integer> periods )
     {
-        return completenessStore.getCompulsoryDataElementRegistrations( dataSet, relevantSources, periods, completenessOffset );
+        return completenessStore.getCompulsoryDataElementRegistrations( dataSet, relevantSources, periods );
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/RegistrationDataSetCompletenessService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/RegistrationDataSetCompletenessService.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/impl/RegistrationDataSetCompletenessService.java	2013-09-30 10:39:35 +0000
@@ -28,11 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.period.Period;
 
+import java.util.Collection;
+
 /**
  * @author Lars Helge Overland
  */
@@ -46,9 +46,9 @@
     }
 
     @Override
-    public int getRegistrationsOnTime( DataSet dataSet, Collection<Integer> relevantSources, Collection<Integer> periods, int completenessOffset )
+    public int getRegistrationsOnTime( DataSet dataSet, Collection<Integer> relevantSources, Collection<Integer> periods )
     {
-        return completenessStore.getCompleteDataSetRegistrations( dataSet, periods, relevantSources, completenessOffset );
+        return completenessStore.getCompleteDataSetRegistrations( dataSet, periods, relevantSources );
     }
 
     @Override

=== 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	2013-09-16 11:22:02 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2013-09-30 10:39:35 +0000
@@ -52,7 +52,7 @@
     <property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-	<property name="analyticsService" ref="org.hisp.dhis.analytics.AnalyticsService" />
+    <property name="analyticsService" ref="org.hisp.dhis.analytics.AnalyticsService" />
   </bean>
 
   <!-- Document -->
@@ -78,19 +78,20 @@
     </property>
   </bean>
 
-  <bean id="org.hisp.dhis.completeness.DataSetCompletenessEngine" class="org.hisp.dhis.completeness.engine.DefaultDataSetCompletenessEngine">
-	<property name="completenessService" ref="registrationDataCompletenessService"/>
+  <bean id="org.hisp.dhis.completeness.DataSetCompletenessEngine"
+    class="org.hisp.dhis.completeness.engine.DefaultDataSetCompletenessEngine">
+    <property name="completenessService" ref="registrationDataCompletenessService" />
     <property name="completenessStore" ref="org.hisp.dhis.completeness.DataSetCompletenessStore" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
     <property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
-	<property name="notifier" ref="notifier" />
+    <property name="notifier" ref="notifier" />
   </bean>
 
   <bean id="compulsoryDataCompletenessService" class="org.hisp.dhis.completeness.impl.CompulsoryDataSetCompletenessService">
     <property name="batchHandlerFactory" ref="batchHandlerFactory" />
-	<property name="aggregationCache" ref="org.hisp.dhis.datamart.aggregation.cache.AggregationCache" />
+    <property name="aggregationCache" ref="org.hisp.dhis.datamart.aggregation.cache.AggregationCache" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
@@ -105,20 +106,20 @@
 
   <bean id="org.hisp.dhis.completeness.DataSetCompletenessStore" class="org.hisp.dhis.completeness.jdbc.JDBCDataSetCompletenessStore">
     <property name="statementManager" ref="statementManager" />
-	<property name="statementBuilder" ref="statementBuilder" />
+    <property name="statementBuilder" ref="statementBuilder" />
   </bean>
 
   <!-- DataSetReport -->
 
   <bean id="org.hisp.dhis.datasetreport.DataSetReportService" class="org.hisp.dhis.datasetreport.impl.DefaultDataSetReportService">
     <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
-	<property name="dataSetReportStore" ref="org.hisp.dhis.datasetreport.DataSetReportStore" />
+    <property name="dataSetReportStore" ref="org.hisp.dhis.datasetreport.DataSetReportStore" />
   </bean>
-  
+
   <bean id="org.hisp.dhis.datasetreport.DataSetReportStore" class="org.hisp.dhis.datasetreport.jdbc.AnalyticsDataSetReportStore">
     <property name="analyticsService" ref="org.hisp.dhis.analytics.AnalyticsService" />
   </bean>
-  
+
   <!-- Dashboard -->
 
   <bean id="org.hisp.dhis.dashboard.DashboardStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
@@ -133,22 +134,23 @@
 
   <!-- Organisation Unit Distribution -->
 
-  <bean id="org.hisp.dhis.orgunitdistribution.OrgUnitDistributionService" class="org.hisp.dhis.orgunitdistribution.impl.DefaultOrgUnitDistributionService">
+  <bean id="org.hisp.dhis.orgunitdistribution.OrgUnitDistributionService"
+    class="org.hisp.dhis.orgunitdistribution.impl.DefaultOrgUnitDistributionService">
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="chartService" ref="org.hisp.dhis.chart.ChartService" />
   </bean>
-  
+
   <!-- Interpretation -->
-  
+
   <bean id="org.hisp.dhis.interpretation.InterpretationService" class="org.hisp.dhis.interpretation.impl.DefaultInterpretationService">
-	<property name="interpretationStore" ref="org.hisp.dhis.interpretation.InterpretationStore" />
-	<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
-	<property name="userService" ref="org.hisp.dhis.user.UserService" />
-	<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+    <property name="interpretationStore" ref="org.hisp.dhis.interpretation.InterpretationStore" />
+    <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+    <property name="userService" ref="org.hisp.dhis.user.UserService" />
+    <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
   </bean>
 
   <bean id="org.hisp.dhis.interpretation.InterpretationStore" class="org.hisp.dhis.interpretation.hibernate.HibernateInterpretationStore">
-	<property name="clazz" value="org.hisp.dhis.interpretation.Interpretation" />
+    <property name="clazz" value="org.hisp.dhis.interpretation.Interpretation" />
     <property name="sessionFactory" ref="sessionFactory" />
   </bean>
 
@@ -162,10 +164,10 @@
       <map>
         <entry key="resourceTableTask" value-ref="resourceTableTask" />
         <entry key="dataMartLast12MonthsTask" value-ref="dataMartLast12MonthsTask" />
-		<entry key="dataMartLast6MonthsTask" value-ref="dataMartLast6MonthsTask" />
-		<entry key="dataMartFrom6To12MonthsTask" value-ref="dataMartFrom6To12MonthsTask" />
-		<entry key="analyticsAllTask" value-ref="analyticsAllTask" />
-		<entry key="analyticsLast3YearsTask" value-ref="analyticsLast3YearsTask" />
+        <entry key="dataMartLast6MonthsTask" value-ref="dataMartLast6MonthsTask" />
+        <entry key="dataMartFrom6To12MonthsTask" value-ref="dataMartFrom6To12MonthsTask" />
+        <entry key="analyticsAllTask" value-ref="analyticsAllTask" />
+        <entry key="analyticsLast3YearsTask" value-ref="analyticsLast3YearsTask" />
       </map>
     </property>
   </bean>
@@ -173,18 +175,18 @@
   <!-- Scheduled tasks -->
 
   <bean id="dataMartLast12MonthsTask" class="org.hisp.dhis.scheduling.DataMartTask">
-    <property name="last6Months" value="true"/>
-    <property name="last6To12Months" value="true"/>
+    <property name="last6Months" value="true" />
+    <property name="last6To12Months" value="true" />
   </bean>
-    
+
   <bean id="dataMartLast6MonthsTask" class="org.hisp.dhis.scheduling.DataMartTask">
-    <property name="last6Months" value="true"/>
+    <property name="last6Months" value="true" />
   </bean>
-  
+
   <bean id="dataMartFrom6To12MonthsTask" class="org.hisp.dhis.scheduling.DataMartTask">
-    <property name="last6To12Months" value="true"/>
-  </bean>      
-      
+    <property name="last6To12Months" value="true" />
+  </bean>
+
   <!-- DeletionHandler -->
 
   <bean id="org.hisp.dhis.report.ReportDeletionHandler" class="org.hisp.dhis.report.ReportDeletionHandler">
@@ -199,7 +201,8 @@
     <property name="chartService" ref="org.hisp.dhis.chart.ChartService" />
   </bean>
 
-  <bean id="org.hisp.dhis.interpretation.InterpretationDeletionHandler" class="org.hisp.dhis.interpretation.InterpretationDeletionHandler" />
+  <bean id="org.hisp.dhis.interpretation.InterpretationDeletionHandler"
+    class="org.hisp.dhis.interpretation.InterpretationDeletionHandler" />
 
   <!-- DeletionManager -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2013-09-26 18:17:41 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2013-09-30 10:39:35 +0000
@@ -93,7 +93,6 @@
         map.put( KEY_START_MODULE, systemSettingManager.getSystemSetting( KEY_START_MODULE, DEFAULT_START_MODULE ) );
         map.put( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, systemSettingManager.getSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, false ) );
         map.put( KEY_FACTOR_OF_DEVIATION, systemSettingManager.getSystemSetting( KEY_FACTOR_OF_DEVIATION, DEFAULT_FACTOR_OF_DEVIATION ) );
-        map.put( KEY_COMPLETENESS_OFFSET, systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET, DEFAULT_COMPLETENESS_OFFSET ) );
         map.put( KEY_PHONE_NUMBER_AREA_CODE, systemSettingManager.getSystemSetting( KEY_PHONE_NUMBER_AREA_CODE, "" ) );
         map.put( KEY_MULTI_ORGANISATION_UNIT_FORMS, systemSettingManager.getSystemSetting( KEY_MULTI_ORGANISATION_UNIT_FORMS, false ) );
         map.put( KEY_ACCOUNT_RECOVERY, systemSettingManager.getSystemSetting( KEY_ACCOUNT_RECOVERY, false ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java	2013-09-30 10:39:35 +0000
@@ -129,6 +129,13 @@
         this.expiryDays = expiryDays;
     }
 
+    private int timelyDays;
+
+    public void setTimelyDays( int timelyDays )
+    {
+        this.timelyDays = timelyDays;
+    }
+
     private int notificationRecipients;
 
     public void setNotificationRecipients( int notificationRecipients )
@@ -240,6 +247,7 @@
         DataSet dataSet = new DataSet( name, shortName, code, periodType );
 
         dataSet.setExpiryDays( expiryDays );
+        dataSet.setTimelyDays( timelyDays );
         dataSet.setSkipAggregation( skipAggregation );
 
         for ( String id : dataElementsSelectedList )
@@ -264,7 +272,7 @@
         dataSet.setValidCompleteOnly( validCompleteOnly );
         dataSet.setNotifyCompletingUser( notifyCompletingUser );
         dataSet.setSkipOffline( skipOffline );
-        dataSet.setDataElementDecoration( dataElementDecoration );		
+        dataSet.setDataElementDecoration( dataElementDecoration );
         dataSet.setRenderAsTabs( renderAsTabs );
         dataSet.setRenderHorizontally( renderHorizontally );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java	2013-08-25 21:06:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java	2013-09-30 10:39:35 +0000
@@ -140,6 +140,13 @@
         this.expiryDays = expiryDays;
     }
 
+    private int timelyDays;
+
+    public void setTimelyDays( int timelyDays )
+    {
+        this.timelyDays = timelyDays;
+    }
+
     private int notificationRecipients;
 
     public void setNotificationRecipients( int notificationRecipients )
@@ -272,6 +279,7 @@
         DataSet dataSet = dataSetService.getDataSet( dataSetId );
 
         dataSet.setExpiryDays( expiryDays );
+        dataSet.setTimelyDays( timelyDays );
         dataSet.setSkipAggregation( skipAggregation );
 
         if ( !( equalsNullSafe( name, dataSet.getName() ) && 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2013-08-14 11:04:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2013-09-30 10:39:35 +0000
@@ -82,6 +82,7 @@
 grey_field=Grey field
 totals=Totals
 expiry_days=Expiry Days
+timely_days=Days after period end to qualify for timely data submission
 insert_data_elements_totals_indicators=Insert data elements, totals and indicators
 style=Style
 comfortable=Comfortable

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2013-08-25 20:18:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2013-09-30 10:39:35 +0000
@@ -82,6 +82,10 @@
         <td><input type="text" id="expiryDays" name="expiryDays" value="0"></td>
       </tr>
       <tr>
+        <td><label>$i18n.getString( "timely_days" )</label></td>
+        <td><input type="text" id="timelyDays" name="timelyDays" value="0"></td>
+      </tr>
+      <tr>
         <td><label>$i18n.getString( "frequency" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
         <td>
           <select id="frequencySelect" name="frequencySelect">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2013-08-25 20:18:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2013-09-30 10:39:35 +0000
@@ -82,6 +82,10 @@
         <td><input type="text" id="expiryDays" name="expiryDays" value="$!encoder.htmlEncode( $dataSet.expiryDays )"/></td>
       </tr>
       <tr>
+        <td><label>$i18n.getString( "timely_days" )</label></td>
+        <td><input type="text" id="timelyDays" name="timelyDays" value="$!encoder.htmlEncode( $dataSet.timelyDays )"/></td>
+      </tr>
+      <tr>
         <td><label>$i18n.getString( "frequency" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
         <td>
           <select id="frequencySelect" name="frequencySelect">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java	2013-09-14 18:27:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java	2013-09-30 10:39:35 +0000
@@ -147,13 +147,6 @@
         this.offlineOrganisationUnitLevel = offlineOrganisationUnitLevel;
     }
 
-    private Integer completenessOffset;
-
-    public void setCompletenessOffset( Integer completenessOffset )
-    {
-        this.completenessOffset = completenessOffset;
-    }
-
     private String phoneNumberAreaCode;
     
     public void setPhoneNumberAreaCode( String phoneNumberAreaCode )
@@ -191,7 +184,6 @@
         systemSettingManager.saveSystemSetting( KEY_CACHE_STRATEGY, cacheStrategy );
         systemSettingManager.saveSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, omitIndicatorsZeroNumeratorDataMart );
         systemSettingManager.saveSystemSetting( KEY_FACTOR_OF_DEVIATION, factorDeviation );
-        systemSettingManager.saveSystemSetting( KEY_COMPLETENESS_OFFSET, completenessOffset );
         systemSettingManager.saveSystemSetting( KEY_PHONE_NUMBER_AREA_CODE, phoneNumberAreaCode );
         systemSettingManager.saveSystemSetting( KEY_MULTI_ORGANISATION_UNIT_FORMS, multiOrganisationUnitForms );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm	2013-04-25 09:07:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm	2013-09-30 10:39:35 +0000
@@ -9,7 +9,6 @@
                 offlineOrganisationUnitLevel: getFieldValue( 'offlineOrganisationUnitLevel' ),
 				omitIndicatorsZeroNumeratorDataMart: jQuery( '#omitIndicatorsZeroNumeratorDataMart' ).is( ':checked' ),
 				factorDeviation: getFieldValue( 'factorDeviation' ),
-				completenessOffset: getFieldValue( 'completenessOffset' ),
 				phoneNumberAreaCode: getFieldValue( 'phoneNumberAreaCode' ),
                 multiOrganisationUnitForms: jQuery( '#multiOrganisationUnitForms' ).is( ':checked' )
 			}, function( json ) {
@@ -82,12 +81,6 @@
 	<input type="text" id="factorDeviation" name="factorDeviation" value="$!factorDeviation"/>	
 </div>
 
-<div class="settingLabel">$i18n.getString( "days_after_period_timeliness" )</div>
-
-<div class="setting">
-    <input type="text" id="completenessOffset" name="completenessOffset" value="$!completenessOffset"/>
-</div>
-
 <div class="settingLabel">$i18n.getString( "phone_number_area_code" )</div>
 
 <div class="setting">