dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33971
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17411: don't use name:like:abc optimization in web-api filtering if field is not persisted
------------------------------------------------------------
revno: 17411
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-11-11 09:55:15 +0545
message:
don't use name:like:abc optimization in web-api filtering if field is not persisted
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.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/schema/Schema.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java 2014-09-30 07:02:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java 2014-11-11 04:10:15 +0000
@@ -47,7 +47,7 @@
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
-@JacksonXmlRootElement( localName = "schema", namespace = DxfNamespaces.DXF_2_0 )
+@JacksonXmlRootElement(localName = "schema", namespace = DxfNamespaces.DXF_2_0)
public class Schema implements Ordered
{
/**
@@ -150,7 +150,7 @@
}
@JsonProperty
- @JacksonXmlProperty( isAttribute = true )
+ @JacksonXmlProperty(isAttribute = true)
public Class<?> getKlass()
{
return klass;
@@ -162,21 +162,21 @@
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isIdentifiableObject()
{
return identifiableObject;
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isNameableObject()
{
return nameableObject;
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getSingular()
{
return singular;
@@ -188,7 +188,7 @@
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getPlural()
{
return plural;
@@ -200,7 +200,7 @@
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getNamespace()
{
return namespace;
@@ -212,7 +212,7 @@
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getCollectionName()
{
return collectionName == null ? plural : collectionName;
@@ -224,7 +224,7 @@
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getName()
{
return name == null ? singular : name;
@@ -236,7 +236,7 @@
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getDisplayName()
{
return displayName != null ? displayName : getName();
@@ -248,7 +248,7 @@
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isShareable()
{
return shareable;
@@ -260,7 +260,7 @@
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getApiEndpoint()
{
return apiEndpoint;
@@ -277,7 +277,7 @@
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isMetadata()
{
return metadata;
@@ -289,7 +289,7 @@
}
@JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public boolean isPersisted()
{
return persisted;
@@ -301,8 +301,8 @@
}
@JsonProperty
- @JacksonXmlElementWrapper( localName = "authorities", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "authority", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlElementWrapper(localName = "authorities", namespace = DxfNamespaces.DXF_2_0)
+ @JacksonXmlProperty(localName = "authority", namespace = DxfNamespaces.DXF_2_0)
public List<Authority> getAuthorities()
{
return authorities;
@@ -314,8 +314,8 @@
}
@JsonProperty
- @JacksonXmlElementWrapper( localName = "properties", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "property", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlElementWrapper(localName = "properties", namespace = DxfNamespaces.DXF_2_0)
+ @JacksonXmlProperty(localName = "property", namespace = DxfNamespaces.DXF_2_0)
public List<Property> getProperties()
{
return Lists.newArrayList( propertyMap.values() );
@@ -332,6 +332,17 @@
this.propertyMap = propertyMap;
}
+ @JsonIgnore
+ public Property getProperty( String name )
+ {
+ if ( propertyMap.containsKey( name ) )
+ {
+ return propertyMap.get( name );
+ }
+
+ return null;
+ }
+
private Map<AuthorityType, List<String>> authorityMap = Maps.newHashMap();
public List<String> getAuthorityByType( AuthorityType type )
=== 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 2014-11-07 18:23:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-11-11 04:10:15 +0000
@@ -129,7 +129,7 @@
//--------------------------------------------------------------------------
@RequestMapping( method = RequestMethod.GET )
- public @ResponseBody RootNode getObjectList( @RequestParam Map<String, String> parameters,
+ public @ResponseBody RootNode getObjectList( @RequestParam Map<String, String> parameters,
HttpServletResponse response, HttpServletRequest request )
{
List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
@@ -138,6 +138,8 @@
WebOptions options = new WebOptions( parameters );
WebMetaData metaData = new WebMetaData();
+ Schema schema = getSchema();
+
if ( fields.isEmpty() )
{
fields.add( ":identifiable" );
@@ -156,15 +158,18 @@
Iterator<String> iterator = filters.iterator();
String name = null;
- while ( iterator.hasNext() )
+ if ( schema.getProperty( "name" ) != null && schema.getProperty( "name" ).isPersisted() )
{
- String filter = iterator.next();
-
- if ( filter.startsWith( "name:like:" ) )
+ while ( iterator.hasNext() )
{
- name = filter.substring( "name:like:".length() );
- iterator.remove();
- break;
+ String filter = iterator.next();
+
+ if ( filter.startsWith( "name:like:" ) )
+ {
+ name = filter.substring( "name:like:".length() );
+ iterator.remove();
+ break;
+ }
}
}
@@ -334,7 +339,7 @@
//--------------------------------------------------------------------------
@RequestMapping( method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
- public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input )
+ public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input )
throws Exception
{
if ( !aclService.canCreate( currentUserService.getCurrentUser(), getEntityClass() ) )
@@ -363,7 +368,7 @@
}
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input )
+ public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input )
throws Exception
{
if ( !aclService.canCreate( currentUserService.getCurrentUser(), getEntityClass() ) )
@@ -396,7 +401,7 @@
//--------------------------------------------------------------------------
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE } )
- public void putXmlObject( HttpServletResponse response, HttpServletRequest request,
+ public void putXmlObject( HttpServletResponse response, HttpServletRequest request,
@PathVariable( "uid" ) String uid, InputStream input ) throws Exception
{
List<T> objects = getEntity( uid );
@@ -428,7 +433,7 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request,
+ public void putJsonObject( HttpServletResponse response, HttpServletRequest request,
@PathVariable( "uid" ) String uid, InputStream input ) throws Exception
{
List<T> objects = getEntity( uid );
@@ -464,7 +469,7 @@
//--------------------------------------------------------------------------
@RequestMapping( value = "/{uid}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request,
+ public void deleteObject( HttpServletResponse response, HttpServletRequest request,
@PathVariable( "uid" ) String uid ) throws Exception
{
List<T> objects = getEntity( uid );