← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15918: ContextUtils, changed from List to Set as return type for getQueryParamValues

 

------------------------------------------------------------
revno: 15918
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-06-30 19:11:33 +0200
message:
  ContextUtils, changed from List to Set as return type for getQueryParamValues
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/OrganisationUnitSelectionMode.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.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/common/OrganisationUnitSelectionMode.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/OrganisationUnitSelectionMode.java	2014-03-31 08:14:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/OrganisationUnitSelectionMode.java	2014-06-30 17:11:33 +0000
@@ -42,5 +42,5 @@
  */
 public enum OrganisationUnitSelectionMode
 {
-    SELECTED, CHILDREN, DESCENDANTS, ALL
+    SELECTED, CHILDREN, DESCENDANTS, ACCESSIBLE, ALL
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2014-06-17 12:45:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2014-06-30 17:11:33 +0000
@@ -222,10 +222,17 @@
      */
     public OrganisationUnit getDataViewOrganisationUnitWithFallback()
     {
-        OrganisationUnit dataViewOrgUnit = getDataViewOrganisationUnit();
-        return dataViewOrgUnit != null ? dataViewOrgUnit : getOrganisationUnit();
-    }
-
+        return hasDataViewOrganisationUnit() ? getDataViewOrganisationUnit() : getOrganisationUnit();
+    }
+    
+    /**
+     * Returns the data view organisation units or organisation units if not exist.
+     */
+    public Set<OrganisationUnit> getDataViewOrganisationUnitsWithFallback()
+    {
+        return hasDataViewOrganisationUnit() ? dataViewOrganisationUnits : organisationUnits;
+    }
+    
     public String getOrganisationUnitsName()
     {
         return IdentifiableObjectUtils.join( organisationUnits );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java	2014-06-27 16:27:09 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java	2014-06-30 17:11:33 +0000
@@ -93,9 +93,6 @@
 
     private Map<Object, Integer> sourceMapping;
 
-    // private BigDecimal price = new BigDecimal("0");
-    // private BigDecimal totalEntry;
-
     // -------------------------------------------------------------------------
     // Constructor
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java	2014-06-11 20:27:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java	2014-06-30 17:11:33 +0000
@@ -28,6 +28,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.IllegalQueryException;
@@ -43,10 +51,10 @@
 import org.hisp.dhis.schema.descriptors.TrackedEntityInstanceSchemaDescriptor;
 import org.hisp.dhis.system.grid.GridUtils;
 import org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams;
-import org.hisp.dhis.webapi.webdomain.WebOptions;
 import org.hisp.dhis.webapi.controller.exception.NotFoundException;
 import org.hisp.dhis.webapi.utils.ContextUtils;
 import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
+import org.hisp.dhis.webapi.webdomain.WebOptions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.http.HttpStatus;
@@ -61,14 +69,6 @@
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseStatus;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -98,7 +98,7 @@
         @RequestParam( required = false ) String query,
         @RequestParam( required = false ) Set<String> attribute,
         @RequestParam( required = false ) Set<String> filter,
-        @RequestParam String ou,
+        @RequestParam( required = false ) String ou,
         @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
         @RequestParam( required = false ) String program,
         @RequestParam( required = false ) ProgramStatus programStatus,
@@ -115,7 +115,7 @@
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        Set<String> orgUnits = new HashSet<String>( ContextUtils.getQueryParamValues( ou ) );
+        Set<String> orgUnits = ContextUtils.getQueryParamValues( ou );
         TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
             program, programStatus, followUp, programStartDate, programEndDate, trackedEntity,
             eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize );
@@ -133,7 +133,7 @@
         @RequestParam( required = false ) String query,
         @RequestParam( required = false ) Set<String> attribute,
         @RequestParam( required = false ) Set<String> filter,
-        @RequestParam String ou,
+        @RequestParam( required = false ) String ou,
         @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
         @RequestParam( required = false ) String program,
         @RequestParam( required = false ) ProgramStatus programStatus,
@@ -150,7 +150,7 @@
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        Set<String> orgUnits = new HashSet<String>( ContextUtils.getQueryParamValues( ou ) );
+        Set<String> orgUnits = ContextUtils.getQueryParamValues( ou );
         TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
             program, programStatus, followUp, programStartDate, programEndDate, trackedEntity,
             eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize );
@@ -165,7 +165,7 @@
         @RequestParam( required = false ) String query,
         @RequestParam( required = false ) Set<String> attribute,
         @RequestParam( required = false ) Set<String> filter,
-        @RequestParam String ou,
+        @RequestParam( required = false ) String ou,
         @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
         @RequestParam( required = false ) String program,
         @RequestParam( required = false ) ProgramStatus programStatus,
@@ -182,7 +182,7 @@
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        Set<String> orgUnits = new HashSet<String>( ContextUtils.getQueryParamValues( ou ) );
+        Set<String> orgUnits = ContextUtils.getQueryParamValues( ou );
         TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
             program, programStatus, followUp, programStartDate, programEndDate, trackedEntity,
             eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize );
@@ -197,7 +197,7 @@
         @RequestParam( required = false ) String query,
         @RequestParam( required = false ) Set<String> attribute,
         @RequestParam( required = false ) Set<String> filter,
-        @RequestParam String ou,
+        @RequestParam( required = false ) String ou,
         @RequestParam( required = false ) OrganisationUnitSelectionMode ouMode,
         @RequestParam( required = false ) String program,
         @RequestParam( required = false ) ProgramStatus programStatus,
@@ -214,7 +214,7 @@
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        Set<String> orgUnits = new HashSet<String>( ContextUtils.getQueryParamValues( ou ) );
+        Set<String> orgUnits = ContextUtils.getQueryParamValues( ou );
         TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
             program, programStatus, followUp, programStartDate, programEndDate, trackedEntity,
             eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java	2014-06-24 11:30:23 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java	2014-06-30 17:11:33 +0000
@@ -34,11 +34,10 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.HashMap;
-import java.util.List;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
@@ -212,7 +211,7 @@
 
     public static HttpServletRequest getRequest()
     {
-        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+        return ( (ServletRequestAttributes) RequestContextHolder.getRequestAttributes() ).getRequest();
     }
 
     public static String getContextPath( HttpServletRequest request )
@@ -268,7 +267,7 @@
      * @param value the query param value.
      * @return the list of independent values.
      */
-    public static List<String> getQueryParamValues( String value )
+    public static Set<String> getQueryParamValues( String value )
     {
         if ( value == null || value.isEmpty() )
         {
@@ -277,7 +276,7 @@
 
         String[] values = value.split( QUERY_PARAM_SEP );
         
-        return new ArrayList<String>( Arrays.asList( values ) );
+        return new HashSet<String>( Arrays.asList( values ) );
     }
     
     /**

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java	2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java	2014-06-30 17:11:33 +0000
@@ -29,7 +29,6 @@
  */
 
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
 import javax.servlet.http.HttpServletResponse;
@@ -62,7 +61,7 @@
      */
     public DataElementCategoryOptionCombo getAttributeOptionCombo( HttpServletResponse response, String cc, String cp )
     {
-        List<String> opts = ContextUtils.getQueryParamValues( cp );
+        Set<String> opts = ContextUtils.getQueryParamValues( cp );
 
         // ---------------------------------------------------------------------
         // Attribute category combo validation
@@ -201,7 +200,7 @@
 
         if ( cp != null )
         {
-            List<String> opts = ContextUtils.getQueryParamValues( cp );
+            Set<String> opts = ContextUtils.getQueryParamValues( cp );
 
             options = new HashSet<DataElementCategoryOption>();