=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java 2014-08-15 07:40:20 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java 2014-11-11 12:24:42 +0000 @@ -28,12 +28,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Map; - +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; import org.hisp.dhis.common.view.BasicView; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.DimensionalView; @@ -45,15 +48,11 @@ import org.hisp.dhis.common.view.UuidView; import org.hisp.dhis.common.view.WithoutOrganisationUnitsView; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; /** * @author Morten Olav Hansen @@ -110,12 +109,7 @@ viewClasses.put( "withoutOrganisationUnits", WithoutOrganisationUnitsView.class ); } - public static boolean isSharingView( String view ) - { - return view.equals( "sharing" ) || view.equals( "sharingBasic" ) || view.equals( "sharingDetailed" ) - || view.equals( "sharingExport" ); - } - + @Deprecated public static Class getViewClass( Object viewName ) { if ( viewName == null || !(viewName instanceof String && ((String) viewName).length() != 0) ) @@ -154,23 +148,25 @@ return jsonMapper.writeValueAsString( value ); } + @Deprecated public static void toJsonWithView( OutputStream output, Object value, Class viewClass ) throws IOException { jsonMapper.writerWithView( viewClass ).writeValue( output, value ); } + @Deprecated public static String toJsonWithViewAsString( Object value, Class viewClass ) throws IOException { return jsonMapper.writerWithView( viewClass ).writeValueAsString( value ); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public static T fromJson( InputStream input, Class clazz ) throws IOException { return (T) jsonMapper.readValue( input, clazz ); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public static T fromJson( String input, Class clazz ) throws IOException { return (T) jsonMapper.readValue( input, clazz ); @@ -190,29 +186,31 @@ return xmlMapper.writeValueAsString( value ); } + @Deprecated public static void toXmlWithView( OutputStream output, Object value, Class viewClass ) throws IOException { xmlMapper.writerWithView( viewClass ).writeValue( output, value ); } + @Deprecated public static String toXmlWithViewAsString( Object value, Class viewClass ) throws IOException { return xmlMapper.writerWithView( viewClass ).writeValueAsString( value ); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public static T fromXml( InputStream input, Class clazz ) throws IOException { return (T) xmlMapper.readValue( input, clazz ); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public static T fromXml( String input, Class clazz ) throws IOException { return (T) xmlMapper.readValue( input, clazz ); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public static T fromJson( InputStream inputStream, TypeReference typeReference ) throws IOException { return (T) jsonMapper.readValue( inputStream, typeReference ); === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/GeoFeatureController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/GeoFeatureController.java 2014-11-03 12:30:39 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/GeoFeatureController.java 2014-11-11 12:24:42 +0000 @@ -151,34 +151,34 @@ List features = new ArrayList<>(); - for ( OrganisationUnit unit : organisationUnits ) + for ( OrganisationUnit organisationUnit : organisationUnits ) { GeoFeature feature = new GeoFeature(); - feature.setId( unit.getUid() ); - feature.setCode( unit.getCode() ); - feature.setHcd( unit.hasChildrenWithCoordinates() ); - feature.setHcu( unit.hasCoordinatesUp() ); - feature.setLe( unit.getLevel() ); - feature.setPg( unit.getParentGraph() ); - feature.setPi( unit.getParent() != null ? unit.getParent().getUid() : null ); - feature.setPn( unit.getParent() != null ? unit.getParent().getDisplayName() : null ); - feature.setTy( FEATURE_TYPE_MAP.get( unit.getFeatureType() ) ); - feature.setCo( unit.getCoordinates() ); + feature.setId( organisationUnit.getUid() ); + feature.setCode( organisationUnit.getCode() ); + feature.setHcd( organisationUnit.hasChildrenWithCoordinates() ); + feature.setHcu( organisationUnit.hasCoordinatesUp() ); + feature.setLe( organisationUnit.getLevel() ); + feature.setPg( organisationUnit.getParentGraph() ); + feature.setPi( organisationUnit.getParent() != null ? organisationUnit.getParent().getUid() : null ); + feature.setPn( organisationUnit.getParent() != null ? organisationUnit.getParent().getDisplayName() : null ); + feature.setTy( FEATURE_TYPE_MAP.get( organisationUnit.getFeatureType() ) ); + feature.setCo( organisationUnit.getCoordinates() ); if ( DisplayProperty.SHORTNAME.equals( params.getDisplayProperty() ) ) { - feature.setNa( unit.getDisplayShortName() ); + feature.setNa( organisationUnit.getDisplayShortName() ); } else { - feature.setNa( unit.getDisplayName() ); + feature.setNa( organisationUnit.getDisplayName() ); } if ( includeGroupSets ) { for ( OrganisationUnitGroupSet groupSet : groupSets ) { - OrganisationUnitGroup group = unit.getGroupInGroupSet( groupSet ); + OrganisationUnitGroup group = organisationUnit.getGroupInGroupSet( groupSet ); if ( group != null ) {