dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40000
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20248: web-api filter optimization, if filtering by display* field and there are no translations availab...
------------------------------------------------------------
revno: 20248
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-21 16:17:44 +0700
message:
web-api filter optimization, if filtering by display* field and there are no translations available, map to their persisted version
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java 2015-06-15 04:43:40 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java 2015-09-21 09:17:44 +0000
@@ -39,6 +39,7 @@
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.
@@ -103,10 +104,7 @@
return criterions;
}
- for ( String candidate : candidates )
- {
- criterions.add( getRestriction( schema, candidate ) );
- }
+ criterions.addAll( candidates.stream().map( candidate -> getRestriction( schema, candidate ) ).collect( Collectors.toList() ) );
return criterions;
}
@@ -121,6 +119,23 @@
{
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 );