← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19933: Data import. Enforcing future periods constraints of data element through data set

 

------------------------------------------------------------
revno: 19933
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-09-02 12:26:26 +0200
message:
  Data import. Enforcing future periods constraints of data element through data set
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.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/period/Period.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java	2015-07-04 17:06:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java	2015-09-02 10:26:26 +0000
@@ -270,8 +270,9 @@
     }
 
     /**
-     * Determines whether this is a future period in relation to the current time.
-     * @return true if this period ends in the future, false otherwise (the period has ended).
+     * Determines whether this is a future period relative to the current time.
+     * 
+     * @return true if this period ends in the future, false otherwise.
      */
     public boolean isFuture()
     {

=== 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-08-31 08:57:11 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2015-09-02 10:26:26 +0000
@@ -748,7 +748,15 @@
             
             if ( !inUserHierarchy )
             {
-                summary.getConflicts().add( new ImportConflict( dataValue.getOrgUnit(), "Organisation unit not in hierarchy of current user: " + currentUser ) );
+                summary.getConflicts().add( new ImportConflict( orgUnit.getUid(), "Organisation unit not in hierarchy of current user: " + currentUser ) );
+                continue;
+            }
+            
+            boolean invalidFuturePeriod = period.isFuture() && dataElement.getOpenFuturePeriods() <= 0;
+            
+            if ( invalidFuturePeriod )
+            {
+                summary.getConflicts().add( new ImportConflict( period.getIsoDate(), "Data element does not allow for future periods through data sets: " + dataElement.getUid() ) );
                 continue;
             }