------------------------------------------------------------
revno: 12678
committer: Lars Helge Ă˜verland <larshe...@gmail.com>
branch nick: dhis2
timestamp: Tue 2013-10-15 14:45:25 +0200
message:
  Added class SetMap and enum OrganisationUnitSelectionMode
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SetMap.java
  
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitSelectionMode.java
modified:
  
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidatorThread.java
  
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.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
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SetMap.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SetMap.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SetMap.java	2013-10-15 12:45:25 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class SetMap<T, V>
+    extends HashMap<T, Set<V>>
+{
+    public SetMap()
+    {
+        super();
+    }
+    
+    public SetMap( SetMap<T, V> setMap )
+    {
+        super( setMap );
+    }    
+
+    public List<V> putValue( T key, V value )
+    {
+        Set<V> set = this.get( key );
+        set = set == null ? new HashSet<V>() : set;        
+        set.add( value );
+        super.put( key, set );        
+        return null;
+    }
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitSelectionMode.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitSelectionMode.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitSelectionMode.java	2013-10-15 12:45:25 +0000
@@ -0,0 +1,37 @@
+package org.hisp.dhis.organisationunit;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+public enum OrganisationUnitSelectionMode
+{
+    EXPLICIT,
+    SUBTREE,
+    ACCESSIBLE,
+    ALL
+}

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidatorThread.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidatorThread.java	2013-10-14 20:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidatorThread.java	2013-10-15 12:45:25 +0000
@@ -93,7 +93,7 @@
     private void validateSource( OrganisationUnitExtended sourceX, ValidationRunContext context )
     {
         if ( context.getValidationResults().size() < ( ValidationRunType.INTERACTIVE == context.getRunType() ?
-        		ValidationRuleService.MAX_INTERACTIVE_VIOLATIONS : ValidationRuleService.MAX_ALERT_VIOLATIONS) )
+            ValidationRuleService.MAX_INTERACTIVE_VIOLATIONS : ValidationRuleService.MAX_ALERT_VIOLATIONS) )
         {
             for ( PeriodTypeExtended periodTypeX : context.getPeriodTypeExtendedMap().values() )
             {
@@ -111,9 +111,10 @@
                         Map<DataElementOperand, Double> currentValueMap = getDataValueMapRecursive( periodTypeX,
                             periodTypeX.getDataElements(), sourceDataElements, recursiveCurrentDataElements,
                             periodTypeX.getAllowedPeriodTypes(), period, sourceX.getSource(), lastUpdatedMap, incompleteValues );
-                        log.trace( "\nsource " + sourceX.getSource().getName()
-                        		+ " [" + period.getStartDate() + " - " + period.getEndDate() + "]"
-                        		+ " valueMap[" + currentValueMap.size() + "]" );
+                        
+                        log.trace( "Source " + sourceX.getSource().getName()
+                            + " [" + period.getStartDate() + " - " + period.getEndDate() + "]"
+                            + " valueMap[" + currentValueMap.size() + "]" );
 
                         for ( ValidationRule rule : rules )
                         {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java	2013-10-15 12:12:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/scheduling/MonitoringTask.java	2013-10-15 12:45:25 +0000
@@ -169,7 +169,7 @@
         
         if ( !results.isEmpty() )
         {
-            postAlerts( results, thisAlertRun ); // Alert the users.
+            postAlerts( results, thisAlertRun );
         }
         
         systemSettingManager.saveSystemSetting( SystemSettingManager.KEY_LAST_ALERT_RUN, thisAlertRun );
@@ -205,6 +205,9 @@
      * (if any), and the most recent previous period. Add whichever of
      * these periods actually exist in the database.
      * 
+     * TODO If the last successful daily run was more than one day ago, we might 
+     * add some additional periods of type DailyPeriodType not to miss any alerts.
+     *
      * @param rules the ValidationRules to be evaluated on this alert run
      * @return periods to search for new alerts
      */
@@ -220,10 +223,7 @@
             Period currentPeriod = calendarPeriodType.createPeriod();
             Period previousPeriod = calendarPeriodType.getPreviousPeriod( currentPeriod );
             periods.addAll( periodService.getIntersectingPeriodsByPeriodType( periodType,
-                previousPeriod.getStartDate(), currentPeriod.getEndDate() ) );
-            // Note: If the last successful daily run was more than one day
-            // ago, we might consider adding some additional periods of type 
-            // DailyPeriodType so we don't miss any alerts.
+                previousPeriod.getStartDate(), currentPeriod.getEndDate() ) );            
         }
 
         return periods;
@@ -282,7 +282,7 @@
     }
 
     /**
-     * Returns a map where the key is a (sorted) list of validation results
+     * Returns a map where the key is a sorted list of validation results
      * to assemble into a message, and the value is the set of users who
      * should receive this message.
      * 
@@ -378,7 +378,7 @@
 
         SimpleDateFormat dateTimeFormatter = new SimpleDateFormat( "yyyy-MM-dd HH:mm" );
 
-        Map<String, Integer> importanceCountMap = countTheResultsByImportanceType( results );
+        Map<String, Integer> importanceCountMap = countResultsByImportanceType( results );
 
         String subject = "DHIS alerts as of " + dateTimeFormatter.format( alertRunStart ) + " - priority High "
             + ( importanceCountMap.get( "high" ) == null ? 0 : importanceCountMap.get( "high" ) ) + ", Medium "
@@ -434,9 +434,9 @@
      * types that are found within the results.
      * 
      * @param results results to analyze
-     * @return Map showing the result count for each importance type
+     * @return Mapping between importance type and result counts.
      */
-    private Map<String, Integer> countTheResultsByImportanceType ( List<ValidationResult> results )
+    private Map<String, Integer> countResultsByImportanceType ( List<ValidationResult> results )
     {
         Map<String, Integer> importanceCountMap = new HashMap<String, Integer>();
         

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to     : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp

Reply via email to