dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15128
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5340: merged with dxf2
Merge authors:
Morten Olav Hansen (mortenoh)
------------------------------------------------------------
revno: 5340 [merge]
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-12-09 19:10:11 +0100
message:
merged with dxf2
removed:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeController.java
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryComboXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryOptionComboXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryOptionXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/ChartXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataElementGroupSetXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataElementGroupXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataSetXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorGroupSetXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorGroupXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JsonDataSetDeserializer.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitGroupSetXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitGroupXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitXmlAdapter.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeTypeController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/HibernateObjectPersister.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ObjectPersister.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/JacksonUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/attributeType.xsl
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValue.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseIdentifiableObjectXmlAdapter.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryComboController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryOptionComboController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryOptionController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CompleteDataSetRegistrationController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndexController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ExtendedMappingJacksonView.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Jaxb2Utils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java
dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl
dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl
--
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/attribute/AttributeValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValue.java 2011-12-06 21:57:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValue.java 2011-12-09 18:08:05 +0000
@@ -75,8 +75,8 @@
this.id = id;
}
- @XmlAttribute
- @JsonProperty
+ @XmlAttribute( name = "id" )
+ @JsonProperty( value = "id" )
public String getAttributeTypeRef()
{
return attribute.getUid();
@@ -89,10 +89,6 @@
return attribute.getName();
}
- /* @XmlElement( name = "attributeType" )
-@XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
-@JsonSerialize( using = JsonIdentifiableObjectSerializer.class )
-@JsonProperty( value = "attributeType" ) */
public Attribute getAttribute()
{
return attribute;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2011-12-06 22:23:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java 2011-12-09 18:08:05 +0000
@@ -30,6 +30,7 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.adapter.BaseNameableObjectXmlAdapter;
import org.hisp.dhis.common.adapter.JsonNameableObjectCollectionSerializer;
import org.hisp.dhis.dataelement.DataElement;
@@ -46,12 +47,11 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.hisp.dhis.common.Dxf2Namespace;
/**
* @author Lars Helge Overland
*/
-@XmlRootElement( name = "chart", namespace=Dxf2Namespace.NAMESPACE )
+@XmlRootElement( name = "chart", namespace = Dxf2Namespace.NAMESPACE )
@XmlAccessorType( value = XmlAccessType.NONE )
public class Chart
extends BaseIdentifiableObject
@@ -76,13 +76,13 @@
public static final String SIZE_NORMAL = "normal";
public static final String SIZE_WIDE = "wide";
public static final String SIZE_TALL = "tall";
-
- public static final String TYPE_COLUMN = "column";
- public static final String TYPE_STACKED_COLUMN = "stackedColumn";
- public static final String TYPE_BAR = "bar";
- public static final String TYPE_STACKED_BAR = "stackedBar";
- public static final String TYPE_LINE = "line";
- public static final String TYPE_AREA = "area";
+
+ public static final String TYPE_COLUMN = "column";
+ public static final String TYPE_STACKED_COLUMN = "stackedColumn";
+ public static final String TYPE_BAR = "bar";
+ public static final String TYPE_STACKED_BAR = "stackedBar";
+ public static final String TYPE_LINE = "line";
+ public static final String TYPE_AREA = "area";
public static final String TYPE_PIE = "pie";
public static final String DIMENSION_DATA = "data";
@@ -280,8 +280,8 @@
// Getters and setters
// -------------------------------------------------------------------------
- @XmlElement
- @JsonProperty
+ @XmlElement( name = "domainAxisLabel" )
+ @JsonProperty( value = "domainAxisLabel" )
public String getDomainAxixLabel()
{
return domainAxixLabel;
@@ -476,7 +476,7 @@
@XmlElementWrapper( name = "indicators" )
@XmlElement( name = "indicator" )
@JsonProperty
- @JsonSerialize( using = JsonNameableObjectCollectionSerializer.class )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public List<Indicator> getIndicators()
{
return indicators;
@@ -487,11 +487,11 @@
this.indicators = indicators;
}
- @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
@XmlElementWrapper( name = "dataElements" )
@XmlElement( name = "dataElement" )
+ @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
@JsonProperty
- @JsonSerialize( using = JsonNameableObjectCollectionSerializer.class )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public List<DataElement> getDataElements()
{
return dataElements;
@@ -502,11 +502,11 @@
this.dataElements = dataElements;
}
- @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
@XmlElementWrapper( name = "dataSets" )
@XmlElement( name = "dataSet" )
+ @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
@JsonProperty
- @JsonSerialize( using = JsonNameableObjectCollectionSerializer.class )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public List<DataSet> getDataSets()
{
return dataSets;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2011-12-09 13:40:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2011-12-09 18:08:05 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hisp.dhis.common.adapter.JsonDateSerializer;
@@ -42,7 +43,6 @@
*/
@XmlRootElement( name = "identifiableObject", namespace = Dxf2Namespace.NAMESPACE )
@XmlAccessorType( value = XmlAccessType.NONE )
-@XmlType( propOrder = {"uid", "name", "code", "lastUpdated" } )
public class BaseIdentifiableObject extends BaseLinkableObject
implements IdentifiableObject
{
@@ -110,7 +110,6 @@
this.id = id;
}
- @XmlID
@XmlAttribute( name = "id" )
@JsonProperty( value = "id" )
public String getUid()
@@ -123,9 +122,8 @@
this.uid = uid;
}
- @XmlAttribute
+ @XmlAttribute(required = false)
@JsonProperty
- @JsonSerialize( include = JsonSerialize.Inclusion.NON_NULL )
public String getCode()
{
return code;
@@ -136,7 +134,7 @@
this.code = code;
}
- @XmlAttribute
+ @XmlAttribute(required = false)
@JsonProperty
public String getName()
{
@@ -148,9 +146,8 @@
this.name = name;
}
- @XmlAttribute
+ @XmlAttribute(required = false)
@JsonProperty
- @JsonSerialize( using = JsonDateSerializer.class )
public Date getLastUpdated()
{
return lastUpdated;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseIdentifiableObjectXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseIdentifiableObjectXmlAdapter.java 2011-12-03 12:53:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseIdentifiableObjectXmlAdapter.java 2011-12-09 18:08:05 +0000
@@ -27,7 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.apache.commons.lang.NotImplementedException;
import org.hisp.dhis.common.BaseIdentifiableObject;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -40,7 +39,7 @@
@Override
public BaseIdentifiableObject unmarshal( BaseIdentifiableObject baseIdentifiableObject ) throws Exception
{
- throw new NotImplementedException();
+ return baseIdentifiableObject;
}
@Override
@@ -51,7 +50,6 @@
BaseIdentifiableObject bio = new BaseIdentifiableObject();
bio.setUid( baseIdentifiableObject.getUid() );
- bio.setCode( baseIdentifiableObject.getCode() );
bio.setName( baseIdentifiableObject.getName() );
bio.setLastUpdated( baseIdentifiableObject.getLastUpdated() );
bio.setLink( baseIdentifiableObject.getLink() );
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java 2011-12-03 12:53:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java 1970-01-01 00:00:00 +0000
@@ -1,68 +0,0 @@
-package org.hisp.dhis.common.adapter;
-
-/*
- * Copyright (c) 2004-2011, 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 org.apache.commons.lang.NotImplementedException;
-import org.hisp.dhis.common.BaseNameableObject;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class BaseNameableObjectXmlAdapter extends XmlAdapter<BaseNameableObject, BaseNameableObject>
-{
- @Override
- public BaseNameableObject unmarshal( BaseNameableObject baseNameableObject ) throws Exception
- {
- throw new NotImplementedException();
- }
-
- @Override
- public BaseNameableObject marshal( BaseNameableObject baseNameableObject ) throws Exception
- {
- if ( baseNameableObject != null )
- {
- BaseNameableObject bno = new BaseNameableObject();
-
- bno.setUid( baseNameableObject.getUid() );
- bno.setCode( baseNameableObject.getCode() );
- bno.setName( baseNameableObject.getName() );
- bno.setLastUpdated( baseNameableObject.getLastUpdated() );
- bno.setLink( baseNameableObject.getLink() );
-
- bno.setShortName( baseNameableObject.getShortName() );
- bno.setAlternativeName( baseNameableObject.getAlternativeName() );
- bno.setDescription( baseNameableObject.getDescription() );
-
- return bno;
- }
-
- return null;
- }
-}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/BaseNameableObjectXmlAdapter.java 2011-12-09 18:08:05 +0000
@@ -0,0 +1,62 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseNameableObject;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class BaseNameableObjectXmlAdapter extends XmlAdapter<BaseNameableObject, BaseNameableObject>
+{
+ @Override
+ public BaseNameableObject unmarshal( BaseNameableObject baseIdentifiableObject ) throws Exception
+ {
+ return baseIdentifiableObject;
+ }
+
+ @Override
+ public BaseNameableObject marshal( BaseNameableObject baseIdentifiableObject ) throws Exception
+ {
+ if ( baseIdentifiableObject != null )
+ {
+ BaseNameableObject bio = new BaseNameableObject();
+
+ bio.setUid( baseIdentifiableObject.getUid() );
+ bio.setName( baseIdentifiableObject.getName() );
+ bio.setLastUpdated( baseIdentifiableObject.getLastUpdated() );
+ bio.setLink( baseIdentifiableObject.getLink() );
+
+ return bio;
+ }
+
+ return null;
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryComboXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryComboXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryComboXmlAdapter.java 2011-12-09 13:41:05 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class CategoryComboXmlAdapter extends XmlAdapter<BaseIdentifiableObject, DataElementCategoryCombo>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public DataElementCategoryCombo unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ DataElementCategoryCombo categoryCombo = new DataElementCategoryCombo();
+
+ categoryCombo.setUid( identifiableObject.getUid() );
+ categoryCombo.setLastUpdated( identifiableObject.getLastUpdated() );
+ categoryCombo.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return categoryCombo;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( DataElementCategoryCombo categoryCombo ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( categoryCombo );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryOptionComboXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryOptionComboXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryOptionComboXmlAdapter.java 2011-12-09 13:41:05 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class CategoryOptionComboXmlAdapter extends XmlAdapter<BaseIdentifiableObject, DataElementCategoryOptionCombo>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public DataElementCategoryOptionCombo unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ DataElementCategoryOptionCombo categoryOptionCombo = new DataElementCategoryOptionCombo();
+
+ categoryOptionCombo.setUid( identifiableObject.getUid() );
+ categoryOptionCombo.setLastUpdated( identifiableObject.getLastUpdated() );
+ categoryOptionCombo.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return categoryOptionCombo;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( DataElementCategoryOptionCombo categoryOptionCombo ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( categoryOptionCombo );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryOptionXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryOptionXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryOptionXmlAdapter.java 2011-12-09 13:41:05 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.dataelement.DataElementCategoryOption;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class CategoryOptionXmlAdapter extends XmlAdapter<BaseIdentifiableObject, DataElementCategoryOption>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public DataElementCategoryOption unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ DataElementCategoryOption categoryOption = new DataElementCategoryOption();
+
+ categoryOption.setUid( identifiableObject.getUid() );
+ categoryOption.setLastUpdated( identifiableObject.getLastUpdated() );
+ categoryOption.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return categoryOption;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( DataElementCategoryOption categoryOption ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( categoryOption );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/CategoryXmlAdapter.java 2011-12-09 13:41:05 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.dataelement.DataElementCategory;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class CategoryXmlAdapter extends XmlAdapter<BaseIdentifiableObject, DataElementCategory>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public DataElementCategory unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ DataElementCategory category = new DataElementCategory();
+
+ category.setUid( identifiableObject.getUid() );
+ category.setLastUpdated( identifiableObject.getLastUpdated() );
+ category.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return category;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( DataElementCategory category ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( category );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/ChartXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/ChartXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/ChartXmlAdapter.java 2011-12-09 14:27:51 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.chart.Chart;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class ChartXmlAdapter extends XmlAdapter<BaseIdentifiableObject, Chart>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public Chart unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ Chart chart = new Chart();
+
+ chart.setUid( identifiableObject.getUid() );
+ chart.setLastUpdated( identifiableObject.getLastUpdated() );
+ chart.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return chart;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( Chart chart ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( chart );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataElementGroupSetXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataElementGroupSetXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataElementGroupSetXmlAdapter.java 2011-12-09 13:41:05 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.dataelement.DataElementGroupSet;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DataElementGroupSetXmlAdapter extends XmlAdapter<BaseIdentifiableObject, DataElementGroupSet>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public DataElementGroupSet unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ DataElementGroupSet dataElementGroupSet = new DataElementGroupSet();
+
+ dataElementGroupSet.setUid( identifiableObject.getUid() );
+ dataElementGroupSet.setLastUpdated( identifiableObject.getLastUpdated() );
+ dataElementGroupSet.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return dataElementGroupSet;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( DataElementGroupSet dataElementGroupSet ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( dataElementGroupSet );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataElementGroupXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataElementGroupXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataElementGroupXmlAdapter.java 2011-12-09 13:41:05 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.dataelement.DataElementGroup;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DataElementGroupXmlAdapter extends XmlAdapter<BaseIdentifiableObject, DataElementGroup>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public DataElementGroup unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ DataElementGroup dataElementGroup = new DataElementGroup();
+
+ dataElementGroup.setUid( identifiableObject.getUid() );
+ dataElementGroup.setLastUpdated( identifiableObject.getLastUpdated() );
+ dataElementGroup.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return dataElementGroup;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( DataElementGroup dataElementGroup ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( dataElementGroup );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataSetXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataSetXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/DataSetXmlAdapter.java 2011-12-09 13:41:05 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.dataset.DataSet;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DataSetXmlAdapter extends XmlAdapter<BaseIdentifiableObject, DataSet>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public DataSet unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ DataSet dataSet = new DataSet();
+
+ dataSet.setUid( identifiableObject.getUid() );
+ dataSet.setLastUpdated( identifiableObject.getLastUpdated() );
+ dataSet.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return dataSet;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( DataSet dataSet ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( dataSet );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorGroupSetXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorGroupSetXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorGroupSetXmlAdapter.java 2011-12-09 14:27:51 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class IndicatorGroupSetXmlAdapter extends XmlAdapter<BaseIdentifiableObject, IndicatorGroupSet>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public IndicatorGroupSet unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ IndicatorGroupSet indicatorGroupSet = new IndicatorGroupSet();
+
+ indicatorGroupSet.setUid( identifiableObject.getUid() );
+ indicatorGroupSet.setLastUpdated( identifiableObject.getLastUpdated() );
+ indicatorGroupSet.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return indicatorGroupSet;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( IndicatorGroupSet indicatorGroupSet ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( indicatorGroupSet );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorGroupXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorGroupXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorGroupXmlAdapter.java 2011-12-09 14:27:51 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.indicator.IndicatorGroup;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class IndicatorGroupXmlAdapter extends XmlAdapter<BaseIdentifiableObject, IndicatorGroup>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public IndicatorGroup unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ IndicatorGroup indicatorGroup = new IndicatorGroup();
+
+ indicatorGroup.setUid( identifiableObject.getUid() );
+ indicatorGroup.setLastUpdated( identifiableObject.getLastUpdated() );
+ indicatorGroup.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return indicatorGroup;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( IndicatorGroup indicatorGroup ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( indicatorGroup );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/IndicatorXmlAdapter.java 2011-12-09 14:27:51 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.indicator.Indicator;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class IndicatorXmlAdapter extends XmlAdapter<BaseIdentifiableObject, Indicator>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public Indicator unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ Indicator indicator = new Indicator();
+
+ indicator.setUid( identifiableObject.getUid() );
+ indicator.setLastUpdated( identifiableObject.getLastUpdated() );
+ indicator.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return indicator;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( Indicator indicator ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( indicator );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JsonDataSetDeserializer.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JsonDataSetDeserializer.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JsonDataSetDeserializer.java 2011-12-09 13:41:05 +0000
@@ -0,0 +1,28 @@
+package org.hisp.dhis.common.adapter;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.hisp.dhis.common.BaseNameableObject;
+import org.hisp.dhis.dataset.DataSet;
+
+import java.io.IOException;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class JsonDataSetDeserializer extends JsonDeserializer<DataSet>
+{
+ @Override
+ public DataSet deserialize( JsonParser jp, DeserializationContext context ) throws IOException, JsonProcessingException
+ {
+ DataSet dataSet = new DataSet();
+ BaseNameableObject baseNameableObject = jp.readValueAs( BaseNameableObject.class );
+
+ dataSet.setUid( baseNameableObject.getUid() );
+ dataSet.setName( baseNameableObject.getName() );
+
+ return dataSet;
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitGroupSetXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitGroupSetXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitGroupSetXmlAdapter.java 2011-12-09 14:27:51 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class OrganisationUnitGroupSetXmlAdapter extends XmlAdapter<BaseIdentifiableObject, OrganisationUnitGroupSet>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public OrganisationUnitGroupSet unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ OrganisationUnitGroupSet organisationUnitGroupSet = new OrganisationUnitGroupSet();
+
+ organisationUnitGroupSet.setUid( identifiableObject.getUid() );
+ organisationUnitGroupSet.setLastUpdated( identifiableObject.getLastUpdated() );
+ organisationUnitGroupSet.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return organisationUnitGroupSet;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( OrganisationUnitGroupSet organisationUnitGroupSet ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( organisationUnitGroupSet );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitGroupXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitGroupXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitGroupXmlAdapter.java 2011-12-09 14:27:51 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class OrganisationUnitGroupXmlAdapter extends XmlAdapter<BaseIdentifiableObject, OrganisationUnitGroup>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public OrganisationUnitGroup unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ OrganisationUnitGroup organisationUnitGroup = new OrganisationUnitGroup();
+
+ organisationUnitGroup.setUid( identifiableObject.getUid() );
+ organisationUnitGroup.setLastUpdated( identifiableObject.getLastUpdated() );
+ organisationUnitGroup.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return organisationUnitGroup;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( OrganisationUnitGroup organisationUnitGroup ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( organisationUnitGroup );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitXmlAdapter.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/OrganisationUnitXmlAdapter.java 2011-12-09 14:27:51 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.common.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class OrganisationUnitXmlAdapter extends XmlAdapter<BaseIdentifiableObject, OrganisationUnit>
+{
+ private BaseIdentifiableObjectXmlAdapter baseIdentifiableObjectXmlAdapter = new BaseIdentifiableObjectXmlAdapter();
+
+ @Override
+ public OrganisationUnit unmarshal( BaseIdentifiableObject identifiableObject ) throws Exception
+ {
+ OrganisationUnit organisationUnit = new OrganisationUnit();
+
+ organisationUnit.setUid( identifiableObject.getUid() );
+ organisationUnit.setLastUpdated( identifiableObject.getLastUpdated() );
+ organisationUnit.setName( identifiableObject.getName() == null ? UUID.randomUUID().toString() : identifiableObject.getName() );
+
+ return organisationUnit;
+ }
+
+ @Override
+ public BaseIdentifiableObject marshal( OrganisationUnit organisationUnit ) throws Exception
+ {
+ return baseIdentifiableObjectXmlAdapter.marshal( organisationUnit );
+ }
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2011-12-07 13:32:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2011-12-09 18:08:05 +0000
@@ -31,9 +31,12 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hisp.dhis.attribute.AttributeValue;
+import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseNameableObject;
import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.common.adapter.*;
+import org.hisp.dhis.common.adapter.CategoryComboXmlAdapter;
+import org.hisp.dhis.common.adapter.DataElementGroupXmlAdapter;
+import org.hisp.dhis.common.adapter.DataSetXmlAdapter;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.period.YearlyPeriodType;
@@ -432,7 +435,9 @@
}
@XmlElement
- @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
+ @XmlJavaTypeAdapter( CategoryComboXmlAdapter.class )
+ @JsonProperty
+ @JsonSerialize( as = BaseIdentifiableObject.class )
public DataElementCategoryCombo getCategoryCombo()
{
return categoryCombo;
@@ -469,8 +474,9 @@
@XmlElementWrapper( name = "dataElementGroups" )
@XmlElement( name = "dataElementGroup" )
- @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @XmlJavaTypeAdapter( DataElementGroupXmlAdapter.class )
+ @JsonProperty( value = "dataElementGroups" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<DataElementGroup> getGroups()
{
return groups;
@@ -483,8 +489,8 @@
@XmlElementWrapper( name = "dataSets" )
@XmlElement( name = "dataSet" )
- @XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonNameableObjectCollectionSerializer.class )
+ @XmlJavaTypeAdapter( DataSetXmlAdapter.class )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<DataSet> getDataSets()
{
return dataSets;
@@ -534,7 +540,6 @@
@XmlElementWrapper( name = "attributes" )
@XmlElement( name = "attribute" )
@JsonProperty( value = "attributes" )
- @JsonSerialize( using = JsonCollectionSerializer.class )
public Set<AttributeValue> getAttributeValues()
{
return attributeValues;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java 2011-12-07 12:27:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java 2011-12-09 18:08:05 +0000
@@ -213,9 +213,8 @@
// -------------------------------------------------------------------------
@XmlElementWrapper( name = "categories" )
- @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
@XmlElement( name = "category" )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
public List<DataElementCategory> getCategories()
{
return categories;
@@ -227,9 +226,8 @@
}
@XmlElementWrapper( name = "optionCombos" )
- @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
@XmlElement( name = "optionCombo" )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
public Set<DataElementCategoryOptionCombo> getOptionCombos()
{
return optionCombos;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java 2011-12-06 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java 2011-12-09 18:08:05 +0000
@@ -27,10 +27,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.common.adapter.*;
+import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -145,9 +146,10 @@
// -------------------------------------------------------------------------
@XmlElementWrapper( name = "dataElements" )
- @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
@XmlElement( name = "dataElement" )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
+ @JsonProperty( value = "dataElements" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<DataElement> getMembers()
{
return members;
@@ -158,9 +160,10 @@
this.members = members;
}
- @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
@XmlElement( name = "dataElementGroupSet" )
- @JsonSerialize( using = JsonIdentifiableObjectSerializer.class )
+ @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
+ @JsonProperty( value = "dataElementGroupSet" )
+ @JsonSerialize( as = BaseIdentifiableObject.class )
public DataElementGroupSet getGroupSet()
{
return groupSet;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2011-12-06 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2011-12-09 18:08:05 +0000
@@ -32,7 +32,6 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter;
-import org.hisp.dhis.common.adapter.JsonIdentifiableObjectCollectionSerializer;
import org.hisp.dhis.dataelement.comparator.DataElementGroupNameComparator;
import javax.xml.bind.annotation.*;
@@ -220,9 +219,10 @@
}
@XmlElementWrapper( name = "dataElementGroups" )
+ @XmlElement( name = "dataElementGroup" )
@XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
- @XmlElement( name = "dataElementGroup" )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @JsonProperty( value = "dataElementGroups" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public List<DataElementGroup> getMembers()
{
return members;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2011-11-22 16:17:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2011-12-09 13:41:05 +0000
@@ -38,7 +38,7 @@
/**
* Defines service functionality for DataElements and DataElementGroups.
- *
+ *
* @author Kristian Nordal
* @version $Id: DataElementService.java 6289 2008-11-14 17:53:24Z larshelg $
*/
@@ -52,7 +52,7 @@
/**
* Adds a DataElement.
- *
+ *
* @param dataElement the DataElement to add.
* @return a generated unique id of the added DataElement.
*/
@@ -60,7 +60,7 @@
/**
* Updates a DataElement.
- *
+ *
* @param dataElement the DataElement to update.
*/
void updateDataElement( DataElement dataElement );
@@ -69,7 +69,7 @@
* Deletes a DataElement. The DataElement is also removed from any
* DataElementGroups it is a member of. It is not possible to delete a
* DataElement with children.
- *
+ *
* @param dataElement the DataElement to delete.
* @throws HierarchyViolationException if the DataElement has children.
*/
@@ -78,7 +78,7 @@
/**
* Returns a DataElement.
- *
+ *
* @param id the id of the DataElement to return.
* @return the DataElement with the given id, or null if no match.
*/
@@ -86,7 +86,7 @@
/**
* Returns the DataElement with the given UID.
- *
+ *
* @param uid the UID.
* @return the DataElement with the given UID, or null if no match.
*/
@@ -94,7 +94,7 @@
/**
* Returns the DataElement with the given code.
- *
+ *
* @param code the code.
* @return the DataElement with the given code, or null if no match.
*/
@@ -102,7 +102,7 @@
/**
* Returns a DataElement with a given name.
- *
+ *
* @param name the name of the DataElement to return.
* @return the DataElement with the given name, or null if no match.
*/
@@ -110,7 +110,7 @@
/**
* Returns a DataElement with a given alternative name.
- *
+ *
* @param alternativeName the alternative name of the DataElement to return.
* @return the DataElement with the given alternative name, or null if no
* match.
@@ -119,7 +119,7 @@
/**
* Returns List of DataElements with a given key.
- *
+ *
* @param key the name of the DataElement to return.
* @return List of DataElements with a given key, or all dataelements if no
* match.
@@ -128,7 +128,7 @@
/**
* Returns a DataElement with a given short name.
- *
+ *
* @param shortName the short name of the DataElement to return.
* @return the DataElement with the given short name, or null if no match.
*/
@@ -136,7 +136,7 @@
/**
* Returns all DataElements.
- *
+ *
* @return a collection of all DataElements, or an empty collection if there
* are no DataElements.
*/
@@ -145,7 +145,7 @@
/**
* Returns all DataElements with corresponding identifiers. Returns all
* DataElements if the given argument is null.
- *
+ *
* @param identifiers the collection of identifiers.
* @return a collection of DataElements.
*/
@@ -154,14 +154,14 @@
/**
* Returns all DataElements with types that are possible to aggregate. The
* types are currently INT and BOOL.
- *
+ *
* @return all DataElements with types that are possible to aggregate.
*/
Collection<DataElement> getAggregateableDataElements();
/**
* Returns all active DataElements.
- *
+ *
* @return a collection of all active DataElements, or an empty collection
* if there are no active DataElements.
*/
@@ -169,7 +169,7 @@
/**
* Returns all DataElements with a given aggregantion operator.
- *
+ *
* @param aggregationOperator the aggregation operator of the DataElements
* to return.
* @return a collection of all DataElements with the given aggregation
@@ -180,7 +180,7 @@
/**
* Returns all DataElements with the given domain type.
- *
+ *
* @param domainType the domainType.
* @return all DataElements with the given domainType.
*/
@@ -188,7 +188,7 @@
/**
* Returns all DataElements with the given type.
- *
+ *
* @param type the type.
* @return all DataElements with the given type.
*/
@@ -197,7 +197,7 @@
/**
* Returns the DataElements with the given PeriodType.
- *
+ *
* @param periodType the PeriodType.
* @return a Collection of DataElements.
*/
@@ -205,7 +205,7 @@
/**
* Returns all DataElements with the given category combo.
- *
+ *
* @param categoryCombo the DataElementCategoryCombo.
* @return all DataElements with the given category combo.
*/
@@ -215,7 +215,7 @@
* Returns a Map with DataElementCategoryCombo as key and a Collection of
* the DataElements belonging to the DataElementCategoryCombo from the given
* argument List of DataElements as value.
- *
+ *
* @param dataElements the DataElements to include.
* @return grouped DataElements based on their DataElementCategoryCombo.
*/
@@ -225,7 +225,7 @@
/**
* Returns the DataElementCategoryCombos associated with the given argument
* list of DataElements.
- *
+ *
* @param dataElements the DataElements.
* @return a list of DataElements.
*/
@@ -234,7 +234,7 @@
/**
* Returns all DataElements which are associated with one or more
* DataElementGroupSets.
- *
+ *
* @return all DataElements which are associated with one or more
* DataElementGroupSets.
*/
@@ -242,28 +242,28 @@
/**
* Returns all DataElements which are not member of any DataElementGroups.
- *
+ *
* @return all DataElements which are not member of any DataElementGroups.
*/
Collection<DataElement> getDataElementsWithoutGroups();
/**
* Returns all DataElements which are not assigned to any DataSets.
- *
+ *
* @return all DataElements which are not assigned to any DataSets.
*/
Collection<DataElement> getDataElementsWithoutDataSets();
/**
* Returns all DataElements which are assigned to at least one DataSet.
- *
+ *
* @return all DataElements which are assigned to at least one DataSet.
*/
Collection<DataElement> getDataElementsWithDataSets();
/**
* Checks whether a DataElement with the given identifier exists.
- *
+ *
* @param id the DataElement identifier.
* @return true or false.
*/
@@ -272,7 +272,7 @@
/**
* Checks whether a DataElementCategoryOptionCombo with the given identifier
* exists.
- *
+ *
* @param id the DataElementCategoryOptionCombo identifier.
* @return true or false.
*/
@@ -289,7 +289,7 @@
int getDataElementCount();
int getDataElementCountByName( String name );
-
+
Map<Integer, Set<Integer>> getDataElementCategoryOptionCombos();
// -------------------------------------------------------------------------
@@ -298,7 +298,7 @@
/**
* Adds a DataElementGroup.
- *
+ *
* @param dataElementGroup the DataElementGroup to add.
* @return a generated unique id of the added DataElementGroup.
*/
@@ -306,21 +306,21 @@
/**
* Updates a DataElementGroup.
- *
+ *
* @param dataElementGroup the DataElementGroup to update.
*/
void updateDataElementGroup( DataElementGroup dataElementGroup );
/**
* Deletes a DataElementGroup.
- *
+ *
* @param dataElementGroup the DataElementGroup to delete.
*/
void deleteDataElementGroup( DataElementGroup dataElementGroup );
/**
* Returns a DataElementGroup.
- *
+ *
* @param id the id of the DataElementGroup to return.
* @return the DataElementGroup with the given id, or null if no match.
*/
@@ -328,7 +328,7 @@
/**
* Returns data elements with identifiers in the given collection.
- *
+ *
* @param identifiers the id collection.
* @return data elements with identifiers in the given collection.
*/
@@ -336,7 +336,7 @@
/**
* Returns the DataElementGroup with the given UID.
- *
+ *
* @param id the UID of the DataElementGroup to return.
* @return the DataElementGroup with the given UID, or null if no match.
*/
@@ -344,7 +344,7 @@
/**
* Returns a DataElementGroup with a given name.
- *
+ *
* @param name the name of the DataElementGroup to return.
* @return the DataElementGroup with the given name, or null if no match.
*/
@@ -352,7 +352,7 @@
/**
* Returns all DataElementGroups.
- *
+ *
* @return a collection of all DataElementGroups, or an empty collection if
* no DataElementGroups exist.
*/
@@ -360,7 +360,7 @@
/**
* Returns all DataElementGroups which contain the given DataElement.
- *
+ *
* @param dataElement the DataElement which the DataElementGroups must
* contain.
* @return a collection of all DataElementGroups that contain the given
@@ -370,7 +370,7 @@
/**
* Returns data elements with identifier in the given id.
- *
+ *
* @param groupId is the id of data element group.
* @return data elements with identifier in the given id.
*/
@@ -379,7 +379,7 @@
/**
* Defines the given data elements as zero is significant. All other data
* elements are defined as zero is in-significant.
- *
+ *
* @param dataElementIds identifiers of data elements where zero is
* significant.
*/
@@ -387,7 +387,7 @@
/**
* Returns all DataElement which zeroIsSignificant property is true or false
- *
+ *
* @param zeroIsSignificant is zeroIsSignificant property
* @return a collection of all DataElement
*/
@@ -395,7 +395,7 @@
/**
* Returns all DataElement which zeroIsSignificant property is true or false
- *
+ *
* @param zeroIsSignificant is zeroIsSignificant property
* @param dataElementGroup is group contain data elements
* @return a collection of all DataElement
@@ -422,7 +422,7 @@
void deleteDataElementGroupSet( DataElementGroupSet groupSet );
DataElementGroupSet getDataElementGroupSet( int id );
-
+
DataElementGroupSet getDataElementGroupSet( String uid );
DataElementGroupSet getDataElementGroupSetByName( String name );
@@ -452,7 +452,7 @@
/**
* Returns all Operands. Requires the categoryoptioncomboname resource table
* to be populated.
- *
+ *
* @return a collection of all Operands.
*/
Collection<DataElementOperand> getAllGeneratedOperands();
@@ -461,7 +461,7 @@
* Returns all generated permutations of Operands for the given collection
* of DataElements. Requires the categoryoptioncomboname resource table to
* be populated.
- *
+ *
* @param dataElements the DataElements.
* @return a collection of all Operands.
*/
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java 2011-05-05 21:14:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java 2011-12-09 18:08:05 +0000
@@ -27,13 +27,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.common.ImportableObject;
+
import java.io.Serializable;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.hisp.dhis.common.ImportableObject;
-
/**
* @author Bharath Kumar
*/
@@ -47,7 +47,7 @@
public static final Pattern INPUT_PATTERN = Pattern.compile( "value\\[\\d+\\]\\.value:value\\[\\d+\\]\\.value" );
public static final Pattern OPERAND_PATTERN = Pattern.compile( "\\d+" );
-
+
/**
* The unique identifier for this DataEntryForm
*/
@@ -62,7 +62,7 @@
* HTML Code of DataEntryForm
*/
private String htmlCode;
-
+
// -------------------------------------------------------------------------
// Contructors
// -------------------------------------------------------------------------
@@ -87,43 +87,43 @@
// -------------------------------------------------------------------------
/**
- * Map the identifiers inside the HTML code according to the provided data
+ * Map the identifiers inside the HTML code according to the provided data
* element identifier and category option combo identifier mappings.
- *
- * @param htmlCode the HTML code.
- * @param dataElementMap the mapping between data element identifiers to be
- * converted.
+ *
+ * @param htmlCode the HTML code.
+ * @param dataElementMap the mapping between data element identifiers to be
+ * converted.
* @param categoryOptionComboMap the mapping between category option combo
- * identifiers to be converted.
+ * identifiers to be converted.
* @return the converted HTML code.
*/
public void convertDataEntryForm( Map<Object, Integer> dataElementMap, Map<Object, Integer> categoryOptionComboMap )
{
- Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
+ Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
StringBuffer buffer = new StringBuffer();
-
+
while ( inputMatcher.find() )
{
String input = inputMatcher.group();
Matcher operandMatcher = OPERAND_PATTERN.matcher( input );
-
- operandMatcher.find();
+
+ operandMatcher.find();
String d = operandMatcher.group();
throwException( d == null, "Could not find data element identifier in form" );
Integer dataElement = dataElementMap.get( Integer.parseInt( d ) );
throwException( dataElement == null, "Data element identifier does not exist: " + d );
-
+
operandMatcher.find();
String c = operandMatcher.group();
throwException( c == null, "Could not find category option combo identifier in form" );
Integer categoryOptionCombo = categoryOptionComboMap.get( Integer.parseInt( c ) );
throwException( categoryOptionCombo == null, "Category option combo identifier does not exist: " + c );
-
+
inputMatcher.appendReplacement( buffer, "value[" + dataElement + "].value:value[" + categoryOptionCombo + "].value" );
}
-
+
inputMatcher.appendTail( buffer );
-
+
this.htmlCode = buffer.toString();
}
@@ -134,7 +134,7 @@
throw new IllegalArgumentException( message );
}
}
-
+
// -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
@@ -172,16 +172,6 @@
// Getters and setters
// -------------------------------------------------------------------------
- public String getHtmlCode()
- {
- return htmlCode;
- }
-
- public void setHtmlCode( String htmlCode )
- {
- this.htmlCode = htmlCode;
- }
-
public int getId()
{
return id;
@@ -201,4 +191,14 @@
{
this.name = name;
}
+
+ public String getHtmlCode()
+ {
+ return htmlCode;
+ }
+
+ public void setHtmlCode( String htmlCode )
+ {
+ this.htmlCode = htmlCode;
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2011-12-06 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2011-12-09 18:08:05 +0000
@@ -29,9 +29,11 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseNameableObject;
import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.common.adapter.*;
+import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter;
+import org.hisp.dhis.common.adapter.BaseNameableObjectXmlAdapter;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.dataentryform.DataEntryForm;
@@ -306,7 +308,8 @@
@XmlElementWrapper( name = "dataElements" )
@XmlElement( name = "dataElement" )
@XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonNameableObjectCollectionSerializer.class )
+ @JsonProperty( value = "dataElements" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<DataElement> getDataElements()
{
return dataElements;
@@ -320,7 +323,8 @@
@XmlElementWrapper( name = "indicators" )
@XmlElement( name = "indicator" )
@XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonNameableObjectCollectionSerializer.class )
+ @JsonProperty( value = "indicators" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<Indicator> getIndicators()
{
return indicators;
@@ -346,7 +350,8 @@
@XmlElementWrapper( name = "organisationUnits" )
@XmlElement( name = "organisationUnit" )
@XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @JsonProperty( value = "organisationUnits" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<OrganisationUnit> getSources()
{
return sources;
@@ -372,7 +377,6 @@
@XmlElementWrapper( name = "sections" )
@XmlElement( name = "section" )
@JsonProperty
- @JsonSerialize( using = JsonCollectionSerializer.class )
public Set<Section> getSections()
{
return sections;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java 2011-12-06 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java 2011-12-09 18:08:05 +0000
@@ -25,9 +25,9 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter;
-import org.hisp.dhis.common.adapter.JsonIdentifiableObjectCollectionSerializer;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementOperand;
@@ -200,7 +200,8 @@
@XmlElementWrapper( name = "dataElements" )
@XmlElement( name = "dataElement" )
@XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @JsonProperty( value = "dataElements" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public List<DataElement> getDataElements()
{
return dataElements;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java 2011-12-06 21:57:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java 2011-12-09 18:08:05 +0000
@@ -30,9 +30,11 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hisp.dhis.attribute.AttributeValue;
+import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseNameableObject;
import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.common.adapter.*;
+import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter;
+import org.hisp.dhis.common.adapter.BaseNameableObjectXmlAdapter;
import org.hisp.dhis.dataset.DataSet;
import javax.xml.bind.annotation.*;
@@ -170,7 +172,7 @@
@XmlElement
@XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonIdentifiableObjectSerializer.class )
+ @JsonSerialize( as = BaseIdentifiableObject.class )
public IndicatorType getIndicatorType()
{
return indicatorType;
@@ -280,7 +282,8 @@
@XmlElementWrapper( name = "indicatorGroups" )
@XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
@XmlElement( name = "indicatorGroup" )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @JsonProperty( value = "indicatorGroups" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<IndicatorGroup> getGroups()
{
return groups;
@@ -294,7 +297,7 @@
@XmlElementWrapper( name = "dataSets" )
@XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
@XmlElement( name = "dataSet" )
- @JsonSerialize( using = JsonNameableObjectCollectionSerializer.class )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<DataSet> getDataSets()
{
return dataSets;
@@ -308,7 +311,6 @@
@XmlElementWrapper( name = "attributes" )
@XmlElement( name = "attribute" )
@JsonProperty( value = "attributes" )
- @JsonSerialize( using = JsonCollectionSerializer.class )
public Set<AttributeValue> getAttributeValues()
{
return attributeValues;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroup.java 2011-12-06 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroup.java 2011-12-09 18:08:05 +0000
@@ -27,12 +27,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter;
import org.hisp.dhis.common.adapter.JsonIdentifiableObjectCollectionSerializer;
-import org.hisp.dhis.common.adapter.JsonIdentifiableObjectSerializer;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -157,9 +157,10 @@
this.members = members;
}
- @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
@XmlElement( name = "indicatorGroupSet" )
- @JsonSerialize( using = JsonIdentifiableObjectSerializer.class )
+ @XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
+ @JsonProperty( value = "indicatorGroupSet" )
+ @JsonSerialize( as = BaseIdentifiableObject.class )
public IndicatorGroupSet getGroupSet()
{
return groupSet;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java 2011-12-06 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java 2011-12-09 18:08:05 +0000
@@ -27,27 +27,25 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter;
-import org.hisp.dhis.common.adapter.JsonIdentifiableObjectCollectionSerializer;
import org.hisp.dhis.indicator.comparator.IndicatorGroupNameComparator;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
/**
* An IndicatorGroupSet is a set of IndicatorGroups. It is by default exclusive,
* in the sense that an Indicator can only be a member of one or zero of the
* IndicatorGroups in a IndicatorGroupSet.
- *
+ *
* @author Lars Helge Overland
*/
@XmlRootElement( name = "indicatorGroupSet", namespace = Dxf2Namespace.NAMESPACE )
@@ -221,9 +219,10 @@
}
@XmlElementWrapper( name = "indicatorGroups" )
+ @XmlElement( name = "indicatorGroup" )
@XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
- @XmlElement( name = "indicatorGroup" )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @JsonProperty( value = "indicatorGroups" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public List<IndicatorGroup> getMembers()
{
return members;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2011-12-06 21:57:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java 2011-12-09 18:08:05 +0000
@@ -31,9 +31,11 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hisp.dhis.attribute.AttributeValue;
+import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseNameableObject;
import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.common.adapter.*;
+import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter;
+import org.hisp.dhis.common.adapter.BaseNameableObjectXmlAdapter;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
@@ -128,7 +130,7 @@
private transient String type;
private transient String[] groupNames;
-
+
private transient Double value;
// -------------------------------------------------------------------------
@@ -505,7 +507,7 @@
@XmlElement
@XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonNameableObjectSerializer.class )
+ @JsonSerialize( as = BaseIdentifiableObject.class )
public OrganisationUnit getParent()
{
return parent;
@@ -528,7 +530,6 @@
@XmlElement
@JsonProperty
- @JsonSerialize( using = JsonDateSerializer.class )
public Date getOpeningDate()
{
return openingDate;
@@ -541,7 +542,6 @@
@XmlElement
@JsonProperty
- @JsonSerialize( using = JsonDateSerializer.class )
public Date getClosedDate()
{
return closedDate;
@@ -627,7 +627,8 @@
@XmlElementWrapper( name = "organisationUnitGroups" )
@XmlElement( name = "organisationUnitGroup" )
@XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @JsonProperty( value = "organisationUnitGroups" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<OrganisationUnitGroup> getGroups()
{
return groups;
@@ -641,7 +642,7 @@
@XmlElementWrapper( name = "dataSets" )
@XmlElement( name = "dataSet" )
@XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonNameableObjectCollectionSerializer.class )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<DataSet> getDataSets()
{
return dataSets;
@@ -723,16 +724,6 @@
this.hasPatients = hasPatients;
}
- public int getLevel()
- {
- return level;
- }
-
- public void setLevel( int level )
- {
- this.level = level;
- }
-
@XmlElement
@JsonProperty
public boolean isCurrentParent()
@@ -760,7 +751,6 @@
@XmlElementWrapper( name = "attributes" )
@XmlElement( name = "attribute" )
@JsonProperty( value = "attributes" )
- @JsonSerialize( using = JsonCollectionSerializer.class )
public Set<AttributeValue> getAttributeValues()
{
return attributeValues;
@@ -771,6 +761,16 @@
this.attributeValues = attributeValues;
}
+ public int getLevel()
+ {
+ return level;
+ }
+
+ public void setLevel( int level )
+ {
+ this.level = level;
+ }
+
public String[] getGroupNames()
{
return groupNames;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java 2011-12-06 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java 2011-12-09 18:08:05 +0000
@@ -27,10 +27,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
-import org.hisp.dhis.common.adapter.*;
+import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter;
+import org.hisp.dhis.common.adapter.BaseNameableObjectXmlAdapter;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -144,7 +146,8 @@
@XmlElementWrapper( name = "organisationUnits" )
@XmlElement( name = "organisationUnit" )
@XmlJavaTypeAdapter( BaseNameableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonNameableObjectCollectionSerializer.class )
+ @JsonProperty( value = "organisationUnits" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<OrganisationUnit> getMembers()
{
return members;
@@ -157,7 +160,8 @@
@XmlElement( name = "organisationUnitGroupSet" )
@XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonIdentifiableObjectSerializer.class )
+ @JsonProperty( value = "organisationUnitGroupSet" )
+ @JsonSerialize( as = BaseIdentifiableObject.class )
public OrganisationUnitGroupSet getGroupSet()
{
return groupSet;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java 2011-12-06 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java 2011-12-09 18:08:05 +0000
@@ -32,7 +32,6 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.adapter.BaseIdentifiableObjectXmlAdapter;
-import org.hisp.dhis.common.adapter.JsonIdentifiableObjectCollectionSerializer;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupNameComparator;
import javax.xml.bind.annotation.*;
@@ -200,7 +199,8 @@
@XmlElementWrapper( name = "organisationUnitGroups" )
@XmlElement( name = "organisationUnitGroup" )
@XmlJavaTypeAdapter( BaseIdentifiableObjectXmlAdapter.class )
- @JsonSerialize( using = JsonIdentifiableObjectCollectionSerializer.class )
+ @JsonProperty( value = "organisationUnitGroups" )
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
public Set<OrganisationUnitGroup> getOrganisationUnitGroups()
{
return organisationUnitGroups;
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeController.java 1970-01-01 00:00:00 +0000
@@ -1,87 +0,0 @@
-package org.hisp.dhis.api.controller;
-
-/*
- * Copyright (c) 2004-2011, 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 org.hisp.dhis.api.utils.IdentifiableObjectParams;
-import org.hisp.dhis.api.utils.WebLinkPopulator;
-import org.hisp.dhis.attribute.Attribute;
-import org.hisp.dhis.attribute.AttributeService;
-import org.hisp.dhis.attribute.Attributes;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@Controller
-@RequestMapping( value = "/attributes" )
-public class AttributeController
-{
- @Autowired
- private AttributeService attributeService;
-
- @RequestMapping( method = RequestMethod.GET )
- public String getAttributes( IdentifiableObjectParams params, Model model, HttpServletRequest request )
- {
- Attributes attributes = new Attributes();
- attributes.setAttributes( new ArrayList<Attribute>( attributeService.getAllAttributes() ) );
-
- if ( params.hasLinks() )
- {
- WebLinkPopulator listener = new WebLinkPopulator( request );
- listener.addLinks( attributes );
- }
-
- model.addAttribute( "model", attributes );
-
- return "attributes";
- }
-
- @RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getAttribute( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
- {
- Attribute attribute = attributeService.getAttribute( uid );
-
- if ( params.hasLinks() )
- {
- WebLinkPopulator listener = new WebLinkPopulator( request );
- listener.addLinks( attribute );
- }
-
- model.addAttribute( "model", attribute );
-
- return "attribute";
- }
-}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeTypeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeTypeController.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AttributeTypeController.java 2011-12-09 18:08:05 +0000
@@ -0,0 +1,221 @@
+package org.hisp.dhis.api.controller;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.api.view.JacksonUtils;
+import org.hisp.dhis.api.view.Jaxb2Utils;
+import org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.attribute.Attributes;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.util.ArrayList;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Controller
+@RequestMapping( value = AttributeTypeController.RESOURCE_PATH )
+public class AttributeTypeController
+{
+ public static final String RESOURCE_PATH = "/attributeTypes";
+
+ @Autowired
+ private AttributeService attributeService;
+
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.GET )
+ public String getAttributeTypes( IdentifiableObjectParams params, Model model, HttpServletRequest request )
+ {
+ Attributes attributes = new Attributes();
+ attributes.setAttributes( new ArrayList<Attribute>( attributeService.getAllAttributes() ) );
+
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulator listener = new WebLinkPopulator( request );
+ listener.addLinks( attributes );
+ }
+
+ model.addAttribute( "model", attributes );
+
+ return "attributeTypes";
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.GET )
+ public String getAttributeType( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
+ {
+ Attribute attribute = attributeService.getAttribute( uid );
+
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulator listener = new WebLinkPopulator( request );
+ listener.addLinks( attribute );
+ }
+
+ model.addAttribute( "model", attribute );
+
+ return "attributeType";
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ public void postAttributeTypeXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ Attribute attribute = (Attribute) Jaxb2Utils.unmarshal( Attribute.class, input );
+ postAttributeType( attribute, response );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ public void postAttributeTypeJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ Attribute attribute = JacksonUtils.readValueAs( Attribute.class, input );
+ postAttributeType( attribute, response );
+ }
+
+ public void postAttributeType( Attribute attribute, HttpServletResponse response )
+ {
+ if ( attribute == null )
+ {
+ response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED );
+ }
+ else
+ {
+ try
+ {
+ attributeService.addAttribute( attribute );
+
+ if ( attribute.getUid() == null )
+ {
+ response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ }
+ else
+ {
+ response.setStatus( HttpServletResponse.SC_CREATED );
+ response.setHeader( "Location", AttributeTypeController.RESOURCE_PATH + "/" + attribute.getUid() );
+ }
+ } catch ( Exception e )
+ {
+ response.setStatus( HttpServletResponse.SC_CONFLICT );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ public void putAttributeTypeXML( @PathVariable( "uid" ) String uid, InputStream input, HttpServletResponse response ) throws Exception
+ {
+ Attribute updateAttribute = (Attribute) Jaxb2Utils.unmarshal( Attribute.class, input );
+ updateAttribute.setUid( uid );
+ putAttributeType( updateAttribute, response );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ public void putAttributeTypeJSON( @PathVariable( "uid" ) String uid, InputStream input, HttpServletResponse response ) throws Exception
+ {
+ Attribute updateAttribute = JacksonUtils.readValueAs( Attribute.class, input );
+ updateAttribute.setUid( uid );
+ putAttributeType( updateAttribute, response );
+ }
+
+ public void putAttributeType( Attribute updatedAttribute, HttpServletResponse response )
+ {
+ Attribute attribute = attributeService.getAttribute( updatedAttribute.getUid() );
+
+ if ( updatedAttribute == null || attribute == null )
+ {
+ response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED );
+ }
+ else
+ {
+ attribute.setName( updatedAttribute.getName() );
+ attribute.setCode( updatedAttribute.getCode() );
+ attribute.setDataElementAttribute( updatedAttribute.isDataElementAttribute() );
+ attribute.setIndicatorAttribute( updatedAttribute.isIndicatorAttribute() );
+ attribute.setOrganisationUnitAttribute( updatedAttribute.isOrganisationUnitAttribute() );
+ attribute.setMandatory( updatedAttribute.isMandatory() );
+ attribute.setAttributeValues( updatedAttribute.getAttributeValues() );
+
+ try
+ {
+ attributeService.updateAttribute( attribute );
+
+ if ( updatedAttribute.getUid() == null )
+ {
+ response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ }
+ else
+ {
+ response.setStatus( HttpServletResponse.SC_NO_CONTENT );
+ response.setHeader( "Location", AttributeTypeController.RESOURCE_PATH + "/" + updatedAttribute.getUid() );
+ }
+ } catch ( Exception e )
+ {
+ response.setStatus( HttpServletResponse.SC_CONFLICT );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ public void deleteAttributeType( @PathVariable( "uid" ) String uid, HttpServletResponse response ) throws Exception
+ {
+ Attribute attribute = attributeService.getAttribute( uid );
+
+ if ( attribute == null )
+ {
+ response.setStatus( HttpServletResponse.SC_NOT_FOUND );
+ }
+ else
+ {
+ response.setStatus( HttpServletResponse.SC_NO_CONTENT );
+ attributeService.deleteAttribute( attribute );
+ }
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryComboController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryComboController.java 2011-12-07 12:27:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryComboController.java 2011-12-08 17:11:47 +0000
@@ -33,25 +33,36 @@
import org.hisp.dhis.dataelement.DataElementCategoryCombos;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/categoryCombos" )
+@RequestMapping( value = CategoryComboController.RESOURCE_PATH )
public class CategoryComboController
{
+ public static final String RESOURCE_PATH = "/categoryCombos";
+
@Autowired
private DataElementCategoryService dataElementCategoryService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getCategoryCombos( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -84,4 +95,51 @@
return "categoryCombo";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postCategoryComboXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postCategoryComboJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putCategoryComboXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putCategoryComboJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteCategoryCombo( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryController.java 2011-12-07 12:27:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryController.java 2011-12-08 17:11:47 +0000
@@ -33,25 +33,36 @@
import org.hisp.dhis.dataelement.DataElementCategory;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/categories" )
+@RequestMapping( value = CategoryController.RESOURCE_PATH )
public class CategoryController
{
+ public static final String RESOURCE_PATH = "/categories";
+
@Autowired
private DataElementCategoryService dataElementCategoryService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getCategories( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -84,4 +95,51 @@
return "category";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postCategoryXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postCategoryJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putCategoryXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putCategoryJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteCategory( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryOptionComboController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryOptionComboController.java 2011-12-07 12:27:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryOptionComboController.java 2011-12-08 17:11:47 +0000
@@ -46,12 +46,18 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/categoryOptionCombos" )
+@RequestMapping( value = CategoryOptionComboController.RESOURCE_PATH )
public class CategoryOptionComboController
{
+ public static final String RESOURCE_PATH = "/categoryOptionCombos";
+
@Autowired
private DataElementCategoryService dataElementCategoryService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getCategoryOptionCombos( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryOptionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryOptionController.java 2011-12-07 12:27:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryOptionController.java 2011-12-08 17:11:47 +0000
@@ -33,27 +33,38 @@
import org.hisp.dhis.dataelement.DataElementCategoryOptions;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/categoryOptions" )
+@RequestMapping( value = CategoryOptionController.RESOURCE_PATH )
public class CategoryOptionController
{
+ public static final String RESOURCE_PATH = "/categoryOptions";
+
@Autowired
private DataElementCategoryService dataElementCategoryService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
- public String getDataElementCategoryOptions( IdentifiableObjectParams params, Model model, HttpServletRequest request )
+ public String getCategoryOptions( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementCategoryOptions categoryOptions = new DataElementCategoryOptions();
categoryOptions.setCategoryOptions( new ArrayList<DataElementCategoryOption>( dataElementCategoryService.getAllDataElementCategoryOptions() ) );
@@ -70,7 +81,7 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getDataElementCategoryOption( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
+ public String getCategoryOption( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElementCategoryOption categoryOption = dataElementCategoryService.getDataElementCategoryOption( uid );
@@ -84,4 +95,51 @@
return "categoryOption";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postCategoryOptionXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postCategoryOptionJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putCategoryOptionXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putCategoryOptionJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteCategoryOption( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2011-12-08 17:11:47 +0000
@@ -54,12 +54,18 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/charts" )
+@RequestMapping( value = ChartController.RESOURCE_PATH )
public class ChartController
{
+ public static final String RESOURCE_PATH = "/charts";
+
@Autowired
private ChartService chartService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getCharts( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CompleteDataSetRegistrationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CompleteDataSetRegistrationController.java 2011-12-03 14:20:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CompleteDataSetRegistrationController.java 2011-12-08 14:31:31 +0000
@@ -49,10 +49,9 @@
@Autowired
private CompleteDataSetRegistrationService completeDataSetRegistrationService;
- public CompleteDataSetRegistrationController()
- {
-
- }
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
@RequestMapping( method = RequestMethod.GET )
public String getCompleteDataSetRegistrations( Model model, HttpServletRequest request )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java 2011-12-09 13:41:05 +0000
@@ -28,14 +28,18 @@
*/
import org.hisp.dhis.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.ObjectPersister;
import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.api.view.Jaxb2Utils;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataelement.DataElements;
+import org.hisp.dhis.dataset.DataSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -50,12 +54,24 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/dataElements" )
+@RequestMapping( value = DataElementController.RESOURCE_PATH )
public class DataElementController
{
+ public static final String RESOURCE_PATH = "/dataElements";
+
@Autowired
private DataElementService dataElementService;
+ @Autowired
+ private DataSetService dataSetService;
+
+ @Autowired
+ private ObjectPersister objectPersister;
+
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getDataElements( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -73,24 +89,6 @@
return "dataElements";
}
- @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
- @ResponseStatus( value = HttpStatus.CREATED )
- public void postDataElementXML( HttpServletResponse response, InputStream input ) throws Exception
- {
- System.err.println( "POST request on DataElement using XML." );
-
- // response.setHeader("Location", "/spittles/" + spittle.getId());
- }
-
- @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
- @ResponseStatus( value = HttpStatus.CREATED )
- public void postDataElementJSON( HttpServletResponse response, InputStream input ) throws Exception
- {
- System.err.println( "POST request on DataElement using JSON." );
-
- // response.setHeader("Location", "/spittles/" + spittle.getId());
- }
-
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
public String getDataElement( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -107,24 +105,80 @@
return "dataElement";
}
- @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
- @ResponseStatus( value = HttpStatus.NO_CONTENT )
- public void deleteDataElement( @PathVariable( "uid" ) String uid )
- {
- System.err.println( "DELETE request on DataElement with UID = " + uid );
- }
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ public void postDataElementXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ DataElement dataElement = Jaxb2Utils.unmarshal( DataElement.class, input );
+ postDataElement( dataElement, response );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ public void postDataElementJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ //DataElement dataElement = JacksonUtils.readValueAs( DataElement.class, input );
+ //postDataElement( dataElement, response );
+ }
+
+ public void postDataElement( DataElement dataElement, HttpServletResponse response )
+ {
+ if ( dataElement == null )
+ {
+ response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED );
+ }
+ else
+ {
+ try
+ {
+ objectPersister.persistDataElement( dataElement );
+
+ if ( dataElement.getUid() == null )
+ {
+ response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ }
+ else
+ {
+ response.setStatus( HttpServletResponse.SC_CREATED );
+ response.setHeader( "Location", DataElementController.RESOURCE_PATH + "/" + dataElement.getUid() );
+ }
+ } catch ( Exception e )
+ {
+ e.printStackTrace();
+ response.setStatus( HttpServletResponse.SC_CONFLICT );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
@ResponseStatus( value = HttpStatus.NO_CONTENT )
- public void putDataElementXML( @PathVariable( "uid" ) String uid, InputStream input )
+ public void putDataElementXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
{
- System.err.println( "PUT request on DataElement with UID = " + uid + " using XML." );
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
}
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
@ResponseStatus( value = HttpStatus.NO_CONTENT )
- public void putDataElementJSON( @PathVariable( "uid" ) String uid, InputStream input )
- {
- System.err.println( "PUT request on DataElement with UID = " + uid + " using JSON." );
+ public void putDataElementJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteDataElement( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java 2011-12-08 17:11:47 +0000
@@ -33,22 +33,33 @@
import org.hisp.dhis.dataelement.DataElementGroups;
import org.hisp.dhis.dataelement.DataElementService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
@Controller
-@RequestMapping( value = "/dataElementGroups" )
+@RequestMapping( value = DataElementGroupController.RESOURCE_PATH )
public class DataElementGroupController
{
+ public static final String RESOURCE_PATH = "/dataElementGroups";
+
@Autowired
private DataElementService dataElementService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getDataElementGroups( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -81,4 +92,51 @@
return "dataElementGroup";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postDataElementGroupXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postDataElementGroupJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putDataElementGroupXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putDataElementGroupJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteDataElementGroup( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java 2011-12-08 17:11:47 +0000
@@ -46,12 +46,18 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/dataElementGroupSets" )
+@RequestMapping( value = DataElementGroupSetController.RESOURCE_PATH )
public class DataElementGroupSetController
{
+ public static final String RESOURCE_PATH = "/dataElementGroupSets";
+
@Autowired
private DataElementService dataElementService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getDataElementGroupSets( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2011-12-08 14:31:31 +0000
@@ -33,13 +33,18 @@
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.dataset.DataSets;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
/**
@@ -52,6 +57,10 @@
@Autowired
private DataSetService dataSetService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getDataSets( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -84,4 +93,51 @@
return "dataSet";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postDataSetXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postDataSetJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putDataSetXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putDataSetJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteDataSet( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2011-12-03 14:11:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2011-12-08 17:11:47 +0000
@@ -21,9 +21,11 @@
import org.springframework.web.bind.annotation.RequestParam;
@Controller
-@RequestMapping( value = "/dataValueSets" )
+@RequestMapping( value = DataValueSetController.RESOURCE_PATH )
public class DataValueSetController
{
+ public static final String RESOURCE_PATH = "/dataValueSets";
+
private static final Log log = LogFactory.getLog( DataValueSetController.class );
@Autowired
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndexController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndexController.java 2011-12-06 08:39:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndexController.java 2011-12-08 14:31:31 +0000
@@ -38,6 +38,10 @@
@Controller
public class IndexController
{
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( value = "/api", method = RequestMethod.GET )
public String getIndex( Model model )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java 2011-12-08 17:11:47 +0000
@@ -33,25 +33,36 @@
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.Indicators;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/indicators" )
+@RequestMapping( value = IndicatorController.RESOURCE_PATH )
public class IndicatorController
{
+ public static final String RESOURCE_PATH = "/indicators";
+
@Autowired
private IndicatorService indicatorService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getIndicators( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -84,4 +95,51 @@
return "indicator";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postIndicatorXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postIndicatorJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putIndicatorXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putIndicatorJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteIndicator( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java 2011-12-08 17:11:47 +0000
@@ -46,12 +46,18 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/indicatorGroups" )
+@RequestMapping( value = IndicatorGroupController.RESOURCE_PATH )
public class IndicatorGroupController
{
+ public static final String RESOURCE_PATH = "/indicatorGroups";
+
@Autowired
private IndicatorService indicatorService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getIndicatorGroups( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java 2011-12-08 17:11:47 +0000
@@ -33,25 +33,36 @@
import org.hisp.dhis.indicator.IndicatorGroupSets;
import org.hisp.dhis.indicator.IndicatorService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/indicatorGroupSets" )
+@RequestMapping( value = IndicatorGroupSetController.RESOURCE_PATH )
public class IndicatorGroupSetController
{
+ public static final String RESOURCE_PATH = "/indicatorGroupSets";
+
@Autowired
private IndicatorService indicatorService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getIndicatorGroupSets( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -84,4 +95,51 @@
return "indicatorGroupSet";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postIndicatorGroupSetXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postIndicatorGroupSetJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putIndicatorGroupSetXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putIndicatorGroupSetJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteIndicatorGroupSet( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java 2011-12-08 17:11:47 +0000
@@ -46,12 +46,18 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/indicatorTypes" )
+@RequestMapping( value = IndicatorTypeController.RESOURCE_PATH )
public class IndicatorTypeController
{
+ public static final String RESOURCE_PATH = "/indicatorTypes";
+
@Autowired
private IndicatorService indicatorService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getIndicatorTypes( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java 2011-12-08 14:31:31 +0000
@@ -28,9 +28,11 @@
*/
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulator;
@@ -39,11 +41,14 @@
import org.hisp.dhis.mapping.MappingService;
import org.hisp.dhis.mapping.Maps;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
@Controller
@RequestMapping( value = "/maps" )
@@ -55,6 +60,10 @@
@Autowired
MappingService mappingService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getMaps(IdentifiableObjectParams params, Model model, HttpServletRequest request ) throws IOException
{
@@ -73,7 +82,7 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getChart( @PathVariable String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
+ public String getMap( @PathVariable String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
MapView mapView = mappingService.getMapView( uid );
@@ -92,4 +101,51 @@
return "map";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postMapXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postMapJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putMapXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putMapJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteMap( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java 2011-12-07 13:29:09 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java 2011-12-08 17:11:47 +0000
@@ -6,25 +6,36 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.organisationunit.OrganisationUnits;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/organisationUnits" )
+@RequestMapping( value = OrganisationUnitController.RESOURCE_PATH )
public class OrganisationUnitController
{
+ public static final String RESOURCE_PATH = "/organisationUnits";
+
@Autowired
private OrganisationUnitService organisationUnitService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getOrganisationUnits( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -65,4 +76,51 @@
return "organisationUnit";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postOrganisationUnitXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postOrganisationUnitJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putOrganisationUnitXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putOrganisationUnitJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteOrganisationUnit( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java 2011-12-08 17:15:56 +0000
@@ -19,12 +19,18 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/organisationUnitGroups" )
+@RequestMapping( value = OrganisationUnitGroupController.RESOURCE_PATH )
public class OrganisationUnitGroupController
{
+ public static final String RESOURCE_PATH = "/organisationUnitGroups";
+
@Autowired
private OrganisationUnitGroupService organisationUnitGroupService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getOrganisationUnits( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java 2011-12-08 17:11:47 +0000
@@ -33,25 +33,36 @@
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSets;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/organisationUnitGroupSets" )
+@RequestMapping( value = OrganisationUnitGroupSetController.RESOURCE_PATH )
public class OrganisationUnitGroupSetController
{
+ public static final String RESOURCE_PATH = "/organisationUnitGroupSets";
+
@Autowired
private OrganisationUnitGroupService organisationUnitGroupService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getOrganisationUnitGroupSets( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -84,4 +95,51 @@
return "organisationUnitGroupSet";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postOrganisationUnitGroupSetXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postOrganisationUnitGroupSetJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putOrganisationUnitGroupSetXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putOrganisationUnitGroupSetJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteOrganisationUnitGroupSet( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java 2011-12-08 17:11:47 +0000
@@ -33,25 +33,36 @@
import org.hisp.dhis.organisationunit.OrganisationUnitLevels;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/organisationUnitLevels" )
+@RequestMapping( value = OrganisationUnitLevelController.RESOURCE_PATH )
public class OrganisationUnitLevelController
{
+ public static final String RESOURCE_PATH = "/organisationUnitLevels";
+
@Autowired
private OrganisationUnitService organisationUnitService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getOrganisationUnitLevels( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -84,4 +95,51 @@
return "organisationUnitLevel";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postOrganisationUnitLevelXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postOrganisationUnitLevelJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putOrganisationUnitLevelXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putOrganisationUnitLevelJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteOrganisationUnitLevel( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceController.java 2011-12-08 17:11:47 +0000
@@ -41,9 +41,15 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/resources" )
+@RequestMapping( value = ResourceController.RESOURCE_PATH )
public class ResourceController
{
+ public static final String RESOURCE_PATH = "/resources";
+
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getResources( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java 2011-12-06 15:03:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java 2011-12-08 17:11:47 +0000
@@ -33,25 +33,36 @@
import org.hisp.dhis.user.UserService;
import org.hisp.dhis.user.Users;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
import java.util.ArrayList;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/users" )
+@RequestMapping( value = UserController.RESOURCE_PATH )
public class UserController
{
+ public static final String RESOURCE_PATH = "/users";
+
@Autowired
private UserService userService;
+ //-------------------------------------------------------------------------------------------------------
+ // GET
+ //-------------------------------------------------------------------------------------------------------
+
@RequestMapping( method = RequestMethod.GET )
public String getUsers( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
@@ -84,4 +95,51 @@
return "user";
}
+
+ //-------------------------------------------------------------------------------------------------------
+ // POST
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postUserXML( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.CREATED )
+ public void postUserJSON( HttpServletResponse response, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // PUT
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putUserXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void putUserJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+ }
+
+ //-------------------------------------------------------------------------------------------------------
+ // DELETE
+ //-------------------------------------------------------------------------------------------------------
+
+ @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+ @ResponseStatus( value = HttpStatus.NO_CONTENT )
+ public void deleteUser( @PathVariable( "uid" ) String uid ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+ }
}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/HibernateObjectPersister.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/HibernateObjectPersister.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/HibernateObjectPersister.java 2011-12-09 15:05:53 +0000
@@ -0,0 +1,202 @@
+package org.hisp.dhis.api.utils;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.chart.Chart;
+import org.hisp.dhis.dataelement.*;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.user.User;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Component
+public class HibernateObjectPersister implements ObjectPersister
+{
+ @Autowired
+ private DataElementService dataElementService;
+
+ @Autowired
+ private DataElementCategoryService dataElementCategoryService;
+
+ @Autowired
+ private DataSetService dataSetService;
+
+ @Override
+ public void persistAttribute( Attribute attribute )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void persistDataElement( DataElement dataElement )
+ {
+ if ( dataElement.getCategoryCombo() != null )
+ {
+ DataElementCategoryCombo dataElementCategoryCombo = dataElementCategoryService.getDataElementCategoryCombo( dataElement.getCategoryCombo().getUid() );
+ dataElement.setCategoryCombo( dataElementCategoryCombo );
+ }
+
+ Collection<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>( dataElement.getGroups() );
+ Collection<DataSet> dataSets = new ArrayList<DataSet>( dataElement.getDataSets() );
+ dataElement.getGroups().clear();
+ dataElement.getDataSets().clear();
+
+ dataElementService.addDataElement( dataElement );
+
+ for ( DataElementGroup dataElementGroup : dataElementGroups )
+ {
+ dataElementGroup = dataElementService.getDataElementGroup( dataElementGroup.getUid() );
+ dataElement.addDataElementGroup( dataElementGroup );
+ }
+
+ for ( DataSet dataSet : dataSets )
+ {
+ dataSet = dataSetService.getDataSet( dataSet.getUid() );
+ dataSet.addDataElement( dataElement );
+ }
+
+ dataElementService.updateDataElement( dataElement );
+ }
+
+ @Override
+ public void persistDataElementGroup( DataElementGroup dataElementGroup )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistDataElementGroupSet( DataElementGroupSet dataElementGroupSet )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistCategory( DataElementCategory category )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistCategoryOption( DataElementCategoryOption categoryOption )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistCategoryCombo( DataElementCategoryCombo categoryCombo )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistIndicator( Indicator indicator )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistIndicatorType( IndicatorType indicatorType )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistIndicatorGroup( IndicatorGroup indicatorGroup )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistIndicatorGroupSet( IndicatorGroupSet indicatorGroupSet )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistOrganisationUnit( OrganisationUnit organisationUnit )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistOrganisationUnitLevel( OrganisationUnitLevel organisationUnitLevel )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistOrganisationUnitGroupSet( OrganisationUnitGroupSet organisationUnitGroupSet )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistDataSet( DataSet dataSet )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistChart( Chart chart )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void persistUser( User user )
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ObjectPersister.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ObjectPersister.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ObjectPersister.java 2011-12-09 15:05:53 +0000
@@ -0,0 +1,86 @@
+package org.hisp.dhis.api.utils;
+
+/*
+ * Copyright (c) 2004-2011, 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 org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.chart.Chart;
+import org.hisp.dhis.dataelement.*;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.user.User;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public interface ObjectPersister
+{
+ public void persistAttribute( Attribute attribute );
+
+ public void persistDataElement( DataElement dataElement );
+
+ public void persistDataElementGroup( DataElementGroup dataElementGroup );
+
+ public void persistDataElementGroupSet( DataElementGroupSet dataElementGroupSet );
+
+ public void persistCategory( DataElementCategory category );
+
+ public void persistCategoryOption( DataElementCategoryOption categoryOption );
+
+ public void persistCategoryCombo( DataElementCategoryCombo categoryCombo );
+
+ public void persistCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo );
+
+ public void persistIndicator( Indicator indicator );
+
+ public void persistIndicatorType( IndicatorType indicatorType );
+
+ public void persistIndicatorGroup( IndicatorGroup indicatorGroup );
+
+ public void persistIndicatorGroupSet( IndicatorGroupSet indicatorGroupSet );
+
+ public void persistOrganisationUnit( OrganisationUnit organisationUnit );
+
+ public void persistOrganisationUnitLevel( OrganisationUnitLevel organisationUnitLevel );
+
+ public void persistOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup );
+
+ public void persistOrganisationUnitGroupSet( OrganisationUnitGroupSet organisationUnitGroupSet );
+
+ public void persistDataSet( DataSet dataSet );
+
+ public void persistChart( Chart chart );
+
+ public void persistUser( User user );
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java 2011-12-07 12:27:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java 2011-12-09 18:08:05 +0000
@@ -64,6 +64,9 @@
static
{
+ resourcePaths.put( Attributes.class, "attributeTypes" );
+ resourcePaths.put( Attribute.class, "attributeTypes" );
+
resourcePaths.put( DataElementCategories.class, "categories" );
resourcePaths.put( DataElementCategory.class, "categories" );
@@ -719,7 +722,9 @@
private void populateIdentifiableObject( BaseIdentifiableObject baseIdentifiableObject )
{
if ( baseIdentifiableObject != null )
+ {
baseIdentifiableObject.setLink( getPathWithUid( baseIdentifiableObject ) );
+ }
}
private String getPathWithUid( BaseIdentifiableObject baseIdentifiableObject )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ExtendedMappingJacksonView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ExtendedMappingJacksonView.java 2011-12-06 11:36:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ExtendedMappingJacksonView.java 2011-12-08 17:04:19 +0000
@@ -27,15 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.codehaus.jackson.JsonEncoding;
-import org.codehaus.jackson.JsonFactory;
-import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.map.AnnotationIntrospector;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
import org.codehaus.jackson.map.util.JSONPObject;
-import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
import org.springframework.web.servlet.view.json.MappingJacksonJsonView;
import javax.servlet.http.HttpServletRequest;
@@ -84,17 +76,6 @@
model = ViewUtils.filterModel( model );
Object value = model.get( "model" );
- ObjectMapper objectMapper = new ObjectMapper();
-
- AnnotationIntrospector jacksonAnnotationIntrospector = new JacksonAnnotationIntrospector();
- AnnotationIntrospector jaxAnnotationIntrospector = new JaxbAnnotationIntrospector();
- AnnotationIntrospector pair = new AnnotationIntrospector.Pair( jacksonAnnotationIntrospector, jaxAnnotationIntrospector );
-
- objectMapper.setAnnotationIntrospector( pair );
-
- JsonFactory jf = objectMapper.getJsonFactory();
- JsonGenerator jg = jf.createJsonGenerator( response.getOutputStream(), JsonEncoding.UTF8 );
-
if ( withPadding )
{
String callback = request.getParameter( callbackParameter );
@@ -104,12 +85,9 @@
callback = paddingFunction;
}
- JSONPObject valueWithPadding = valueWithPadding = new JSONPObject( callback, value );
- jg.writeObject( valueWithPadding );
- }
- else
- {
- jg.writeObject( value );
- }
+ value = new JSONPObject( callback, value );
+ }
+
+ JacksonUtils.writeObject( value, response.getOutputStream() );
}
}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/JacksonUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/JacksonUtils.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/JacksonUtils.java 2011-12-09 18:08:05 +0000
@@ -0,0 +1,73 @@
+package org.hisp.dhis.api.view;
+
+import org.codehaus.jackson.JsonEncoding;
+import org.codehaus.jackson.JsonFactory;
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.map.AnnotationIntrospector;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
+import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class JacksonUtils
+{
+ public static JsonFactory createJsonFactory()
+ {
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ AnnotationIntrospector jacksonAnnotationIntrospector = new JacksonAnnotationIntrospector();
+ //AnnotationIntrospector jaxAnnotationIntrospector = new JaxbAnnotationIntrospector();
+ //AnnotationIntrospector pair = new AnnotationIntrospector.Pair( jacksonAnnotationIntrospector, jaxAnnotationIntrospector );
+
+ objectMapper.setAnnotationIntrospector( jacksonAnnotationIntrospector );
+ objectMapper.setSerializationInclusion( JsonSerialize.Inclusion.NON_NULL );
+ objectMapper.configure( SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false );
+ objectMapper.configure( SerializationConfig.Feature.WRITE_EMPTY_JSON_ARRAYS, false );
+ objectMapper.configure( SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false );
+ objectMapper.configure( SerializationConfig.Feature.AUTO_DETECT_FIELDS, false );
+ objectMapper.configure( SerializationConfig.Feature.AUTO_DETECT_GETTERS, false );
+ objectMapper.configure( SerializationConfig.Feature.AUTO_DETECT_IS_GETTERS, false );
+
+ JsonFactory factory = objectMapper.getJsonFactory();
+ factory.enable( JsonGenerator.Feature.QUOTE_FIELD_NAMES );
+
+ return factory;
+ }
+
+ //---------------------------------------------------------------------------------------------------
+ // Json Serializer
+ //---------------------------------------------------------------------------------------------------
+
+ public static JsonGenerator createJsonGenerator( OutputStream output ) throws IOException
+ {
+ return JacksonUtils.createJsonFactory().createJsonGenerator( output, JsonEncoding.UTF8 );
+ }
+
+ public static void writeObject( Object value, OutputStream output ) throws IOException
+ {
+ JacksonUtils.createJsonGenerator( output ).writeObject( value );
+ }
+
+ //---------------------------------------------------------------------------------------------------
+ // Json Deserializer
+ //---------------------------------------------------------------------------------------------------
+
+ public static JsonParser createJsonParser( InputStream input ) throws IOException
+ {
+ return JacksonUtils.createJsonFactory().createJsonParser( input );
+ }
+
+ public static <T> T readValueAs( Class<?> clazz, InputStream input ) throws IOException
+ {
+ return (T) JacksonUtils.createJsonParser( input ).readValueAs( clazz );
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Jaxb2Utils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Jaxb2Utils.java 2011-12-06 13:19:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Jaxb2Utils.java 2011-12-09 13:41:05 +0000
@@ -27,10 +27,20 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.BaseNameableObject;
+import org.hisp.dhis.common.adapter.DataElementGroupXmlAdapter;
+import org.hisp.dhis.common.adapter.DataSetXmlAdapter;
+import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.dataset.DataSet;
+
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.io.InputStream;
public class Jaxb2Utils
{
@@ -45,4 +55,19 @@
return marshaller;
}
+
+ public static Unmarshaller createUnmarshaller( Class<?> clazz )
+ throws JAXBException
+ {
+ JAXBContext context = JAXBContext.newInstance( clazz );
+
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+
+ return unmarshaller;
+ }
+
+ public static <T> T unmarshal( Class<?> clazz, InputStream input ) throws JAXBException
+ {
+ return (T) Jaxb2Utils.createUnmarshaller( clazz ).unmarshal( input );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java 2011-12-07 13:29:09 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Resources.java 2011-12-09 18:08:05 +0000
@@ -101,7 +101,7 @@
List<RequestMethod> requestMethods = Arrays.asList( defaultRequestMethods );
List<MediaType> mediaTypes = Arrays.asList( defaultMediaTypes );
- resources.add( new Resource( "Attributes", Attributes.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "AttributeTypes", Attributes.class, requestMethods, mediaTypes ) );
resources.add( new Resource( "Charts", Charts.class, requestMethods, mediaTypes ) );
resources.add( new Resource( "Maps", Maps.class, requestMethods, mediaTypes ) );
resources.add( new Resource( "CompleteDataSetRegistrations", CompleteDataSetRegistrations.class, requestMethods, mediaTypes ) );
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/attributeType.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/attributeType.xsl 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/attributeType.xsl 2011-12-09 18:08:05 +0000
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:d="http://dhis2.org/schema/dxf/2.0"
+ >
+
+ <xsl:template match="d:attributeType">
+ <div class="attributeType">
+ <h2> <xsl:value-of select="@name" /> </h2>
+
+ <table border="1">
+ <tr>
+ <td>ID</td>
+ <td> <xsl:value-of select="@id" /> </td>
+ </tr>
+ <tr>
+ <td>Last Updated</td>
+ <td> <xsl:value-of select="@lastUpdated" /> </td>
+ </tr>
+ <tr>
+ <td>Mandatory</td>
+ <td> <xsl:value-of select="d:mandatory" /> </td>
+ </tr>
+ <tr>
+ <td>Value Type</td>
+ <td> <xsl:value-of select="d:valueType" /> </td>
+ </tr>
+ <tr>
+ <td>Applicable for DataElements</td>
+ <td> <xsl:value-of select="d:dataElementAttribute" /> </td>
+ </tr>
+ <tr>
+ <td>Applicable for Indicators</td>
+ <td> <xsl:value-of select="d:indicatorAttribute" /> </td>
+ </tr>
+ <tr>
+ <td>Applicable for OrganisationUnits</td>
+ <td> <xsl:value-of select="d:organisationUnitAttribute" /> </td>
+ </tr>
+ <tr>
+ <td>Applicable for Users</td>
+ <td> <xsl:value-of select="d:userAttribute" /> </td>
+ </tr>
+ <tr>
+ <td>Sort Order</td>
+ <td> <xsl:value-of select="d:sortOrder" /> </td>
+ </tr>
+ </table>
+
+ </div>
+ </xsl:template>
+
+</xsl:stylesheet>
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl 2011-12-07 14:04:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl 2011-12-09 18:08:05 +0000
@@ -11,7 +11,7 @@
d:categoryOptions|d:categoryOptionCombos|d:dataElements|d:indicators|
d:organisationUnits|d:dataElementGroups|d:dataElementGroupSets|
d:indicatorGroups|d:indicatorGroupSets|d:organisationUnitGroups|
- d:organisationUnitGroupSets|d:indicatorTypes">
+ d:organisationUnitGroupSets|d:indicatorTypes|d:attributeTypes">
<h3> <xsl:value-of select="local-name()"/> </h3>
<table border="1">
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl 2011-12-07 16:03:19 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl 2011-12-09 18:08:05 +0000
@@ -34,6 +34,7 @@
<xsl:include href="organisationUnitGroup.xsl"/>
<xsl:include href="organisationUnitGroupSet.xsl"/>
<xsl:include href="dataSet.xsl"/>
+ <xsl:include href="attributeType.xsl"/>
<!-- etc ... -->
</xsl:stylesheet>