← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2326: DataSet Locking - Added more two selectable options "Selected" and "Child Tree"

 

------------------------------------------------------------
revno: 2326
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-10-07 04:15:55 +0700
message:
  DataSet Locking - Added more two selectable options "Selected" and "Child Tree"
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lock/CollectiveDataLockingAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/collectiveDataLockingForm.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-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lock/CollectiveDataLockingAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lock/CollectiveDataLockingAction.java	2010-10-05 10:04:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lock/CollectiveDataLockingAction.java	2010-10-06 21:15:55 +0000
@@ -53,6 +53,11 @@
 public class CollectiveDataLockingAction
     implements Action
 {
+
+    private static final String SELECTED = "selected";
+
+    private static final String CHILDTREE = "childtree";
+
     Collection<Period> periods = new ArrayList<Period>();
 
     Collection<DataSet> dataSets = new ArrayList<DataSet>();
@@ -139,6 +144,13 @@
         this.selectBetweenLockUnlock = selectBetweenLockUnlock;
     }
 
+    private String selectionValue = new String();
+
+    public void setSelectionValue( String selectionValue )
+    {
+        this.selectionValue = selectionValue;
+    }
+
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
@@ -171,22 +183,46 @@
         Set<Source> selectedSources = new HashSet<Source>();
 
         selectedOrganisationUnits = selectionTreeManager.getSelectedOrganisationUnits();
-        selectedSources = organisationUnitService.convert( selectedOrganisationUnits );
-
+        
+        if ( selectionValue.equalsIgnoreCase( SELECTED ) )
+        {
+            selectedSources = organisationUnitService.convert( selectedOrganisationUnits );
+
+            this.executeCollectiveDataLock( selectedSources, currentUserName );
+        }
+        else if ( selectionValue.equalsIgnoreCase( CHILDTREE ) )
+        {
+            selectedSources = new HashSet<Source>();
+
+            for ( OrganisationUnit organisationUnitsElement : selectedOrganisationUnits )
+            {
+                selectedSources.addAll( organisationUnitService.convert( organisationUnitService
+                    .getOrganisationUnitWithChildren( organisationUnitsElement.getId() ) ) );
+            }
+            
+            this.executeCollectiveDataLock( selectedSources, currentUserName );
+        }
+
+        return SUCCESS;
+    }
+
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+
+    private void executeCollectiveDataLock( Set<Source> sources, String currentUserName )
+    {
         if ( selectBetweenLockUnlock )
         {
-            dataSetLockService.applyCollectiveDataLock( dataSets, periods, selectedSources, currentUserName );
+            dataSetLockService.applyCollectiveDataLock( dataSets, periods, sources, currentUserName );
 
             message = i18n.getString( "information_successfully_locked" );
         }
-        else
+        else if ( selectBetweenLockUnlock )
         {
-            dataSetLockService.removeCollectiveDataLock( dataSets, periods, selectedSources, currentUserName );
+            dataSetLockService.removeCollectiveDataLock( dataSets, periods, sources, currentUserName );
 
             message = i18n.getString( "information_successfully_unlocked" );
         }
-
-        return SUCCESS;
     }
-
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2010-10-05 10:04:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2010-10-06 21:15:55 +0000
@@ -314,4 +314,5 @@
 organisation_not_selected                                           = WARNING: There is no organisation unit selected
 selected_periods                                                    = Selected Periods
 selected_datasets                                                   = Selected Datasets
-organisation_not_selected                                           = WARNING: There is no organisation unit selected
\ No newline at end of file
+organisation_not_selected                                           = WARNING: There is no organisation unit selected
+child_tree                                                          = Child Tree
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties	2010-10-05 10:04:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module_vi_VN.properties	2010-10-06 21:15:55 +0000
@@ -287,4 +287,5 @@
 sqlview_process_canceled_interrupted                                = C\u1ea2NH B\u00c1O: C\u00e2u truy v\u1ea5n n\u00e0y c\u00f3 th\u1ec3 s\u1ebd l\u1ea5y ra m\u1ed9t l\u01b0\u1ee3ng d\u1eef li\u1ec7u kh\u00e1 l\u1edbn trong CSDL.\n\nB\u1ea1n c\u00f3 mu\u1ed1n ti\u1ebfp t\u1ee5c...?
 organisation_not_selected                                           = C\u1ea2NH B\u00c1O: Kh\u00f4ng c\u00f3 \u0111\u01a1n v\u1ecb n\u00e0o \u0111\u01b0\u1ee3c ch\u1ecdn
 selected_periods                                                    = Th\u1eddi \u0111i\u1ec3m \u0111\u01b0\u1ee3c ch\u1ecdn
-selected_datasets                                                   = T\u1eadp d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c ch\u1ecdn
\ No newline at end of file
+selected_datasets                                                   = T\u1eadp d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c ch\u1ecdn
+child_tree                                                          = Duy\u1ec7t c\u1ea3 \u0111\u01a1n v\u1ecb con
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/collectiveDataLockingForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/collectiveDataLockingForm.vm	2010-10-05 10:04:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/collectiveDataLockingForm.vm	2010-10-06 21:15:55 +0000
@@ -73,15 +73,23 @@
 	</table>
 	<table>
 		<tr>
-			<td>#organisationUnitSelectionTree( true, true, false )</td>							
+			<td>#organisationUnitSelectionTree( true, true, false )</td>										
 		</tr>
-		<tr></tr>
+		<tr></tr>				
+	</table>	
+	<table>
 		<tr>
 			<td>
+				<select id="selectionValue" name="selectionValue" enabled="true">
+					<option value="selected" selected>$i18n.getString( "selected" )</option>
+					<option value="childtree">$i18n.getString( "child_tree" )</option>
+				</select>   
+			</td>
+			<td>
 				<input type="submit" id="lock" name="lock" onclick="setClickedButtonElementValue( true )" value="$i18n.getString( 'lock' )" style="width:10em" disabled="true"/>
 				<input type="submit" id="unlock" name="unlock" onclick="setClickedButtonElementValue( false )" value="$i18n.getString( 'unlock' )" style="width:10em" disabled="true"/>
 			</td>
-		</tr>							
+		</tr>
 	</table>	
 </form>