← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20914: Data value import. Fixed bug related to future periods check.

 

------------------------------------------------------------
revno: 20914
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-11-01 22:52:38 -0500
message:
  Data value import. Fixed bug related to future periods check.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java


--
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/dataelement/DataElementService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2015-10-20 07:16:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2015-11-02 03:52:38 +0000
@@ -112,6 +112,15 @@
     DataElement getDataElementByName( String name );
 
     /**
+     * Indicates whether this data element allows for data entry for future periods
+     * through its data set assignments.
+     * 
+     * @param id the data element id.
+     * @return true or false.
+     */
+    boolean isOpenFuturePeriods( int id );
+
+    /**
      * Returns List of DataElements with a given key.
      *
      * @param key the name of the DataElement to return.
@@ -127,7 +136,7 @@
      * @return the DataElement with the given short name, or null if no match.
      */
     DataElement getDataElementByShortName( String shortName );
-
+    
     /**
      * Returns all DataElements.
      *

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2015-10-20 07:16:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2015-11-02 03:52:38 +0000
@@ -131,6 +131,14 @@
     }
 
     @Override
+    public boolean isOpenFuturePeriods( int id )
+    {
+        DataElement dataElement = getDataElement( id );
+        
+        return dataElement != null && dataElement.getOpenFuturePeriods() >= 0;
+    }
+    
+    @Override
     public List<DataElement> getAllDataElements()
     {
         return i18n( i18nService, dataElementStore.getAll() );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2015-10-31 10:08:19 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2015-11-02 03:52:38 +0000
@@ -60,6 +60,7 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.CompleteDataSetRegistration;
 import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
 import org.hisp.dhis.dataset.DataSet;
@@ -112,6 +113,9 @@
 
     @Autowired
     private IdentifiableObjectManager identifiableObjectManager;
+    
+    @Autowired
+    private DataElementService dataElementService;
 
     @Autowired
     private DataElementCategoryService categoryService;
@@ -581,7 +585,7 @@
         CachingMap<String, Set<DataElementCategoryOptionCombo>> dataElementCategoryOptionComboMap = new CachingMap<>();
         CachingMap<String, Set<DataElementCategoryOptionCombo>> dataElementAttrOptionComboMap = new CachingMap<>();
         CachingMap<String, Boolean> dataElementOrgUnitMap = new CachingMap<>();
-        CachingMap<String, Integer> dataElementOpenFuturePeriodsMap = new CachingMap<>();
+        CachingMap<String, Boolean> dataElementOpenFuturePeriodsMap = new CachingMap<>();
         CachingMap<String, Boolean> orgUnitInHierarchyMap = new CachingMap<>();
 
         //----------------------------------------------------------------------
@@ -741,7 +745,7 @@
             }
             
             boolean invalidFuturePeriod = period.isFuture() && dataElementOpenFuturePeriodsMap.get( dataElement.getUid(),
-                () -> dataElement.getOpenFuturePeriods()  ) <= 0;
+                () -> dataElementService.isOpenFuturePeriods( dataElement.getId() ) );
             
             if ( invalidFuturePeriod )
             {