=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java 2014-03-27 10:14:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaService.java 2014-05-28 11:02:29 +0000 @@ -40,4 +40,6 @@ Schema getSchemaBySingularName( String name ); List getSchemas(); + + List getMetadataSchemas(); } === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schemas.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schemas.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schemas.java 2014-05-28 11:02:29 +0000 @@ -0,0 +1,69 @@ +package org.hisp.dhis.schema; + +/* + * 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.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import com.google.common.collect.Lists; +import org.hisp.dhis.common.DxfNamespaces; + +import java.util.List; + +/** + * @author Morten Olav Hansen + */ +@JacksonXmlRootElement( localName = "schemas", namespace = DxfNamespaces.DXF_2_0 ) +public class Schemas +{ + private List schemas = Lists.newArrayList(); + + public Schemas() + { + } + + public Schemas( List schemas ) + { + this.schemas = schemas; + } + + @JsonProperty + @JacksonXmlProperty( localName = "schema", namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlElementWrapper( localName = "schemas", namespace = DxfNamespaces.DXF_2_0, useWrapping = false ) + public List getSchemas() + { + return schemas; + } + + public void setSchemas( List schemas ) + { + this.schemas = schemas; + } +} === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java 2014-03-28 03:28:21 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java 2014-05-28 11:02:29 +0000 @@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.PostConstruct; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -107,4 +108,24 @@ { return Lists.newArrayList( classSchemaMap.values() ); } + + @Override + public List getMetadataSchemas() + { + List schemas = getSchemas(); + + Iterator iterator = schemas.iterator(); + + while ( iterator.hasNext() ) + { + Schema schema = iterator.next(); + + if ( !schema.isMetadata() ) + { + iterator.remove(); + } + } + + return schemas; + } } === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java 2014-05-22 12:40:24 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java 2014-05-28 11:02:29 +0000 @@ -28,10 +28,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.hisp.dhis.dxf2.metadata.MetaData; +import org.hisp.dhis.dxf2.utils.JacksonUtils; import org.hisp.dhis.schema.Schema; import org.hisp.dhis.schema.SchemaService; -import org.hisp.dhis.dxf2.utils.JacksonUtils; +import org.hisp.dhis.schema.Schemas; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; @@ -41,7 +41,6 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.List; /** * @author Morten Olav Hansen @@ -53,18 +52,16 @@ @Autowired private SchemaService schemaService; - @RequestMapping( value = "", method = RequestMethod.GET, produces = { "*/*" } ) + @RequestMapping( value = "", method = RequestMethod.GET, produces = { "text/html", "*/*" } ) public void getSchemasJson( HttpServletResponse response ) throws IOException { - List schemas = schemaService.getSchemas(); - MetaData metaData = new MetaData(); - metaData.setSchemas( schemas ); + Schemas schemas = new Schemas( schemaService.getSchemas() ); response.setContentType( MediaType.APPLICATION_JSON_VALUE ); JacksonUtils.toJson( response.getOutputStream(), schemas ); } - @RequestMapping( value = "/{type}", method = RequestMethod.GET, produces = { "*/*" } ) + @RequestMapping( value = "/{type}", method = RequestMethod.GET, produces = { "text/html", "*/*" } ) public void getSchemaJson( @PathVariable String type, HttpServletResponse response ) throws IOException { Schema schema = schemaService.getSchemaBySingularName( type ); @@ -76,12 +73,10 @@ @RequestMapping( value = "", method = RequestMethod.GET, produces = { MediaType.APPLICATION_XML_VALUE } ) public void getSchemasXml( HttpServletResponse response ) throws IOException { - List schemas = schemaService.getSchemas(); - MetaData metaData = new MetaData(); - metaData.setSchemas( schemas ); + Schemas schemas = new Schemas( schemaService.getSchemas() ); response.setContentType( MediaType.APPLICATION_XML_VALUE ); - JacksonUtils.toXml( response.getOutputStream(), metaData ); + JacksonUtils.toXml( response.getOutputStream(), schemas ); } @RequestMapping( value = "/{type}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_XML_VALUE } ) === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/MetaDataExportFormAction.java' --- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/MetaDataExportFormAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/dxf2/MetaDataExportFormAction.java 2014-05-28 11:02:29 +0000 @@ -28,13 +28,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import com.opensymphony.xwork2.Action; import org.apache.commons.lang3.StringUtils; -import org.hisp.dhis.dxf2.metadata.ExchangeClasses; +import org.hisp.dhis.schema.Schema; +import org.hisp.dhis.schema.SchemaService; +import org.springframework.beans.factory.annotation.Autowired; -import java.util.ArrayList; import java.util.Collections; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -44,11 +46,14 @@ public class MetaDataExportFormAction implements Action { + @Autowired + private SchemaService schemaService; + // ------------------------------------------------------------------------- // Input & Output // ------------------------------------------------------------------------- - private Map exportClasses = new LinkedHashMap(); + private Map exportClasses = Maps.newLinkedHashMap(); public Map getExportClasses() { @@ -62,7 +67,13 @@ @Override public String execute() throws Exception { - List values = new ArrayList( ExchangeClasses.getExportMap().values() ); + List values = Lists.newArrayList(); + + for ( Schema schema : schemaService.getMetadataSchemas() ) + { + values.add( schema.getPlural() ); + } + Collections.sort( values ); for ( String key : values ) === modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm' --- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm 2014-03-13 16:17:36 +0000 +++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm 2014-05-28 11:02:29 +0000 @@ -1,162 +1,155 @@

$i18n.getString( "metadata_export" )

- - - - - - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- - - - - - - - + + + + + + +
- - -
+
+ +
+ + + + + + + + - + + - - + - - - - - - -
+ + +
-
+
-
- -
+
+ +