=== 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 */ -@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 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 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> authorityMap = Maps.newHashMap(); public List 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 parameters, + public @ResponseBody RootNode getObjectList( @RequestParam Map parameters, HttpServletResponse response, HttpServletRequest request ) { List 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 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 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 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 objects = getEntity( uid );