← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13237: Data entry, using uids for data set completion

 

------------------------------------------------------------
revno: 13237
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-12-15 23:20:57 +0100
message:
  Data entry, using uids for data set completion
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.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/dataset/DataSetService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java	2013-12-09 21:32:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java	2013-12-15 22:20:57 +0000
@@ -359,6 +359,18 @@
     /**
      * Checks whether the system is locked for data entry for the given input.
      *
+     * @param dataSet            the data set
+     * @param period             Period the period.s
+     * @param organisationUnit   the organisation unit.
+     * @param now                the base date for deciding locked date, current date if null.
+     * @param useOrgUnitChildren whether to check children of the given org unit or the org unit only.
+     * @return true or false indicating whether the system is locked or not.
+     */
+    boolean isLocked( DataSet dataSet, Period period, OrganisationUnit organisationUnit, Date now, boolean useOrgUnitChildren );
+
+    /**
+     * Checks whether the system is locked for data entry for the given input.
+     *
      * @param dataElement      the data element.
      * @param period           the period.
      * @param organisationUnit the organisation unit.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2013-12-09 21:32:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2013-12-15 22:20:57 +0000
@@ -469,6 +469,30 @@
     }
 
     @Override
+    public boolean isLocked( DataSet dataSet, Period period, OrganisationUnit organisationUnit, Date now, boolean useOrgUnitChildren )
+    {
+        if ( !useOrgUnitChildren )
+        {
+            return isLocked( dataSet, period, organisationUnit, now );
+        }
+        
+        if ( organisationUnit == null || !organisationUnit.hasChild() )
+        {
+            return false;
+        }
+        
+        for ( OrganisationUnit child : organisationUnit.getChildren() )
+        {
+            if ( isLocked( dataSet, period, child, now ) )
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+
+    @Override
     public void mergeWithCurrentUserOrganisationUnits( DataSet dataSet, Collection<OrganisationUnit> mergeOrganisationUnits )
     {
         Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>( dataSet.getSources() );

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java	2013-09-27 12:55:38 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java	2013-12-15 22:20:57 +0000
@@ -103,16 +103,16 @@
         this.periodId = periodId;
     }
 
-    private Integer dataSetId;
+    private String dataSetId;
 
-    public void setDataSetId( Integer dataSetId )
+    public void setDataSetId( String dataSetId )
     {
         this.dataSetId = dataSetId;
     }
 
-    private Integer organisationUnitId;
+    private String organisationUnitId;
 
-    public void setOrganisationUnitId( Integer organisationUnitId )
+    public void setOrganisationUnitId( String organisationUnitId )
     {
         this.organisationUnitId = organisationUnitId;
     }
@@ -148,22 +148,9 @@
         // Check locked status
         // ---------------------------------------------------------------------
 
-        if ( !multiOrganisationUnit )
-        {
-            if ( dataSetService.isLocked( dataSet, period, organisationUnit, null ) )
-            {
-                return logError( "Entry locked for combination: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
-            }
-        }
-        else
-        {
-            for ( OrganisationUnit ou : children )
-            {
-                if ( ou.getDataSets().contains( dataSet ) && dataSetService.isLocked( dataSet, period, ou, null ) )
-                {
-                    return logError( "Entry locked for combination: " + dataSet + ", " + period + ", " + ou, 2 );
-                }
-            }
+        if ( dataSetService.isLocked( dataSet, period, organisationUnit, null, multiOrganisationUnit ) )
+        {
+            return logError( "Entry locked: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
         }
 
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java	2013-09-27 12:55:38 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/UndoCompleteDataSetAction.java	2013-12-15 22:20:57 +0000
@@ -86,16 +86,16 @@
         this.periodId = periodId;
     }
 
-    private Integer dataSetId;
+    private String dataSetId;
 
-    public void setDataSetId( Integer dataSetId )
+    public void setDataSetId( String dataSetId )
     {
         this.dataSetId = dataSetId;
     }
 
-    private Integer organisationUnitId;
+    private String organisationUnitId;
 
-    public void setOrganisationUnitId( Integer organisationUnitId )
+    public void setOrganisationUnitId( String organisationUnitId )
     {
         this.organisationUnitId = organisationUnitId;
     }
@@ -129,29 +129,15 @@
         // Check locked status
         // ---------------------------------------------------------------------
 
-        if ( !multiOrganisationUnit )
-        {
-            if ( dataSetService.isLocked( dataSet, period, organisationUnit, null ) )
-            {
-                return logError( "Entry locked for combination: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
-            }
-        }
-        else
-        {
-            for ( OrganisationUnit ou : children )
-            {
-                if ( ou.getDataSets().contains( dataSet ) && dataSetService.isLocked( dataSet, period, ou, null ) )
-                {
-                    return logError( "Entry locked for combination: " + dataSet + ", " + period + ", " + ou, 2 );
-                }
-            }
+        if ( dataSetService.isLocked( dataSet, period, organisationUnit, null, multiOrganisationUnit ) )
+        {
+            return logError( "Entry locked: " + dataSet + ", " + period + ", " + organisationUnit, 2 );
         }
 
         // ---------------------------------------------------------------------
         // Un-register as completed dataSet
         // ---------------------------------------------------------------------
 
-
         if ( !multiOrganisationUnit )
         {
             deregisterCompleteDataSet( dataSet, period, organisationUnit );