dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41160
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20963: remove custom in-operator parsing in QueryService
------------------------------------------------------------
revno: 20963
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-11-05 14:23:30 +0700
message:
remove custom in-operator parsing in QueryService
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/DefaultObjectFilterService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.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-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/DefaultObjectFilterService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/DefaultObjectFilterService.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/DefaultObjectFilterService.java 2015-11-05 07:23:30 +0000
@@ -41,6 +41,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -65,13 +66,9 @@
List<T> list = Lists.newArrayList();
- for ( T object : objects )
- {
- if ( evaluateWithFilters( object, parsed ) )
- {
- list.add( object );
- }
- }
+ list.addAll( objects.stream()
+ .filter( object -> evaluateWithFilters( object, parsed ) )
+ .collect( Collectors.toList() ) );
return list;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java 2015-11-05 06:39:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java 2015-11-05 07:23:30 +0000
@@ -28,7 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.google.common.collect.Lists;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.query.operators.MatchMode;
import org.hisp.dhis.schema.Property;
@@ -219,7 +218,7 @@
}
case "in":
{
- return Restrictions.in( split[0], parseInOperator( value ) );
+ return Restrictions.in( split[0], QueryUtils.getValue( Collection.class, value ) );
}
case "null":
{
@@ -229,16 +228,4 @@
return null;
}
-
- private Collection<String> parseInOperator( String value )
- {
- if ( value == null || !value.startsWith( "[" ) || !value.endsWith( "]" ) )
- {
- return Lists.newArrayList();
- }
-
- String[] split = value.substring( 1, value.length() - 1 ).split( "," );
-
- return Lists.newArrayList( split );
- }
}