dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41292
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21035: remove old ObjectFilterService, now all is controlled by QueryService and its engines, paging etc...
------------------------------------------------------------
revno: 21035
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-11-12 11:47:12 +0700
message:
remove old ObjectFilterService, now all is controlled by QueryService and its engines, paging etc is only handled in the service. Cleaned up AbstractCrudController to use code. Added several new filter operators.
removed:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/
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/FilterOps.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/Filters.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ObjectFilterService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/OpFactory.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EmptyCollectionOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EndsWithOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EqOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/GtOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/GteOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/InOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LikeOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LtOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LteOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NLikeOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NeqOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NnullOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NullOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/Op.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/OpStatus.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/StartsWithOp.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/parser/
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/parser/DefaultParserService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/parser/ParserService.java
added:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldParser.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/FieldParser.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotInOperator.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotLikeOperator.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/PagerUtils.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/CriteriaQueryEngine.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryParser.java
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/InMemoryQueryEngine.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/QueryService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Restrictions.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/CriteriaQueryEngineTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/InMemoryQueryEngineTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryParserTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CrudControllerAdvice.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/validation/ValidationRuleController.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/PagerUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/PagerUtils.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/PagerUtils.java 2015-11-12 04:47:12 +0000
@@ -46,6 +46,11 @@
{
List<T> objects = new ArrayList<>( col );
+ if ( offset == 0 && objects.size() <= limit )
+ {
+ return objects;
+ }
+
if ( offset >= objects.size() )
{
offset = objects.isEmpty() ? objects.size() : objects.size() - 1;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldFilterService.java 2015-11-12 04:47:12 +0000
@@ -33,7 +33,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.hisp.dhis.common.PresetProvider;
-import org.hisp.dhis.parser.ParserService;
import org.hisp.dhis.node.AbstractNode;
import org.hisp.dhis.node.Node;
import org.hisp.dhis.node.NodePropertyConverter;
@@ -65,7 +64,7 @@
private final Pattern MUTATOR_PATTERN = Pattern.compile( "(\\w+)(?:::(\\w+))?(?:\\|rename\\((\\w+)\\))?" );
@Autowired
- private ParserService parserService;
+ private FieldParser fieldParser;
@Autowired
private SchemaService schemaService;
@@ -158,7 +157,7 @@
}
else
{
- fieldMap = parserService.parseFieldFilter( fields );
+ fieldMap = fieldParser.parse( fields );
}
for ( Object object : objects )
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldParser.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldParser.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/DefaultFieldParser.java 2015-11-12 04:47:12 +0000
@@ -0,0 +1,116 @@
+package org.hisp.dhis.fieldfilter;
+
+/*
+ * Copyright (c) 2004-2015, 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 com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DefaultFieldParser implements FieldParser
+{
+ @Override
+ public FieldMap parse( String fields )
+ {
+ List<String> prefixList = Lists.newArrayList();
+ FieldMap fieldMap = new FieldMap();
+
+ StringBuilder builder = new StringBuilder();
+
+ for ( String c : fields.split( "" ) )
+ {
+ if ( c.equals( "," ) )
+ {
+ putInMap( fieldMap, joinedWithPrefix( builder, prefixList ) );
+ builder = new StringBuilder();
+ continue;
+ }
+
+ if ( c.equals( "[" ) )
+ {
+ prefixList.add( builder.toString() );
+ builder = new StringBuilder();
+ continue;
+ }
+
+ if ( c.equals( "]" ) )
+ {
+ if ( !builder.toString().isEmpty() )
+ {
+ putInMap( fieldMap, joinedWithPrefix( builder, prefixList ) );
+ }
+
+ prefixList.remove( prefixList.size() - 1 );
+ builder = new StringBuilder();
+ continue;
+ }
+
+ if ( StringUtils.isAlpha( c ) || c.equals( "*" ) || c.equals( ":" ) || c.equals( "!" )
+ || c.equals( "|" ) || c.equals( "{" ) || c.equals( "}" ) || c.equals( "(" ) || c.equals( ")" ) )
+ {
+ builder.append( c );
+ }
+ }
+
+ if ( !builder.toString().isEmpty() )
+ {
+ putInMap( fieldMap, joinedWithPrefix( builder, prefixList ) );
+ }
+
+ return fieldMap;
+ }
+
+ private String joinedWithPrefix( StringBuilder builder, List<String> prefixList )
+ {
+ String prefixes = StringUtils.join( prefixList, "." );
+ prefixes = prefixes.isEmpty() ? builder.toString() : (prefixes + "." + builder.toString());
+ return prefixes;
+ }
+
+ private void putInMap( FieldMap fieldMap, String path )
+ {
+ if ( StringUtils.isEmpty( path ) )
+ {
+ return;
+ }
+
+ for ( String p : path.split( "\\." ) )
+ {
+ if ( fieldMap.get( p ) == null )
+ {
+ fieldMap.put( p, new FieldMap() );
+ }
+
+ fieldMap = fieldMap.get( p );
+ }
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/FieldParser.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/FieldParser.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fieldfilter/FieldParser.java 2015-11-12 04:47:12 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.fieldfilter;
+
+/*
+ * Copyright (c) 2004-2015, 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.
+ */
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public interface FieldParser
+{
+ /**
+ * Parses and writes out fieldMap with included/excluded properties.
+ *
+ * @param filter String to parse, can be used for both inclusion/exclusion
+ * @return FieldMap with property name as key, and another FieldMap as value (recursive)
+ * @see org.hisp.dhis.fieldfilter.FieldMap
+ */
+ FieldMap parse( String filter );
+}
=== removed directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter'
=== removed 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-11-05 07:23:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/DefaultObjectFilterService.java 1970-01-01 00:00:00 +0000
@@ -1,178 +0,0 @@
-package org.hisp.dhis.objectfilter;
-
-/*
- * Copyright (c) 2004-2015, 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 com.google.common.collect.Lists;
-import org.hisp.dhis.objectfilter.ops.Op;
-import org.hisp.dhis.objectfilter.ops.OpStatus;
-import org.hisp.dhis.parser.ParserService;
-import org.hisp.dhis.schema.Property;
-import org.hisp.dhis.schema.Schema;
-import org.hisp.dhis.schema.SchemaService;
-import org.hisp.dhis.system.util.ReflectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class DefaultObjectFilterService implements ObjectFilterService
-{
- @Autowired
- private ParserService parserService;
-
- @Autowired
- private SchemaService schemaService;
-
- @Override
- public <T> List<T> filter( List<T> objects, List<String> filters )
- {
- if ( objects == null || objects.isEmpty() )
- {
- return Lists.newArrayList();
- }
-
- Filters parsed = parserService.parseObjectFilter( filters );
-
- List<T> list = Lists.newArrayList();
-
- list.addAll( objects.stream()
- .filter( object -> evaluateWithFilters( object, parsed ) )
- .collect( Collectors.toList() ) );
-
- return list;
- }
-
- @SuppressWarnings( "unchecked" )
- private <T> boolean evaluateWithFilters( T object, Filters filters )
- {
- if ( object == null )
- {
- return false;
- }
-
- Schema schema = schemaService.getDynamicSchema( object.getClass() );
-
- for ( String field : filters.getFilters().keySet() )
- {
- if ( !schema.haveProperty( field ) )
- {
- continue;
- }
-
- Property descriptor = schema.getProperty( field );
-
- if ( descriptor == null )
- {
- continue;
- }
-
- Object value = ReflectionUtils.invokeMethod( object, descriptor.getGetterMethod() );
-
- Object filter = filters.getFilters().get( field );
-
- if ( FilterOps.class.isInstance( filter ) )
- {
- if ( evaluateFilterOps( value, (FilterOps) filter ) )
- {
- return false;
- }
- }
- else
- {
- Map<String, Object> map = (Map<String, Object>) filters.getFilters().get( field );
- Filters f = new Filters();
- f.setFilters( map );
-
- if ( map.containsKey( "__self__" ) )
- {
- if ( evaluateFilterOps( value, (FilterOps) map.get( "__self__" ) ) )
- {
- return false;
- }
-
- map.remove( "__self__" );
- }
-
- if ( !descriptor.isCollection() )
- {
- if ( !evaluateWithFilters( value, f ) )
- {
- return false;
- }
- }
- else
- {
- Collection<?> objectCollection = (Collection<?>) value;
-
- if ( objectCollection.isEmpty() )
- {
- return false;
- }
-
- boolean include = false;
-
- for ( Object idObject : objectCollection )
- {
- if ( evaluateWithFilters( idObject, f ) )
- {
- include = true;
- }
- }
-
- if ( !include )
- {
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
- private boolean evaluateFilterOps( Object value, FilterOps filterOps )
- {
- for ( Op op : filterOps.getFilters() )
- {
- OpStatus status = op.evaluate( value );
-
- if ( OpStatus.EXCLUDE.equals( status ) )
- {
- return true;
- }
- }
-
- return false;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/FilterOps.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/FilterOps.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/FilterOps.java 1970-01-01 00:00:00 +0000
@@ -1,62 +0,0 @@
-package org.hisp.dhis.objectfilter;
-
-/*
- * Copyright (c) 2004-2015, 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 org.hisp.dhis.objectfilter.ops.Op;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class FilterOps
-{
- private List<Op> filters = new ArrayList<>();
-
- FilterOps()
- {
- }
-
- public List<Op> getFilters()
- {
- return filters;
- }
-
- public void setFilters( List<Op> filters )
- {
- this.filters = filters;
- }
-
- @Override
- public String toString()
- {
- return filters.toString();
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/Filters.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/Filters.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/Filters.java 1970-01-01 00:00:00 +0000
@@ -1,160 +0,0 @@
-package org.hisp.dhis.objectfilter;
-
-/*
- * Copyright (c) 2004-2015, 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 com.google.common.collect.Maps;
-import org.hisp.dhis.objectfilter.ops.Op;
-
-import java.util.Map;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class Filters
-{
- private Map<String, Object> filters = Maps.newHashMap();
-
- public Filters()
- {
- }
-
- public void addFilter( String path, String operator, String value )
- {
- FilterOps filterOps = createPath( path );
-
- if ( filterOps == null )
- {
- return;
- }
-
- if ( OpFactory.canCreate( operator ) )
- {
- Op op = OpFactory.create( operator );
-
- if ( op == null )
- {
- return;
- }
-
- if ( op.wantValue() )
- {
- if ( value == null )
- {
- return;
- }
-
- op.setValue( value );
- }
-
- filterOps.getFilters().add( op );
- }
- }
-
- @SuppressWarnings( "unchecked" )
- private FilterOps createPath( String path )
- {
- if ( !path.contains( "." ) )
- {
- if ( !filters.containsKey( path ) )
- {
- filters.put( path, new FilterOps() );
- }
-
- return (FilterOps) filters.get( path );
- }
-
- String[] split = path.split( "\\." );
-
- Map<String, Object> c = filters;
-
- for ( int i = 0; i < split.length; i++ )
- {
- boolean last = (i == (split.length - 1));
-
- if ( c.containsKey( split[i] ) )
- {
- if ( FilterOps.class.isInstance( c.get( split[i] ) ) )
- {
- if ( last )
- {
- return (FilterOps) c.get( split[i] );
- }
- else
- {
- FilterOps self = (FilterOps) c.get( split[i] );
- Map<String, Object> map = Maps.newHashMap();
- map.put( "__self__", self );
-
- c.put( split[i], map );
- c = map;
- }
- }
- else
- {
- c = (Map<String, Object>) c.get( split[i] );
- }
- }
- else
- {
- if ( last )
- {
- FilterOps filterOps = new FilterOps();
- c.put( split[i], filterOps );
- return filterOps;
- }
- else
- {
- Map<String, Object> map = Maps.newHashMap();
- c.put( split[i], map );
- c = map;
- }
- }
- }
-
- return null;
- }
-
- public Map<String, Object> getFilters()
- {
- return filters;
- }
-
- public void setFilters( Map<String, Object> filters )
- {
- this.filters = filters;
- }
-
- @Override
- public String toString()
- {
- return "Filters{" +
- "filters=" + filters +
- '}';
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ObjectFilterService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ObjectFilterService.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ObjectFilterService.java 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
-package org.hisp.dhis.objectfilter;
-
-/*
- * Copyright (c) 2004-2015, 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.List;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public interface ObjectFilterService
-{
- /**
- * Filter a list of objects based on un-parsed filter string.
- * In-memory filter
- *
- * @param objects List to filter
- * @param filters Filter string
- * @return Filtered object list
- */
- <T extends Object> List<T> filter( List<T> objects, List<String> filters );
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/OpFactory.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/OpFactory.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/OpFactory.java 1970-01-01 00:00:00 +0000
@@ -1,103 +0,0 @@
-package org.hisp.dhis.objectfilter;
-
-/*
- * Copyright (c) 2004-2015, 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 com.google.common.collect.Maps;
-import org.hisp.dhis.objectfilter.ops.EmptyCollectionOp;
-import org.hisp.dhis.objectfilter.ops.EndsWithOp;
-import org.hisp.dhis.objectfilter.ops.EqOp;
-import org.hisp.dhis.objectfilter.ops.GtOp;
-import org.hisp.dhis.objectfilter.ops.GteOp;
-import org.hisp.dhis.objectfilter.ops.InOp;
-import org.hisp.dhis.objectfilter.ops.LikeOp;
-import org.hisp.dhis.objectfilter.ops.LtOp;
-import org.hisp.dhis.objectfilter.ops.LteOp;
-import org.hisp.dhis.objectfilter.ops.NLikeOp;
-import org.hisp.dhis.objectfilter.ops.NeqOp;
-import org.hisp.dhis.objectfilter.ops.NnullOp;
-import org.hisp.dhis.objectfilter.ops.NullOp;
-import org.hisp.dhis.objectfilter.ops.Op;
-import org.hisp.dhis.objectfilter.ops.StartsWithOp;
-
-import java.util.Map;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class OpFactory
-{
- protected static Map<String, Class<? extends Op>> REGISTER = Maps.newHashMap();
-
- static
- {
- register( "eq", EqOp.class );
- register( "ne", NeqOp.class );
- register( "neq", NeqOp.class );
- register( "like", LikeOp.class );
- register( "ilike", LikeOp.class );
- register( "nlike", NLikeOp.class );
- register( "startsWith", StartsWithOp.class );
- register( "endsWith", EndsWithOp.class );
- register( "gt", GtOp.class );
- register( "ge", GteOp.class );
- register( "gte", GteOp.class );
- register( "lt", LtOp.class );
- register( "le", LteOp.class );
- register( "lte", LteOp.class );
- register( "null", NullOp.class );
- register( "nnull", NnullOp.class );
- register( "empty", EmptyCollectionOp.class );
- register( "in", InOp.class );
- }
-
- public static void register( String type, Class<? extends Op> opClass )
- {
- REGISTER.put( type.toLowerCase(), opClass );
- }
-
- public static boolean canCreate( String type )
- {
- return REGISTER.containsKey( type.toLowerCase() );
- }
-
- public static Op create( String type )
- {
- Class<? extends Op> opClass = REGISTER.get( type.toLowerCase() );
-
- try
- {
- return opClass.newInstance();
- }
- catch ( InstantiationException | IllegalAccessException ignored )
- {
- }
-
- return null;
- }
-}
=== removed directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops'
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EmptyCollectionOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EmptyCollectionOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EmptyCollectionOp.java 1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.Collection;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class EmptyCollectionOp extends Op
-{
- @Override
- public boolean wantValue()
- {
- return false;
- }
-
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( object == null )
- {
- // TODO: ignore or include here?
- return OpStatus.IGNORE;
- }
-
- if ( Collection.class.isInstance( object ) )
- {
- Collection<?> c = (Collection<?>) object;
-
- if ( c.isEmpty() )
- {
- return OpStatus.INCLUDE;
- }
- else
- {
- return OpStatus.EXCLUDE;
- }
- }
-
- return OpStatus.IGNORE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EndsWithOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EndsWithOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EndsWithOp.java 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.
- */
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class EndsWithOp extends Op
-{
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( getValue() == null || object == null )
- {
- return OpStatus.IGNORE;
- }
-
- if ( String.class.isInstance( object ) )
- {
- String s1 = getValue( String.class );
- String s2 = (String) object;
-
- return (s1 != null && s2.toLowerCase().endsWith( s1.toLowerCase() )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
-
- return OpStatus.IGNORE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EqOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EqOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/EqOp.java 1970-01-01 00:00:00 +0000
@@ -1,106 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.Collection;
-import java.util.Date;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class EqOp extends Op
-{
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( getValue() == null || object == null )
- {
- return OpStatus.EXCLUDE;
- }
-
- if ( String.class.isInstance( object ) )
- {
- String s1 = getValue( String.class );
- String s2 = (String) object;
-
- return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Boolean.class.isInstance( object ) )
- {
- Boolean s1 = getValue( Boolean.class );
- Boolean s2 = (Boolean) object;
-
- return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Integer.class.isInstance( object ) )
- {
- Integer s1 = getValue( Integer.class );
- Integer s2 = (Integer) object;
-
- return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Float.class.isInstance( object ) )
- {
- Float s1 = getValue( Float.class );
- Float s2 = (Float) object;
-
- return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Collection.class.isInstance( object ) )
- {
- Collection<?> collection = (Collection<?>) object;
- Integer size = getValue( Integer.class );
-
- if ( size != null && collection.size() == size )
- {
- return OpStatus.INCLUDE;
- }
- else
- {
- return OpStatus.EXCLUDE;
- }
- }
- else if ( Date.class.isInstance( object ) )
- {
- Date s1 = getValue( Date.class );
- Date s2 = (Date) object;
-
- return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Enum.class.isInstance( object ) )
- {
- String s1 = getValue();
- String s2 = String.valueOf( object );
-
- return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
-
- return OpStatus.EXCLUDE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/GtOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/GtOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/GtOp.java 1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.Collection;
-import java.util.Date;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class GtOp extends Op
-{
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( getValue() == null || object == null )
- {
- return OpStatus.IGNORE;
- }
-
- if ( Integer.class.isInstance( object ) )
- {
- Integer s1 = getValue( Integer.class );
- Integer s2 = (Integer) object;
-
- return (s1 != null && s2 > s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Float.class.isInstance( object ) )
- {
- Float s1 = getValue( Float.class );
- Float s2 = (Float) object;
-
- return (s1 != null && s2 > s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Collection.class.isInstance( object ) )
- {
- Collection<?> collection = (Collection<?>) object;
- Integer size = getValue( Integer.class );
-
- if ( size != null && collection.size() > size )
- {
- return OpStatus.INCLUDE;
- }
- else
- {
- return OpStatus.EXCLUDE;
- }
- }
- else if ( Date.class.isInstance( object ) )
- {
- Date s1 = getValue( Date.class );
- Date s2 = (Date) object;
-
- return (s1 != null && s2.after( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
-
- return OpStatus.IGNORE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/GteOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/GteOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/GteOp.java 1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.Collection;
-import java.util.Date;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class GteOp extends Op
-{
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( getValue() == null || object == null )
- {
- return OpStatus.EXCLUDE;
- }
-
- if ( Integer.class.isInstance( object ) )
- {
- Integer s1 = getValue( Integer.class );
- Integer s2 = (Integer) object;
-
- return (s1 != null && s2 >= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Float.class.isInstance( object ) )
- {
- Float s1 = getValue( Float.class );
- Float s2 = (Float) object;
-
- return (s1 != null && s2 >= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Collection.class.isInstance( object ) )
- {
- Collection<?> collection = (Collection<?>) object;
- Integer size = getValue( Integer.class );
-
- if ( size != null && collection.size() >= size )
- {
- return OpStatus.INCLUDE;
- }
- else
- {
- return OpStatus.EXCLUDE;
- }
- }
- else if ( Date.class.isInstance( object ) )
- {
- Date s1 = getValue( Date.class );
- Date s2 = (Date) object;
-
- return (s1 != null && (s2.after( s1 ) || s2.equals( s1 ))) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
-
- return OpStatus.IGNORE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/InOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/InOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/InOp.java 1970-01-01 00:00:00 +0000
@@ -1,107 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.Collection;
-import java.util.Date;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class InOp extends Op
-{
- @Override
- @SuppressWarnings( "unchecked" )
- public OpStatus evaluate( Object object )
- {
- Collection<String> items = getValue( Collection.class );
-
- if ( items == null || object == null )
- {
- return OpStatus.IGNORE;
- }
-
- for ( String item : items )
- {
- if ( compare( item, object ) )
- {
- return OpStatus.INCLUDE;
- }
- }
-
- return OpStatus.EXCLUDE;
- }
-
- private boolean compare( String item, Object object )
- {
- if ( String.class.isInstance( object ) )
- {
- String s1 = getValue( String.class, item );
- String s2 = (String) object;
-
- return s1 != null && s2.equals( s1 );
- }
- else if ( Boolean.class.isInstance( object ) )
- {
- Boolean s1 = getValue( Boolean.class, item );
- Boolean s2 = (Boolean) object;
-
- return s1 != null && s2.equals( s1 );
- }
- else if ( Integer.class.isInstance( object ) )
- {
- Integer s1 = getValue( Integer.class, item );
- Integer s2 = (Integer) object;
-
- return s1 != null && s2.equals( s1 );
- }
- else if ( Float.class.isInstance( object ) )
- {
- Float s1 = getValue( Float.class, item );
- Float s2 = (Float) object;
-
- return s1 != null && s2.equals( s1 );
- }
- else if ( Date.class.isInstance( object ) )
- {
- Date s1 = getValue( Date.class, item );
- Date s2 = (Date) object;
-
- return s1 != null && s2.equals( s1 );
- }
- else if ( Enum.class.isInstance( object ) )
- {
- String s2 = String.valueOf( object );
-
- return item != null && s2.equals( item );
- }
-
- return false;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LikeOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LikeOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LikeOp.java 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.
- */
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class LikeOp extends Op
-{
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( getValue() == null || object == null )
- {
- return OpStatus.EXCLUDE;
- }
-
- if ( String.class.isInstance( object ) )
- {
- String s1 = getValue( String.class );
- String s2 = (String) object;
-
- return (s1 != null && s2.toLowerCase().contains( s1.toLowerCase() )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
-
- return OpStatus.EXCLUDE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LtOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LtOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LtOp.java 1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.Collection;
-import java.util.Date;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class LtOp extends Op
-{
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( getValue() == null || object == null )
- {
- return OpStatus.EXCLUDE;
- }
-
- if ( Integer.class.isInstance( object ) )
- {
- Integer s1 = getValue( Integer.class );
- Integer s2 = (Integer) object;
-
- return (s1 != null && s2 < s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Float.class.isInstance( object ) )
- {
- Float s1 = getValue( Float.class );
- Float s2 = (Float) object;
-
- return (s1 != null && s2 < s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Collection.class.isInstance( object ) )
- {
- Collection<?> collection = (Collection<?>) object;
- Integer size = getValue( Integer.class );
-
- if ( size != null && collection.size() < size )
- {
- return OpStatus.INCLUDE;
- }
- else
- {
- return OpStatus.EXCLUDE;
- }
- }
- else if ( Date.class.isInstance( object ) )
- {
- Date s1 = getValue( Date.class );
- Date s2 = (Date) object;
-
- return (s1 != null && (s2.before( s1 ))) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
-
- return OpStatus.EXCLUDE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LteOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LteOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/LteOp.java 1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.Collection;
-import java.util.Date;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class LteOp extends Op
-{
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( getValue() == null || object == null )
- {
- return OpStatus.EXCLUDE;
- }
-
- if ( Integer.class.isInstance( object ) )
- {
- Integer s1 = getValue( Integer.class );
- Integer s2 = (Integer) object;
-
- return (s1 != null && s2 <= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Float.class.isInstance( object ) )
- {
- Float s1 = getValue( Float.class );
- Float s2 = (Float) object;
-
- return (s1 != null && s2 <= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
- else if ( Collection.class.isInstance( object ) )
- {
- Collection<?> collection = (Collection<?>) object;
- Integer size = getValue( Integer.class );
-
- if ( size != null && collection.size() <= size )
- {
- return OpStatus.INCLUDE;
- }
- else
- {
- return OpStatus.EXCLUDE;
- }
- }
- else if ( Date.class.isInstance( object ) )
- {
- Date s1 = getValue( Date.class );
- Date s2 = (Date) object;
-
- return (s1 != null && (s2.before( s1 ) || s2.equals( s1 ))) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
-
- return OpStatus.EXCLUDE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NLikeOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NLikeOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NLikeOp.java 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.
- */
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class NLikeOp extends Op
-{
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( getValue() == null || object == null )
- {
- return OpStatus.EXCLUDE;
- }
-
- if ( String.class.isInstance( object ) )
- {
- String s1 = getValue( String.class );
- String s2 = (String) object;
-
- return (s1 != null && s2.toLowerCase().contains( s1.toLowerCase() )) ? OpStatus.EXCLUDE : OpStatus.INCLUDE;
- }
-
- return OpStatus.EXCLUDE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NeqOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NeqOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NeqOp.java 1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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 org.hisp.dhis.objectfilter.OpFactory;
-
-/**
-* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
-*/
-public class NeqOp extends Op
-{
- private Op op = OpFactory.create( "eq" );
-
- @Override
- public OpStatus evaluate( Object object )
- {
- op.setValue( getValue() );
- OpStatus status = op.evaluate( object );
-
- switch ( status )
- {
- case INCLUDE:
- return OpStatus.EXCLUDE;
- case EXCLUDE:
- return OpStatus.INCLUDE;
- default:
- return OpStatus.IGNORE;
- }
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NnullOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NnullOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NnullOp.java 1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.
- */
-
-/**
-* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
-*/
-public class NnullOp extends Op
-{
- @Override
- public boolean wantValue()
- {
- return false;
- }
-
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( object != null )
- {
- return OpStatus.INCLUDE;
- }
-
- return OpStatus.EXCLUDE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NullOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NullOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/NullOp.java 1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.
- */
-
-/**
-* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
-*/
-public class NullOp extends Op
-{
- @Override
- public boolean wantValue()
- {
- return false;
- }
-
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( object == null )
- {
- return OpStatus.INCLUDE;
- }
-
- return OpStatus.EXCLUDE;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/Op.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/Op.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/Op.java 1970-01-01 00:00:00 +0000
@@ -1,66 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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 org.hisp.dhis.query.QueryUtils;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public abstract class Op
-{
- private String value;
-
- public boolean wantValue()
- {
- return true;
- }
-
- public void setValue( String value )
- {
- this.value = value;
- }
-
- public String getValue()
- {
- return value;
- }
-
- public <T> T getValue( Class<T> klass )
- {
- return QueryUtils.getValue( klass, value );
- }
-
- public <T> T getValue( Class<T> klass, Object value )
- {
- return QueryUtils.getValue( klass, value );
- }
-
- public abstract OpStatus evaluate( Object object );
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/OpStatus.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/OpStatus.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/OpStatus.java 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.
- */
-
-/**
-* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
-*/
-public enum OpStatus
-{
- INCLUDE, EXCLUDE, IGNORE
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/StartsWithOp.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/StartsWithOp.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/objectfilter/ops/StartsWithOp.java 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
-package org.hisp.dhis.objectfilter.ops;
-
-/*
- * Copyright (c) 2004-2015, 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.
- */
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class StartsWithOp extends Op
-{
- @Override
- public OpStatus evaluate( Object object )
- {
- if ( getValue() == null || object == null )
- {
- return OpStatus.EXCLUDE;
- }
-
- if ( String.class.isInstance( object ) )
- {
- String s1 = getValue( String.class );
- String s2 = (String) object;
-
- return (s1 != null && s2.toLowerCase().startsWith( s1.toLowerCase() )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
- }
-
- return OpStatus.EXCLUDE;
- }
-}
=== removed directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/parser'
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/parser/DefaultParserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/parser/DefaultParserService.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/parser/DefaultParserService.java 1970-01-01 00:00:00 +0000
@@ -1,146 +0,0 @@
-package org.hisp.dhis.parser;
-
-/*
- * Copyright (c) 2004-2015, 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 com.google.common.collect.Lists;
-import org.apache.commons.lang3.StringUtils;
-import org.hisp.dhis.fieldfilter.FieldMap;
-import org.hisp.dhis.objectfilter.Filters;
-
-import java.util.List;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class DefaultParserService implements ParserService
-{
- @Override
- public Filters parseObjectFilter( List<String> filters )
- {
- Filters parsed = new Filters();
-
- for ( String filter : filters )
- {
- String[] split = filter.split( ":" );
-
- if ( !(split.length >= 2) )
- {
- continue;
- }
-
- if ( split.length >= 3 )
- {
- int index = split[0].length() + ":".length() + split[1].length() + ":".length();
- parsed.addFilter( split[0], split[1], filter.substring( index ) );
- }
- else
- {
- parsed.addFilter( split[0], split[1], null );
- }
- }
-
- return parsed;
- }
-
- @Override
- public FieldMap parseFieldFilter( String fields )
- {
- List<String> prefixList = Lists.newArrayList();
- FieldMap fieldMap = new FieldMap();
-
- StringBuilder builder = new StringBuilder();
-
- for ( String c : fields.split( "" ) )
- {
- if ( c.equals( "," ) )
- {
- putInMap( fieldMap, joinedWithPrefix( builder, prefixList ) );
- builder = new StringBuilder();
- continue;
- }
-
- if ( c.equals( "[" ) )
- {
- prefixList.add( builder.toString() );
- builder = new StringBuilder();
- continue;
- }
-
- if ( c.equals( "]" ) )
- {
- if ( !builder.toString().isEmpty() )
- {
- putInMap( fieldMap, joinedWithPrefix( builder, prefixList ) );
- }
-
- prefixList.remove( prefixList.size() - 1 );
- builder = new StringBuilder();
- continue;
- }
-
- if ( StringUtils.isAlpha( c ) || c.equals( "*" ) || c.equals( ":" ) || c.equals( "!" )
- || c.equals( "|" ) || c.equals( "{" ) || c.equals( "}" ) || c.equals( "(" ) || c.equals( ")" ) )
- {
- builder.append( c );
- }
- }
-
- if ( !builder.toString().isEmpty() )
- {
- putInMap( fieldMap, joinedWithPrefix( builder, prefixList ) );
- }
-
- return fieldMap;
- }
-
- private String joinedWithPrefix( StringBuilder builder, List<String> prefixList )
- {
- String prefixes = StringUtils.join( prefixList, "." );
- prefixes = prefixes.isEmpty() ? builder.toString() : (prefixes + "." + builder.toString());
- return prefixes;
- }
-
- private void putInMap( FieldMap fieldMap, String path )
- {
- if ( StringUtils.isEmpty( path ) )
- {
- return;
- }
-
- for ( String p : path.split( "\\." ) )
- {
- if ( fieldMap.get( p ) == null )
- {
- fieldMap.put( p, new FieldMap() );
- }
-
- fieldMap = fieldMap.get( p );
- }
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/parser/ParserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/parser/ParserService.java 2015-09-14 09:13:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/parser/ParserService.java 1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
-package org.hisp.dhis.parser;
-
-/*
- * Copyright (c) 2004-2015, 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 org.hisp.dhis.fieldfilter.FieldMap;
-import org.hisp.dhis.objectfilter.Filters;
-
-import java.util.List;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public interface ParserService
-{
- /**
- * Parses and generates Ops based on filter string, used for object filtering.
- *
- * @param filters One or more filter strings to parse
- * @return Filters object
- */
- Filters parseObjectFilter( List<String> filters );
-
- /**
- * Parses and writes out fieldMap with included/excluded properties.
- *
- * @param filter String to parse, can be used for both inclusion/exclusion
- * @return FieldMap with property name as key, and another FieldMap as value (recursive)
- * @see org.hisp.dhis.fieldfilter.FieldMap
- */
- FieldMap parseFieldFilter( String filter );
-}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/CriteriaQueryEngine.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/CriteriaQueryEngine.java 2015-11-10 07:53:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/CriteriaQueryEngine.java 2015-11-12 04:47:12 +0000
@@ -28,6 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Projections;
@@ -40,6 +42,7 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -51,6 +54,8 @@
*/
public class CriteriaQueryEngine<T extends IdentifiableObject> implements QueryEngine
{
+ private static final Log log = LogFactory.getLog( CriteriaQueryEngine.class );
+
@Autowired
private final List<HibernateGenericStore<T>> hibernateGenericStores = new ArrayList<>();
@@ -120,29 +125,75 @@
private Criteria buildCriteria( Criteria criteria, Query query )
{
- if ( query.getFirstResult() != null )
- {
- criteria.setFirstResult( query.getFirstResult() );
- }
-
- if ( query.getMaxResults() != null )
- {
- criteria.setMaxResults( query.getMaxResults() );
- }
-
- for ( org.hisp.dhis.query.Criterion criterion : query.getCriterions() )
+ List<org.hisp.dhis.query.Criterion> criterions = getCriterions( query );
+
+ for ( org.hisp.dhis.query.Criterion criterion : criterions )
{
addCriterion( criteria, criterion, query.getSchema() );
}
- for ( Order order : query.getOrders() )
+ // no more criterions available, so we can do our own paging
+ if ( query.getCriterions().isEmpty() )
{
- criteria.addOrder( getHibernateOrder( order ) );
+ if ( query.getFirstResult() != null )
+ {
+ criteria.setFirstResult( query.getFirstResult() );
+ }
+
+ if ( query.getMaxResults() != null )
+ {
+ criteria.setMaxResults( query.getMaxResults() );
+ }
+
+ for ( Order order : query.getOrders() )
+ {
+ criteria.addOrder( getHibernateOrder( order ) );
+ }
}
return criteria;
}
+ /**
+ * Remove criterions that can be applied by criteria engine, and return those. The rest of
+ * the criterions will be passed on to the next query engine.
+ *
+ * @param query Query
+ * @return List of usable criterions for this engine
+ */
+ private List<org.hisp.dhis.query.Criterion> getCriterions( Query query )
+ {
+ List<org.hisp.dhis.query.Criterion> criterions = new ArrayList<>();
+
+ Iterator<org.hisp.dhis.query.Criterion> criterionIterator = query.getCriterions().iterator();
+
+ while ( criterionIterator.hasNext() )
+ {
+ org.hisp.dhis.query.Criterion criterion = criterionIterator.next();
+
+ if ( Restriction.class.isInstance( criterion ) )
+ {
+ Restriction restriction = (Restriction) criterion;
+
+ if ( !restriction.getPath().contains( "\\." ) )
+ {
+ if ( query.getSchema().haveProperty( restriction.getPath() ) )
+ {
+ Property property = query.getSchema().getProperty( restriction.getPath() );
+
+ if ( property.isSimple() )
+ {
+ criterions.add( criterion );
+ criterionIterator.remove();
+ }
+ }
+ }
+ }
+ }
+
+ return criterions;
+ }
+
private void addJunction( org.hibernate.criterion.Junction junction, org.hisp.dhis.query.Criterion criterion, Schema schema )
{
if ( Restriction.class.isInstance( criterion ) )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryParser.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryParser.java 2015-11-11 06:19:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryParser.java 2015-11-12 04:47:12 +0000
@@ -106,6 +106,10 @@
{
return Restrictions.eq( path, QueryUtils.getValue( property.getKlass(), arg ) );
}
+ case "!eq":
+ {
+ return Restrictions.ne( path, QueryUtils.getValue( property.getKlass(), arg ) );
+ }
case "ne":
{
return Restrictions.ne( path, QueryUtils.getValue( property.getKlass(), arg ) );
@@ -140,20 +144,70 @@
}
case "like":
{
- return Restrictions.ilike( path, String.valueOf( arg ), MatchMode.ANYWHERE );
+ return Restrictions.like( path, String.valueOf( arg ), MatchMode.ANYWHERE );
+ }
+ case "!like":
+ {
+ return Restrictions.notLike( path, String.valueOf( arg ), MatchMode.ANYWHERE );
+ }
+ case "^like":
+ {
+ return Restrictions.like( path, String.valueOf( arg ), MatchMode.START );
+ }
+ case "!^like":
+ {
+ return Restrictions.notLike( path, String.valueOf( arg ), MatchMode.START );
+ }
+ case "$like":
+ {
+ return Restrictions.like( path, String.valueOf( arg ), MatchMode.END );
+ }
+ case "!$like":
+ {
+ return Restrictions.notLike( path, String.valueOf( arg ), MatchMode.END );
}
case "ilike":
{
return Restrictions.ilike( path, String.valueOf( arg ), MatchMode.ANYWHERE );
}
+ case "!ilike":
+ {
+ return Restrictions.notIlike( path, String.valueOf( arg ), MatchMode.ANYWHERE );
+ }
+ case "startsWith":
+ case "^ilike":
+ {
+ return Restrictions.ilike( path, String.valueOf( arg ), MatchMode.START );
+ }
+ case "!^ilike":
+ {
+ return Restrictions.notIlike( path, String.valueOf( arg ), MatchMode.START );
+ }
+ case "endsWith":
+ case "$ilike":
+ {
+ return Restrictions.ilike( path, String.valueOf( arg ), MatchMode.END );
+ }
+ case "!$ilike":
+ {
+ return Restrictions.notIlike( path, String.valueOf( arg ), MatchMode.END );
+ }
case "in":
{
return Restrictions.in( path, QueryUtils.getValue( Collection.class, arg ) );
}
+ case "!in":
+ {
+ return Restrictions.notIn( path, QueryUtils.getValue( Collection.class, arg ) );
+ }
case "null":
{
return Restrictions.isNull( path );
}
+ case "!null":
+ {
+ return Restrictions.isNotNull( path );
+ }
}
return null;
@@ -163,6 +217,7 @@
{
String[] paths = path.split( "\\." );
Schema currentSchema = schema;
+ Property currentProperty = null;
for ( int i = 0; i < paths.length; i++ )
{
@@ -171,33 +226,28 @@
return null;
}
- Property property = currentSchema.getProperty( paths[i] );
+ currentProperty = currentSchema.getProperty( paths[i] );
- if ( property == null )
+ if ( currentProperty == null )
{
throw new QueryParserException( "Unknown path property: " + paths[i] + " (" + path + ")" );
}
- if ( property.isSimple() )
+ if ( currentProperty.isSimple() && i != (paths.length - 1) )
{
- if ( i != (paths.length - 1) )
- {
- throw new QueryParserException( "Simple type was found before finished parsing path expression, please check your path string." );
- }
-
- return property;
+ throw new QueryParserException( "Simple type was found before finished parsing path expression, please check your path string." );
}
- if ( property.isCollection() )
+ if ( currentProperty.isCollection() )
{
- currentSchema = schemaService.getDynamicSchema( property.getItemKlass() );
+ currentSchema = schemaService.getDynamicSchema( currentProperty.getItemKlass() );
}
else
{
- currentSchema = schemaService.getDynamicSchema( property.getKlass() );
+ currentSchema = schemaService.getDynamicSchema( currentProperty.getKlass() );
}
}
- return null;
+ return currentProperty;
}
}
=== 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 07:23:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java 2015-11-12 04:47:12 +0000
@@ -28,18 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.query.operators.MatchMode;
-import org.hisp.dhis.schema.Property;
-import org.hisp.dhis.schema.Schema;
-import org.hisp.dhis.schema.SchemaService;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
-import java.util.stream.Collectors;
/**
* Default implementation of QueryService which works with IdObjects.
@@ -48,24 +42,29 @@
*/
public class DefaultQueryService implements QueryService
{
+ private static final Log log = LogFactory.getLog( DefaultQueryService.class );
+
+ @Autowired
+ private QueryParser queryParser;
+
@Autowired
private CriteriaQueryEngine<? extends IdentifiableObject> criteriaQueryEngine;
@Autowired
- private SchemaService schemaService;
+ private InMemoryQueryEngine<? extends IdentifiableObject> inMemoryQueryEngine;
@Override
@SuppressWarnings( "unchecked" )
public List<? extends IdentifiableObject> query( Query query )
{
- return criteriaQueryEngine.query( query );
+ return queryObjects( query );
}
@Override
@SuppressWarnings( "unchecked" )
public List<? extends IdentifiableObject> query( Query query, ResultTransformer transformer )
{
- List<? extends IdentifiableObject> objects = criteriaQueryEngine.query( query );
+ List<? extends IdentifiableObject> objects = queryObjects( query );
if ( transformer != null )
{
@@ -78,154 +77,42 @@
@Override
public int count( Query query )
{
- return criteriaQueryEngine.count( query );
+ query.setFirstResult( 0 );
+ query.setMaxResults( Integer.MAX_VALUE );
+
+ return queryObjects( query ).size();
}
@Override
- public Query getQueryFromUrl( Class<?> klass, List<String> filters, List<Order> orders )
+ public Query getQueryFromUrl( Class<?> klass, List<String> filters, List<Order> orders ) throws QueryParserException
{
- Query query = Query.from( schemaService.getDynamicSchema( klass ) );
- query.add( getCriterions( query.getSchema(), filters ) );
+ Query query = queryParser.parse( klass, filters );
query.addOrders( orders );
return query;
}
- //--------------------------------------------------------------------------
- // Helpers
- //--------------------------------------------------------------------------
-
- private List<Criterion> getCriterions( Schema schema, List<String> filters )
- {
- List<Criterion> criterions = new ArrayList<>();
- List<String> candidates = getCandidates( schema, filters );
-
- if ( candidates.isEmpty() )
- {
- return criterions;
- }
-
- criterions.addAll( candidates.stream().map( candidate -> getRestriction( schema, candidate ) ).collect( Collectors.toList() ) );
-
- return criterions;
- }
-
- private List<String> getCandidates( Schema schema, List<String> filters )
- {
- List<String> candidates = new ArrayList<>();
-
- Iterator<String> iterator = filters.iterator();
-
- while ( iterator.hasNext() )
- {
- String candidate = iterator.next();
-
- // if there are no translations available, we can simply map display fields to their real (persisted) fields
- if ( !schema.isTranslated() )
- {
- if ( candidate.startsWith( "displayName" ) && schema.havePersistedProperty( "name" ) )
- {
- candidate = candidate.replace( "displayName:", "name:" );
- }
- else if ( candidate.startsWith( "displayShortName" ) && schema.havePersistedProperty( "shortName" ) )
- {
- candidate = candidate.replace( "displayShortName:", "shortName:" );
- }
- else if ( candidate.startsWith( "displayDescription" ) && schema.havePersistedProperty( "description" ) )
- {
- candidate = candidate.replace( "displayDescription:", "description:" );
- }
- }
-
- if ( !candidate.contains( "." ) && getRestriction( schema, candidate ) != null )
- {
- candidates.add( candidate );
- iterator.remove();
- }
- }
-
- return candidates;
- }
-
- private Restriction getRestriction( Schema schema, String filter )
- {
- if ( filter == null )
- {
- return null;
- }
-
- String[] split = filter.split( ":" );
-
- if ( split.length < 3 )
- {
- return null;
- }
-
- Property property = schema.getProperty( split[0] );
-
- if ( property == null || !property.isPersisted() || !property.isSimple() )
- {
- return null;
- }
-
- String value = filter.substring( split[0].length() + ":".length() + split[1].length() + ":".length() );
-
- switch ( split[1] )
- {
- case "eq":
- {
- return Restrictions.eq( split[0], QueryUtils.getValue( property.getKlass(), value ) );
- }
- case "ne":
- {
- return Restrictions.ne( split[0], QueryUtils.getValue( property.getKlass(), value ) );
- }
- case "neq":
- {
- return Restrictions.ne( split[0], QueryUtils.getValue( property.getKlass(), value ) );
- }
- case "gt":
- {
- return Restrictions.gt( split[0], QueryUtils.getValue( property.getKlass(), value ) );
- }
- case "lt":
- {
- return Restrictions.lt( split[0], QueryUtils.getValue( property.getKlass(), value ) );
- }
- case "gte":
- {
- return Restrictions.ge( split[0], QueryUtils.getValue( property.getKlass(), value ) );
- }
- case "ge":
- {
- return Restrictions.ge( split[0], QueryUtils.getValue( property.getKlass(), value ) );
- }
- case "lte":
- {
- return Restrictions.le( split[0], QueryUtils.getValue( property.getKlass(), value ) );
- }
- case "le":
- {
- return Restrictions.le( split[0], QueryUtils.getValue( property.getKlass(), value ) );
- }
- case "like":
- {
- return Restrictions.ilike( split[0], value, MatchMode.ANYWHERE );
- }
- case "ilike":
- {
- return Restrictions.ilike( split[0], value, MatchMode.ANYWHERE );
- }
- case "in":
- {
- return Restrictions.in( split[0], QueryUtils.getValue( Collection.class, value ) );
- }
- case "null":
- {
- return Restrictions.isNull( split[0] );
- }
- }
-
- return null;
+ //---------------------------------------------------------------------------------------------
+ // Helper methods
+ //---------------------------------------------------------------------------------------------
+
+ private List<? extends IdentifiableObject> queryObjects( Query query )
+ {
+ List<? extends IdentifiableObject> objects = query.getObjects();
+
+ if ( objects == null )
+ {
+ objects = criteriaQueryEngine.query( query );
+
+ if ( query.getCriterions().isEmpty() )
+ {
+ return objects;
+ }
+ }
+
+ log.debug( "Doing in-memory filtering for " + query.getCriterions().size() + " criterions." );
+
+ query.setObjects( objects );
+ return inMemoryQueryEngine.query( query );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/InMemoryQueryEngine.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/InMemoryQueryEngine.java 2015-11-10 06:17:17 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/InMemoryQueryEngine.java 2015-11-12 04:47:12 +0000
@@ -29,6 +29,8 @@
*/
import com.google.common.collect.Lists;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.PagerUtils;
import org.hisp.dhis.schema.Property;
@@ -47,6 +49,8 @@
*/
public class InMemoryQueryEngine<T extends IdentifiableObject> implements QueryEngine
{
+ private static final Log log = LogFactory.getLog( InMemoryQueryEngine.class );
+
@Autowired
private SchemaService schemaService;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java 2015-11-09 05:05:13 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Query.java 2015-11-12 04:47:12 +0000
@@ -30,6 +30,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
+import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.schema.Property;
import org.hisp.dhis.schema.Schema;
@@ -48,7 +49,7 @@
private Integer maxResults = Integer.MAX_VALUE;
- private Collection<?> objects;
+ private List<? extends IdentifiableObject> objects;
public static Query from( Schema schema )
{
@@ -92,12 +93,12 @@
return this;
}
- public Collection<?> getObjects()
+ public List<? extends IdentifiableObject> getObjects()
{
return objects;
}
- public void setObjects( Collection<?> objects )
+ public void setObjects( List<? extends IdentifiableObject> objects )
{
this.objects = objects;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/QueryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/QueryService.java 2015-11-05 03:31:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/QueryService.java 2015-11-12 04:47:12 +0000
@@ -73,5 +73,5 @@
* @param orders List of orders to use for query
* @return New query instance using provided filters/orders
*/
- Query getQueryFromUrl( Class<?> klass, List<String> filters, List<Order> orders );
+ Query getQueryFromUrl( Class<?> klass, List<String> filters, List<Order> orders ) throws QueryParserException;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Restrictions.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Restrictions.java 2015-11-05 06:07:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/Restrictions.java 2015-11-12 04:47:12 +0000
@@ -38,6 +38,8 @@
import org.hisp.dhis.query.operators.LikeOperator;
import org.hisp.dhis.query.operators.MatchMode;
import org.hisp.dhis.query.operators.NotEqualOperator;
+import org.hisp.dhis.query.operators.NotInOperator;
+import org.hisp.dhis.query.operators.NotLikeOperator;
import org.hisp.dhis.query.operators.NotNullOperator;
import org.hisp.dhis.query.operators.NullOperator;
@@ -88,16 +90,31 @@
return new Restriction( path, new LikeOperator( value, true, matchMode ) );
}
+ public static Restriction notLike( String path, String value, MatchMode matchMode )
+ {
+ return new Restriction( path, new NotLikeOperator( value, true, matchMode ) );
+ }
+
public static Restriction ilike( String path, String value, MatchMode matchMode )
{
return new Restriction( path, new LikeOperator( value, false, matchMode ) );
}
+ public static Restriction notIlike( String path, String value, MatchMode matchMode )
+ {
+ return new Restriction( path, new NotLikeOperator( value, false, matchMode ) );
+ }
+
public static Restriction in( String path, Collection<?> values )
{
return new Restriction( path, new InOperator( values ) );
}
+ public static Restriction notIn( String path, Collection<?> values )
+ {
+ return new Restriction( path, new NotInOperator( values ) );
+ }
+
public static Restriction isNull( String path )
{
return new Restriction( path, new NullOperator() );
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotInOperator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotInOperator.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotInOperator.java 2015-11-12 04:47:12 +0000
@@ -0,0 +1,59 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, 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 org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.schema.Property;
+
+import java.util.Collection;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class NotInOperator extends InOperator
+{
+ public NotInOperator( Collection<?> arg )
+ {
+ super( arg );
+ }
+
+ @Override
+ public Criterion getHibernateCriterion( Property property )
+ {
+ return Restrictions.not( super.getHibernateCriterion( property ) );
+ }
+
+ @Override
+ @SuppressWarnings( "unchecked" )
+ public boolean test( Object value )
+ {
+ return !super.test( value );
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotLikeOperator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotLikeOperator.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotLikeOperator.java 2015-11-12 04:47:12 +0000
@@ -0,0 +1,56 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, 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 org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.schema.Property;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class NotLikeOperator extends LikeOperator
+{
+ public NotLikeOperator( String arg, boolean caseSensitive, MatchMode matchMode )
+ {
+ super( arg, caseSensitive, matchMode );
+ }
+
+ @Override
+ public Criterion getHibernateCriterion( Property property )
+ {
+ return Restrictions.not( super.getHibernateCriterion( property ) );
+ }
+
+ @Override
+ public boolean test( Object value )
+ {
+ return !super.test( value );
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2015-11-11 06:20:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2015-11-12 04:47:12 +0000
@@ -33,9 +33,7 @@
<bean id="org.hisp.dhis.node.NodeService" class="org.hisp.dhis.node.DefaultNodeService" />
- <bean id="org.hisp.dhis.parser.ParserService" class="org.hisp.dhis.parser.DefaultParserService" />
-
- <bean id="org.hisp.dhis.objectfilter.ObjectFilterService" class="org.hisp.dhis.objectfilter.DefaultObjectFilterService" />
+ <bean id="org.hisp.dhis.fieldfilter.FieldParser" class="org.hisp.dhis.fieldfilter.DefaultFieldParser" />
<bean id="org.hisp.dhis.fieldfilter.FieldFilterService" class="org.hisp.dhis.fieldfilter.DefaultFieldFilterService" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/CriteriaQueryEngineTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/CriteriaQueryEngineTest.java 2015-11-10 07:53:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/CriteriaQueryEngineTest.java 2015-11-12 04:47:12 +0000
@@ -259,6 +259,23 @@
}
@Test
+ public void testDateRange()
+ {
+ Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+
+ query.add( Restrictions.ge( "created", Year.parseYear( "2002" ).getStart() ) );
+ query.add( Restrictions.le( "created", Year.parseYear( "2004" ).getStart() ) );
+
+ List<? extends IdentifiableObject> objects = queryEngine.query( query );
+
+ assertEquals( 3, objects.size() );
+
+ assertTrue( collectionContainsUid( objects, "deabcdefghB" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghC" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghD" ) );
+ }
+
+ @Test
public void getInQuery()
{
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
@@ -348,6 +365,7 @@
}
@Test
+ @Ignore
public void testDoubleEqConjunction()
{
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
@@ -363,6 +381,7 @@
}
@Test
+ @Ignore
public void testDoubleEqDisjunction()
{
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
@@ -381,23 +400,7 @@
}
@Test
- public void testDateRange()
- {
- Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
-
- query.add( Restrictions.ge( "created", Year.parseYear( "2002" ).getStart() ) );
- query.add( Restrictions.le( "created", Year.parseYear( "2004" ).getStart() ) );
-
- List<? extends IdentifiableObject> objects = queryEngine.query( query );
-
- assertEquals( 3, objects.size() );
-
- assertTrue( collectionContainsUid( objects, "deabcdefghB" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghC" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghD" ) );
- }
-
- @Test
+ @Ignore
public void testDateRangeWithConjunction()
{
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/InMemoryQueryEngineTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/InMemoryQueryEngineTest.java 2015-11-10 07:53:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/InMemoryQueryEngineTest.java 2015-11-12 04:47:12 +0000
@@ -60,9 +60,9 @@
@Autowired
private InMemoryQueryEngine<? extends IdentifiableObject> queryEngine;
- private Collection<DataElement> dataElements = new ArrayList<>();
+ private List<DataElement> dataElements = new ArrayList<>();
- private Collection<DataElementGroup> dataElementGroups = new ArrayList<>();
+ private List<DataElementGroup> dataElementGroups = new ArrayList<>();
@Before
public void createDataElements()
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryParserTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryParserTest.java 2015-11-06 08:31:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryParserTest.java 2015-11-12 04:47:12 +0000
@@ -95,12 +95,6 @@
queryParser.parse( DataElement.class, Arrays.asList( "dataElementGroups.id.name:eq:1", "dataElementGroups.id.abc:eq:2" ) );
}
- @Test( expected = QueryParserException.class )
- public void eqOperatorDeepPathFailNotSimpleType() throws QueryParserException
- {
- queryParser.parse( DataElement.class, Arrays.asList( "dataElementGroups:eq:1", "dataElementGroups:eq:2" ) );
- }
-
@Test
public void nullOperator() throws QueryParserException
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java 2015-11-05 06:07:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java 2015-11-12 04:47:12 +0000
@@ -38,6 +38,8 @@
import org.hisp.dhis.schema.Schema;
import org.hisp.dhis.schema.SchemaService;
import org.jfree.data.time.Year;
+import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -62,7 +64,8 @@
@Autowired
private IdentifiableObjectManager identifiableObjectManager;
- private void createDataElements()
+ @Before
+ public void createDataElements()
{
DataElement dataElementA = createDataElement( 'A' );
dataElementA.setValueType( ValueType.NUMBER );
@@ -113,15 +116,13 @@
@Test
public void getAllQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
assertEquals( 6, queryService.query( query ).size() );
}
@Test
- public void getAllQueryUrl()
+ public void getAllQueryUrl() throws QueryParserException
{
- createDataElements();
Query query = queryService.getQueryFromUrl( DataElement.class, Lists.<String>newArrayList(), Lists.<Order>newArrayList() );
assertEquals( 6, queryService.query( query ).size() );
}
@@ -129,7 +130,6 @@
@Test
public void getMinMaxQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.setFirstResult( 2 );
query.setMaxResults( 10 );
@@ -146,7 +146,6 @@
@Test
public void getEqQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.eq( "id", "deabcdefghA" ) );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -156,9 +155,8 @@
}
@Test
- public void getEqQueryUrl()
+ public void getEqQueryUrl() throws QueryParserException
{
- createDataElements();
Query query = queryService.getQueryFromUrl( DataElement.class, Lists.newArrayList( "id:eq:deabcdefghA" ), Lists.<Order>newArrayList() );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -169,7 +167,6 @@
@Test
public void getNeQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.ne( "id", "deabcdefghA" ) );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -185,9 +182,8 @@
}
@Test
- public void getNeQueryUrl()
+ public void getNeQueryUrl() throws QueryParserException
{
- createDataElements();
Query query = queryService.getQueryFromUrl( DataElement.class, Lists.newArrayList( "id:ne:deabcdefghA" ), Lists.<Order>newArrayList() );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -204,7 +200,6 @@
@Test
public void getLikeQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.like( "name", "F", MatchMode.ANYWHERE ) );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -214,9 +209,8 @@
}
@Test
- public void getLikeQueryUrl()
+ public void getLikeQueryUrl() throws QueryParserException
{
- createDataElements();
Query query = queryService.getQueryFromUrl( DataElement.class, Lists.newArrayList( "name:like:F" ), Lists.<Order>newArrayList() );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -227,7 +221,6 @@
@Test
public void getGtQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.gt( "created", Year.parseYear( "2003" ).getStart() ) );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -240,9 +233,8 @@
}
@Test
- public void getGtQueryUrl()
+ public void getGtQueryUrl() throws QueryParserException
{
- createDataElements();
Query query = queryService.getQueryFromUrl( DataElement.class, Lists.newArrayList( "created:gt:2003" ), Lists.<Order>newArrayList() );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -256,7 +248,6 @@
@Test
public void getLtQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.lt( "created", Year.parseYear( "2003" ).getStart() ) );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -268,9 +259,8 @@
}
@Test
- public void getLtQueryUrl()
+ public void getLtQueryUrl() throws QueryParserException
{
- createDataElements();
Query query = queryService.getQueryFromUrl( DataElement.class, Lists.newArrayList( "created:lt:2003" ), Lists.<Order>newArrayList() );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -283,7 +273,6 @@
@Test
public void getGeQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.ge( "created", Year.parseYear( "2003" ).getStart() ) );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -297,9 +286,8 @@
}
@Test
- public void getGeQueryUrl()
+ public void getGeQueryUrl() throws QueryParserException
{
- createDataElements();
Query query = queryService.getQueryFromUrl( DataElement.class, Lists.newArrayList( "created:ge:2003" ), Lists.<Order>newArrayList() );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -314,7 +302,6 @@
@Test
public void getLeQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.le( "created", Year.parseYear( "2003" ).getStart() ) );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -327,9 +314,8 @@
}
@Test
- public void getLeQueryUrl()
+ public void getLeQueryUrl() throws QueryParserException
{
- createDataElements();
Query query = queryService.getQueryFromUrl( DataElement.class, Lists.newArrayList( "created:le:2003" ), Lists.<Order>newArrayList() );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -343,7 +329,6 @@
@Test
public void getBetweenQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.between( "created", Year.parseYear( "2003" ).getStart(), Year.parseYear( "2005" ).getStart() ) );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -358,7 +343,6 @@
@Test
public void getInQuery()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.in( "id", Lists.newArrayList( "deabcdefghD", "deabcdefghF" ) ) );
List<? extends IdentifiableObject> objects = queryService.query( query );
@@ -372,7 +356,6 @@
@Test
public void resultTransformerTest()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
List<? extends IdentifiableObject> objects = queryService.query( query, result1 -> new ArrayList() );
@@ -385,7 +368,6 @@
@Test
public void sortNameDesc()
{
- createDataElements();
Schema schema = schemaService.getDynamicSchema( DataElement.class );
Query query = Query.from( schema );
@@ -405,7 +387,6 @@
@Test
public void sortNameAsc()
{
- createDataElements();
Schema schema = schemaService.getDynamicSchema( DataElement.class );
Query query = Query.from( schema );
@@ -425,7 +406,6 @@
@Test
public void sortCreatedDesc()
{
- createDataElements();
Schema schema = schemaService.getDynamicSchema( DataElement.class );
Query query = Query.from( schema );
@@ -445,7 +425,6 @@
@Test
public void sortCreatedAsc()
{
- createDataElements();
Schema schema = schemaService.getDynamicSchema( DataElement.class );
Query query = Query.from( schema );
@@ -465,7 +444,6 @@
@Test
public void testDoubleEqConjunction()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
Conjunction conjunction = query.conjunction();
@@ -481,7 +459,6 @@
@Test
public void testDoubleEqDisjunction()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
Disjunction disjunction = query.disjunction();
@@ -500,7 +477,6 @@
@Test
public void testDateRange()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.ge( "created", Year.parseYear( "2002" ).getStart() ) );
@@ -518,7 +494,6 @@
@Test
public void testDateRangeWithConjunction()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
Conjunction conjunction = query.conjunction();
@@ -538,7 +513,6 @@
@Test
public void testIsNull()
{
- createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
query.add( Restrictions.isNull( "categoryCombo" ) );
@@ -555,9 +529,8 @@
}
@Test
- public void testIsNullUrl()
+ public void testIsNullUrl() throws QueryParserException
{
- createDataElements();
Query query = queryService.getQueryFromUrl( DataElement.class, Lists.newArrayList( "categoryCombo:null" ), Lists.<Order>newArrayList() );
List<? extends IdentifiableObject> objects = queryService.query( query );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2015-11-04 03:03:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2015-11-12 04:47:12 +0000
@@ -64,9 +64,9 @@
import org.hisp.dhis.node.types.ComplexNode;
import org.hisp.dhis.node.types.RootNode;
import org.hisp.dhis.node.types.SimpleNode;
-import org.hisp.dhis.objectfilter.ObjectFilterService;
import org.hisp.dhis.query.Order;
import org.hisp.dhis.query.Query;
+import org.hisp.dhis.query.QueryParserException;
import org.hisp.dhis.query.QueryService;
import org.hisp.dhis.schema.Property;
import org.hisp.dhis.schema.Schema;
@@ -121,9 +121,6 @@
protected CurrentUserService currentUserService;
@Autowired
- protected ObjectFilterService objectFilterService;
-
- @Autowired
protected FieldFilterService fieldFilterService;
@Autowired
@@ -161,7 +158,7 @@
public @ResponseBody RootNode getObjectList(
@RequestParam Map<String, String> rpParameters,
TranslateParams translateParams, OrderOptions orderOptions,
- HttpServletResponse response, HttpServletRequest request )
+ HttpServletResponse response, HttpServletRequest request ) throws QueryParserException
{
List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
List<String> filters = Lists.newArrayList( contextService.getParameterValues( "filter" ) );
@@ -181,11 +178,9 @@
}
List<T> entities = getEntityList( metaData, options, filters, orders );
+ translate( entities, translateParams );
Pager pager = metaData.getPager();
- entities = objectFilterService.filter( entities, filters );
- translate( entities, translateParams );
-
if ( options.hasPaging() && pager == null )
{
pager = new Pager( options.getPage(), entities.size(), options.getPageSize() );
@@ -415,6 +410,7 @@
}
}
+ @SuppressWarnings( "unchecked" )
private RootNode getObjectInternal( String uid, Map<String, String> parameters,
List<String> filters, List<String> fields, TranslateParams translateParams ) throws Exception
{
@@ -431,7 +427,10 @@
throw new WebMessageException( WebMessageUtils.notFound( getEntityClass(), uid ) );
}
- entities = objectFilterService.filter( entities, filters );
+ Query query = queryService.getQueryFromUrl( getEntityClass(), filters, new ArrayList<>() );
+ query.setObjects( entities );
+
+ entities = (List<T>) queryService.query( query );
if ( options.hasLinks() )
{
@@ -868,10 +867,9 @@
//--------------------------------------------------------------------------
@SuppressWarnings( "unchecked" )
- protected List<T> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
+ protected List<T> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders ) throws QueryParserException
{
List<T> entityList;
- boolean haveFilters = !filters.isEmpty();
Query query = queryService.getQueryFromUrl( getEntityClass(), filters, orders );
query.setDefaultOrder();
@@ -879,17 +877,6 @@
{
entityList = Lists.newArrayList( manager.filter( getEntityClass(), options.getOptions().get( "query" ) ) );
}
- else if ( options.hasPaging() && !haveFilters )
- {
- int count = queryService.count( query );
-
- Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
- metaData.setPager( pager );
-
- query.setFirstResult( pager.getOffset() );
- query.setMaxResults( pager.getPageSize() );
- entityList = (List<T>) queryService.query( query );
- }
else
{
entityList = (List<T>) queryService.query( query );
@@ -898,7 +885,7 @@
return entityList;
}
- private final List<T> getEntity( String uid )
+ private List<T> getEntity( String uid )
{
return getEntity( uid, new WebOptions( new HashMap<>() ) );
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CrudControllerAdvice.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CrudControllerAdvice.java 2015-10-20 19:03:27 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CrudControllerAdvice.java 2015-11-12 04:47:12 +0000
@@ -36,6 +36,8 @@
import org.hisp.dhis.dataapproval.exceptions.DataApprovalException;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.dxf2.webmessage.WebMessageStatus;
+import org.hisp.dhis.query.QueryException;
+import org.hisp.dhis.query.QueryParserException;
import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException;
import org.hisp.dhis.webapi.controller.exception.NotFoundException;
@@ -126,7 +128,13 @@
}
@ExceptionHandler( JsonParseException.class )
- public void jsonParseExceptionHandler( JsonParseException ex, HttpServletResponse response, HttpServletRequest request )
+ public void jsonParseExceptionHandler( Exception ex, HttpServletResponse response, HttpServletRequest request )
+ {
+ webMessageService.send( WebMessageUtils.conflict( ex.getMessage() ), response, request );
+ }
+
+ @ExceptionHandler( { QueryParserException.class, QueryException.class } )
+ public void queryExceptionHandler( Exception ex, HttpServletResponse response, HttpServletRequest request )
{
webMessageService.send( WebMessageUtils.conflict( ex.getMessage() ), response, request );
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2015-08-19 05:48:15 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2015-11-12 04:47:12 +0000
@@ -33,7 +33,6 @@
import org.hisp.dhis.common.DimensionalObject;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.common.NameableObject;
-import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dxf2.common.TranslateParams;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
@@ -43,6 +42,8 @@
import org.hisp.dhis.node.types.CollectionNode;
import org.hisp.dhis.node.types.RootNode;
import org.hisp.dhis.query.Order;
+import org.hisp.dhis.query.Query;
+import org.hisp.dhis.query.QueryParserException;
import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.hisp.dhis.webapi.webdomain.WebMetaData;
import org.hisp.dhis.webapi.webdomain.WebOptions;
@@ -58,7 +59,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -100,7 +100,7 @@
@RequestMapping( value = "/{uid}/items", method = RequestMethod.GET )
public @ResponseBody RootNode getItems( @PathVariable String uid, @RequestParam Map<String, String> parameters,
- TranslateParams translateParams, Model model, HttpServletRequest request, HttpServletResponse response )
+ TranslateParams translateParams, Model model, HttpServletRequest request, HttpServletResponse response ) throws QueryParserException
{
List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
List<String> filters = Lists.newArrayList( contextService.getParameterValues( "filter" ) );
@@ -111,8 +111,9 @@
}
List<NameableObject> items = dimensionService.getCanReadDimensionItems( uid );
- items = objectFilterService.filter( items, filters );
- Collections.sort( items, IdentifiableObjectNameComparator.INSTANCE );
+ Query query = queryService.getQueryFromUrl( getEntityClass(), filters, new ArrayList<>() );
+ query.setObjects( items );
+ query.setDefaultOrder();
translate( items, translateParams );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java 2015-11-04 03:03:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java 2015-11-12 04:47:12 +0000
@@ -29,7 +29,6 @@
*/
import com.google.common.collect.Lists;
-import org.hisp.dhis.common.Pager;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
@@ -37,6 +36,7 @@
import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.query.Order;
import org.hisp.dhis.query.Query;
+import org.hisp.dhis.query.QueryParserException;
import org.hisp.dhis.schema.descriptors.ProgramSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
import org.hisp.dhis.webapi.webdomain.WebMetaData;
@@ -79,12 +79,11 @@
@Override
@SuppressWarnings( "unchecked" )
- protected List<Program> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
+ protected List<Program> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders ) throws QueryParserException
{
Boolean userFilter = Boolean.parseBoolean( options.getOptions().get( "userFilter" ) );
List<Program> entityList;
- boolean haveFilters = !filters.isEmpty();
Query query = queryService.getQueryFromUrl( getEntityClass(), filters, orders );
query.setDefaultOrder();
@@ -92,17 +91,6 @@
{
entityList = Lists.newArrayList( manager.filter( getEntityClass(), options.getOptions().get( "query" ) ) );
}
- else if ( options.hasPaging() && !haveFilters )
- {
- int count = queryService.count( query );
-
- Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
- metaData.setPager( pager );
-
- query.setFirstResult( pager.getOffset() );
- query.setMaxResults( pager.getPageSize() );
- entityList = (List<Program>) queryService.query( query );
- }
else
{
entityList = (List<Program>) queryService.query( query );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java 2015-11-04 03:03:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java 2015-11-12 04:47:12 +0000
@@ -29,12 +29,12 @@
*/
import com.google.common.collect.Lists;
-import org.hisp.dhis.common.Pager;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.query.Order;
import org.hisp.dhis.query.Query;
+import org.hisp.dhis.query.QueryParserException;
import org.hisp.dhis.schema.descriptors.ProgramStageSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
import org.hisp.dhis.webapi.webdomain.WebMetaData;
@@ -64,10 +64,9 @@
@Override
@SuppressWarnings( "unchecked" )
- protected List<ProgramStage> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
+ protected List<ProgramStage> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders ) throws QueryParserException
{
List<ProgramStage> entityList = new ArrayList<>();
- boolean haveFilters = !filters.isEmpty();
Query query = queryService.getQueryFromUrl( getEntityClass(), filters, orders );
query.setDefaultOrder();
@@ -85,17 +84,6 @@
entityList = new ArrayList<>( program.getProgramStages() );
}
}
- else if ( options.hasPaging() && !haveFilters )
- {
- int count = queryService.count( query );
-
- Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
- metaData.setPager( pager );
-
- query.setFirstResult( pager.getOffset() );
- query.setMaxResults( pager.getPageSize() );
- entityList = (List<ProgramStage>) queryService.query( query );
- }
else
{
entityList = (List<ProgramStage>) queryService.query( query );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java 2015-11-04 03:03:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java 2015-11-12 04:47:12 +0000
@@ -31,7 +31,6 @@
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.google.common.collect.Lists;
-import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dxf2.common.TranslateParams;
import org.hisp.dhis.organisationunit.FeatureType;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -40,6 +39,7 @@
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitByLevelComparator;
import org.hisp.dhis.query.Order;
import org.hisp.dhis.query.Query;
+import org.hisp.dhis.query.QueryParserException;
import org.hisp.dhis.schema.descriptors.OrganisationUnitSchemaDescriptor;
import org.hisp.dhis.user.User;
import org.hisp.dhis.util.ObjectUtils;
@@ -80,10 +80,9 @@
@Override
@SuppressWarnings( "unchecked" )
- protected List<OrganisationUnit> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
+ protected List<OrganisationUnit> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders ) throws QueryParserException
{
List<OrganisationUnit> entityList;
- boolean hasFilters = !filters.isEmpty();
Query query = queryService.getQueryFromUrl( getEntityClass(), filters, orders );
query.setDefaultOrder();
@@ -125,17 +124,6 @@
entityList = new ArrayList<>( manager.getAll( getEntityClass() ) );
Collections.sort( entityList, OrganisationUnitByLevelComparator.INSTANCE );
}
- else if ( options.hasPaging() && !hasFilters )
- {
- int count = queryService.count( query );
-
- Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
- metaData.setPager( pager );
-
- query.setFirstResult( pager.getOffset() );
- query.setMaxResults( pager.getPageSize() );
- entityList = (List<OrganisationUnit>) queryService.query( query );
- }
else
{
entityList = (List<OrganisationUnit>) queryService.query( query );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java 2015-07-08 08:31:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java 2015-11-12 04:47:12 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException;
import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
import org.hisp.dhis.query.Order;
+import org.hisp.dhis.query.QueryParserException;
import org.hisp.dhis.schema.descriptors.UserRoleSchemaDescriptor;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserAuthorityGroup;
@@ -61,7 +62,7 @@
private UserService userService;
@Override
- protected List<UserAuthorityGroup> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
+ protected List<UserAuthorityGroup> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders ) throws QueryParserException
{
List<UserAuthorityGroup> entityList = super.getEntityList( metaData, options, filters, orders );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/validation/ValidationRuleController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/validation/ValidationRuleController.java 2015-02-20 09:14:02 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/validation/ValidationRuleController.java 2015-11-12 04:47:12 +0000
@@ -28,11 +28,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.List;
-
+import com.google.common.collect.Lists;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.query.Order;
+import org.hisp.dhis.query.QueryParserException;
import org.hisp.dhis.schema.descriptors.ValidationRuleSchemaDescriptor;
import org.hisp.dhis.validation.ValidationRule;
import org.hisp.dhis.validation.ValidationRuleService;
@@ -43,7 +43,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
-import com.google.common.collect.Lists;
+import java.util.List;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -55,25 +55,25 @@
{
@Autowired
private DataSetService dataSetService;
-
+
@Autowired
private ValidationRuleService validationRuleService;
-
+
@Override
- protected List<ValidationRule> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
+ protected List<ValidationRule> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders ) throws QueryParserException
{
if ( options.contains( "dataSet" ) )
- {
+ {
DataSet ds = dataSetService.getDataSet( options.get( "dataSet" ) );
-
+
if ( ds == null )
{
return null;
}
-
+
return Lists.newArrayList( validationRuleService.getValidationRulesByDataElements( ds.getDataElements() ) );
}
-
+
return super.getEntityList( metaData, options, filters, orders );
}
}