=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFieldFilterService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFieldFilterService.java 2014-06-17 15:28:24 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFieldFilterService.java 2014-06-19 10:51:49 +0000 @@ -31,7 +31,6 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.node.types.CollectionNode; @@ -45,7 +44,6 @@ import java.util.Collection; import java.util.List; -import java.util.Map; /** * @author Morten Olav Hansen @@ -76,19 +74,19 @@ Schema rootSchema = schemaService.getDynamicSchema( klass ); - Map fieldMap = Maps.newHashMap(); + FieldMap fieldMap = new FieldMap(); Schema schema = schemaService.getDynamicSchema( objects.get( 0 ).getClass() ); if ( fields == null ) { for ( Property property : schema.getProperties() ) { - fieldMap.put( property.getName(), Maps.newHashMap() ); + fieldMap.put( property.getName(), new FieldMap() ); } } else { - fieldMap = parserService.parsePropertyFilter( fields ); + fieldMap = parserService.parseFieldFilter( fields ); } CollectionNode collectionNode = new CollectionNode( rootSchema.getCollectionName() ); @@ -103,7 +101,7 @@ } @SuppressWarnings( "unchecked" ) - private ComplexNode buildComplexNode( Map fieldMap, Class klass, Object object ) + private ComplexNode buildComplexNode( FieldMap fieldMap, Class klass, Object object ) { Schema schema = schemaService.getDynamicSchema( klass ); @@ -129,7 +127,7 @@ Object returnValue = ReflectionUtils.invokeMethod( object, property.getGetterMethod() ); Schema propertySchema = schemaService.getDynamicSchema( property.getKlass() ); - Map fieldValue = fieldMap.get( fieldKey ); + FieldMap fieldValue = fieldMap.get( fieldKey ); if ( property.isCollection() ) { @@ -160,7 +158,7 @@ } else if ( !property.isSimple() ) { - Map map = getFullFieldMap( schemaService.getDynamicSchema( property.getItemKlass() ) ); + FieldMap map = getFullFieldMap( schemaService.getDynamicSchema( property.getItemKlass() ) ); for ( Object collectionObject : collection ) { @@ -233,14 +231,14 @@ return complexNode; } - private void updateFields( Map fieldMap, Class klass ) + private void updateFields( FieldMap fieldMap, Class klass ) { // we need two run this (at least) two times, since some of the presets might contain other presets _updateFields( fieldMap, klass, true ); _updateFields( fieldMap, klass, false ); } - private void _updateFields( Map fieldMap, Class klass, boolean expandOnly ) + private void _updateFields( FieldMap fieldMap, Class klass, boolean expandOnly ) { Schema schema = schemaService.getDynamicSchema( klass ); List cleanupFields = Lists.newArrayList(); @@ -253,7 +251,7 @@ { if ( !fieldMap.containsKey( mapKey ) ) { - fieldMap.put( mapKey, Maps.newHashMap() ); + fieldMap.put( mapKey, new FieldMap() ); } } @@ -272,7 +270,7 @@ { if ( !fieldMap.containsKey( field ) ) { - fieldMap.put( field, Maps.newHashMap() ); + fieldMap.put( field, new FieldMap() ); } } @@ -295,16 +293,16 @@ } } - private Map getFullFieldMap( Schema schema ) + private FieldMap getFullFieldMap( Schema schema ) { - Map map = Maps.newHashMap(); + FieldMap fieldMap = new FieldMap(); for ( String mapKey : schema.getPropertyMap().keySet() ) { - map.put( mapKey, Maps.newHashMap() ); + fieldMap.put( mapKey, new FieldMap() ); } - return map; + return fieldMap; } private ComplexNode getProperties( Property currentProperty, Object object, List fields ) === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultParserService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultParserService.java 2014-06-09 10:26:26 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultParserService.java 2014-06-19 10:51:49 +0000 @@ -29,11 +29,9 @@ */ import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import java.util.List; -import java.util.Map; /** * @author Morten Olav Hansen @@ -68,10 +66,10 @@ } @Override - public Map parsePropertyFilter( String fields ) + public FieldMap parseFieldFilter( String fields ) { List prefixList = Lists.newArrayList(); - Map parsed = Maps.newHashMap(); + FieldMap fieldMap = new FieldMap(); StringBuilder builder = new StringBuilder(); @@ -79,7 +77,7 @@ { if ( c.equals( "," ) ) { - putInMap( parsed, joinedWithPrefix( builder, prefixList ) ); + putInMap( fieldMap, joinedWithPrefix( builder, prefixList ) ); builder = new StringBuilder(); continue; } @@ -95,7 +93,7 @@ { if ( !builder.toString().isEmpty() ) { - putInMap( parsed, joinedWithPrefix( builder, prefixList ) ); + putInMap( fieldMap, joinedWithPrefix( builder, prefixList ) ); } prefixList.remove( prefixList.size() - 1 ); @@ -111,10 +109,10 @@ if ( !builder.toString().isEmpty() ) { - putInMap( parsed, joinedWithPrefix( builder, prefixList ) ); + putInMap( fieldMap, joinedWithPrefix( builder, prefixList ) ); } - return parsed; + return fieldMap; } private String joinedWithPrefix( StringBuilder builder, List prefixList ) @@ -125,7 +123,7 @@ } @SuppressWarnings( "unchecked" ) - private void putInMap( Map map, String path ) + private void putInMap( FieldMap fieldMap, String path ) { if ( StringUtils.isEmpty( path ) ) { @@ -134,12 +132,12 @@ for ( String p : path.split( "\\." ) ) { - if ( map.get( p ) == null ) + if ( fieldMap.get( p ) == null ) { - map.put( p, Maps.newHashMap() ); + fieldMap.put( p, new FieldMap() ); } - map = map.get( p ); + fieldMap = fieldMap.get( p ); } } } === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/FieldMap.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/FieldMap.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/FieldMap.java 2014-06-19 10:51:49 +0000 @@ -0,0 +1,48 @@ +package org.hisp.dhis.dxf2.filter; + +/* + * Copyright (c) 2004-2014, 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.ForwardingMap; +import com.google.common.collect.Maps; + +import java.util.Map; + +/** + * @author Morten Olav Hansen + */ +public class FieldMap extends ForwardingMap +{ + private final Map delegate = Maps.newHashMap(); + + @Override + protected Map delegate() + { + return delegate; + } +} === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/ParserService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/ParserService.java 2014-04-14 06:43:16 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/ParserService.java 2014-06-19 10:51:49 +0000 @@ -29,7 +29,6 @@ */ import java.util.List; -import java.util.Map; /** * @author Morten Olav Hansen @@ -45,10 +44,11 @@ Filters parseObjectFilter( List filters ); /** - * Parses and writes out map with included/excluded properties. + * Parses and writes out fieldMap with included/excluded properties. * * @param filter String to parse, can be used for both inclusion/exclusion - * @return Map with property name as key, and another map as value (recursive) + * @return FieldMap with property name as key, and another FieldMap as value (recursive) + * @see org.hisp.dhis.dxf2.filter.FieldMap */ - Map parsePropertyFilter( String filter ); + FieldMap parseFieldFilter( String filter ); }