dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33730
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17271: Introduced BaseMetaDataCollectionObject, which encapsulates lists of associations to meta data ob...
------------------------------------------------------------
revno: 17271
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-10-25 10:28:23 +0200
message:
Introduced BaseMetaDataCollectionObject, which encapsulates lists of associations to meta data objects. Made BaseAnalyticalObject extend it.
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseMetaDataCollectionObject.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java
--
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/common/BaseAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2014-10-25 08:28:23 +0000
@@ -54,21 +54,16 @@
import java.util.Map;
import org.apache.commons.lang.StringUtils;
-import org.hisp.dhis.common.adapter.JacksonPeriodDeserializer;
-import org.hisp.dhis.common.adapter.JacksonPeriodSerializer;
import org.hisp.dhis.common.annotation.Scanned;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.DimensionalView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataelement.CategoryOptionGroup;
-import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryDimension;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementOperand;
-import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.ConfigurablePeriod;
@@ -101,7 +96,7 @@
*/
@JacksonXmlRootElement( localName = "analyticalObject", namespace = DxfNamespaces.DXF_2_0 )
public abstract class BaseAnalyticalObject
- extends BaseIdentifiableObject
+ extends BaseMetaDataCollectionObject
implements AnalyticalObject
{
public static final String NUMBER_FORMATTING_COMMA = "comma";
@@ -117,35 +112,9 @@
// -------------------------------------------------------------------------
@Scanned
- protected List<Indicator> indicators = new ArrayList<>();
-
- @Scanned
- protected List<DataElement> dataElements = new ArrayList<>();
-
- @Scanned
- protected List<DataElementOperand> dataElementOperands = new ArrayList<>();
-
- @Scanned
- protected List<DataSet> dataSets = new ArrayList<>();
-
- @Scanned
- protected List<OrganisationUnit> organisationUnits = new ArrayList<>();
-
- @Scanned
- protected List<Period> periods = new ArrayList<>();
-
- protected RelativePeriods relatives;
-
- @Scanned
protected List<DataElementCategoryDimension> categoryDimensions = new ArrayList<>();
@Scanned
- protected List<DataElementGroup> dataElementGroups = new ArrayList<>();
-
- @Scanned
- protected List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<>();
-
- @Scanned
protected List<CategoryOptionGroup> categoryOptionGroups = new ArrayList<>();
@Scanned
@@ -161,9 +130,6 @@
protected boolean userOrganisationUnitGrandChildren;
@Scanned
- protected List<Integer> organisationUnitLevels = new ArrayList<>();
-
- @Scanned
protected List<OrganisationUnitGroup> itemOrganisationUnitGroups = new ArrayList<>();
protected boolean rewindRelativePeriods;
@@ -783,16 +749,16 @@
periods.clear();
relatives = null;
organisationUnits.clear();
- categoryDimensions.clear();
dataElementGroups.clear();
organisationUnitGroups.clear();
+ organisationUnitLevels.clear();
+ categoryDimensions.clear();
categoryOptionGroups.clear();
attributeDimensions.clear();
dataElementDimensions.clear();
userOrganisationUnit = false;
userOrganisationUnitChildren = false;
userOrganisationUnitGrandChildren = false;
- organisationUnitLevels.clear();
itemOrganisationUnitGroups.clear();
}
@@ -814,16 +780,16 @@
periods.addAll( object.getPeriods() );
relatives = object.getRelatives() == null ? relatives : object.getRelatives();
organisationUnits.addAll( object.getOrganisationUnits() );
- categoryDimensions.addAll( object.getCategoryDimensions() );
dataElementGroups.addAll( object.getDataElementGroups() );
organisationUnitGroups.addAll( object.getOrganisationUnitGroups() );
+ organisationUnitLevels.addAll( object.getOrganisationUnitLevels() );
+ categoryDimensions.addAll( object.getCategoryDimensions() );
categoryOptionGroups.addAll( object.getCategoryOptionGroups() );
attributeDimensions.addAll( object.getAttributeDimensions() );
dataElementDimensions.addAll( object.getDataElementDimensions() );
userOrganisationUnit = object.isUserOrganisationUnit();
userOrganisationUnitChildren = object.isUserOrganisationUnitChildren();
userOrganisationUnitGrandChildren = object.isUserOrganisationUnitGrandChildren();
- organisationUnitLevels.addAll( object.getOrganisationUnitLevels() );
itemOrganisationUnitGroups = object.getItemOrganisationUnitGroups();
rewindRelativePeriods = object.isRewindRelativePeriods();
digitGroupSeparator = object.getDigitGroupSeparator();
@@ -836,110 +802,6 @@
// Getters and setters
// -------------------------------------------------------------------------
- @JsonProperty
- @JsonSerialize( contentAs = BaseNameableObject.class )
- @JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlElementWrapper( localName = "indicators", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "indicator", namespace = DxfNamespaces.DXF_2_0 )
- public List<Indicator> getIndicators()
- {
- return indicators;
- }
-
- public void setIndicators( List<Indicator> indicators )
- {
- this.indicators = indicators;
- }
-
- @JsonProperty
- @JsonSerialize( contentAs = BaseNameableObject.class )
- @JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlElementWrapper( localName = "dataElements", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "dataElement", namespace = DxfNamespaces.DXF_2_0 )
- public List<DataElement> getDataElements()
- {
- return dataElements;
- }
-
- public void setDataElements( List<DataElement> dataElements )
- {
- this.dataElements = dataElements;
- }
-
- @JsonProperty
- @JsonSerialize( contentAs = BaseIdentifiableObject.class )
- @JsonView( DetailedView.class )
- @JacksonXmlElementWrapper( localName = "dataElementOperands", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "dataElementOperand", namespace = DxfNamespaces.DXF_2_0 )
- public List<DataElementOperand> getDataElementOperands()
- {
- return dataElementOperands;
- }
-
- public void setDataElementOperands( List<DataElementOperand> dataElementOperands )
- {
- this.dataElementOperands = dataElementOperands;
- }
-
- @JsonProperty
- @JsonSerialize( contentAs = BaseNameableObject.class )
- @JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlElementWrapper( localName = "dataSets", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "dataSet", namespace = DxfNamespaces.DXF_2_0 )
- public List<DataSet> getDataSets()
- {
- return dataSets;
- }
-
- public void setDataSets( List<DataSet> dataSets )
- {
- this.dataSets = dataSets;
- }
-
- @JsonProperty
- @JsonSerialize( contentAs = BaseNameableObject.class )
- @JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 )
- public List<OrganisationUnit> getOrganisationUnits()
- {
- return organisationUnits;
- }
-
- public void setOrganisationUnits( List<OrganisationUnit> organisationUnits )
- {
- this.organisationUnits = organisationUnits;
- }
-
- @JsonProperty
- @JsonSerialize( contentUsing = JacksonPeriodSerializer.class )
- @JsonDeserialize( contentUsing = JacksonPeriodDeserializer.class )
- @JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlElementWrapper( localName = "periods", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "period", namespace = DxfNamespaces.DXF_2_0 )
- public List<Period> getPeriods()
- {
- return periods;
- }
-
- public void setPeriods( List<Period> periods )
- {
- this.periods = periods;
- }
-
- @JsonProperty( value = "relativePeriods" )
- @JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public RelativePeriods getRelatives()
- {
- return relatives;
- }
-
- public void setRelatives( RelativePeriods relatives )
- {
- this.relatives = relatives;
- }
-
public List<DataElementCategoryDimension> getCategoryDimensions()
{
return categoryDimensions;
@@ -952,34 +814,6 @@
@JsonProperty
@JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlElementWrapper( localName = "dataElementGroups", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "dataElementGroup", namespace = DxfNamespaces.DXF_2_0 )
- public List<DataElementGroup> getDataElementGroups()
- {
- return dataElementGroups;
- }
-
- public void setDataElementGroups( List<DataElementGroup> dataElementGroups )
- {
- this.dataElementGroups = dataElementGroups;
- }
-
- @JsonProperty
- @JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0 )
- public List<OrganisationUnitGroup> getOrganisationUnitGroups()
- {
- return organisationUnitGroups;
- }
-
- public void setOrganisationUnitGroups( List<OrganisationUnitGroup> organisationUnitGroups )
- {
- this.organisationUnitGroups = organisationUnitGroups;
- }
-
- @JsonProperty
- @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlElementWrapper( localName = "categoryOptionGroups", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "categoryOptionGroup", namespace = DxfNamespaces.DXF_2_0 )
public List<CategoryOptionGroup> getCategoryOptionGroups()
@@ -1061,20 +895,6 @@
@JsonProperty
@JsonView( { DetailedView.class, ExportView.class } )
- @JacksonXmlElementWrapper( localName = "organisationUnitLevels", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "organisationUnitLevel", namespace = DxfNamespaces.DXF_2_0 )
- public List<Integer> getOrganisationUnitLevels()
- {
- return organisationUnitLevels;
- }
-
- public void setOrganisationUnitLevels( List<Integer> organisationUnitLevels )
- {
- this.organisationUnitLevels = organisationUnitLevels;
- }
-
- @JsonProperty
- @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlElementWrapper( localName = "itemOrganisationUnitGroups", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "itemOrganisationUnitGroup", namespace = DxfNamespaces.DXF_2_0 )
public List<OrganisationUnitGroup> getItemOrganisationUnitGroups()
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseMetaDataCollectionObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseMetaDataCollectionObject.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseMetaDataCollectionObject.java 2014-10-25 08:28:23 +0000
@@ -0,0 +1,240 @@
+package org.hisp.dhis.common;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.common.adapter.JacksonPeriodDeserializer;
+import org.hisp.dhis.common.adapter.JacksonPeriodSerializer;
+import org.hisp.dhis.common.annotation.Scanned;
+import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.ExportView;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.RelativePeriods;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+
+/**
+* @author Lars Helge Overland
+*/
+public class BaseMetaDataCollectionObject
+ extends BaseIdentifiableObject
+{
+ @Scanned
+ protected List<Indicator> indicators = new ArrayList<>();
+
+ @Scanned
+ protected List<DataElement> dataElements = new ArrayList<>();
+
+ @Scanned
+ protected List<DataElementOperand> dataElementOperands = new ArrayList<>();
+
+ @Scanned
+ protected List<DataSet> dataSets = new ArrayList<>();
+
+ @Scanned
+ protected List<OrganisationUnit> organisationUnits = new ArrayList<>();
+
+ @Scanned
+ protected List<Period> periods = new ArrayList<>();
+
+ protected RelativePeriods relatives;
+
+ @Scanned
+ protected List<DataElementGroup> dataElementGroups = new ArrayList<>();
+
+ @Scanned
+ protected List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<>();
+
+ @Scanned
+ protected List<Integer> organisationUnitLevels = new ArrayList<>();
+
+ // -------------------------------------------------------------------------
+ // Getters and setters
+ // -------------------------------------------------------------------------
+
+ @JsonProperty
+ @JsonSerialize( contentAs = BaseNameableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "indicators", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "indicator", namespace = DxfNamespaces.DXF_2_0 )
+ public List<Indicator> getIndicators()
+ {
+ return indicators;
+ }
+
+ public void setIndicators( List<Indicator> indicators )
+ {
+ this.indicators = indicators;
+ }
+
+ @JsonProperty
+ @JsonSerialize( contentAs = BaseNameableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "dataElements", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "dataElement", namespace = DxfNamespaces.DXF_2_0 )
+ public List<DataElement> getDataElements()
+ {
+ return dataElements;
+ }
+
+ public void setDataElements( List<DataElement> dataElements )
+ {
+ this.dataElements = dataElements;
+ }
+
+ @JsonProperty
+ @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+ @JsonView( DetailedView.class )
+ @JacksonXmlElementWrapper( localName = "dataElementOperands", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "dataElementOperand", namespace = DxfNamespaces.DXF_2_0 )
+ public List<DataElementOperand> getDataElementOperands()
+ {
+ return dataElementOperands;
+ }
+
+ public void setDataElementOperands( List<DataElementOperand> dataElementOperands )
+ {
+ this.dataElementOperands = dataElementOperands;
+ }
+
+ @JsonProperty
+ @JsonSerialize( contentAs = BaseNameableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "dataSets", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "dataSet", namespace = DxfNamespaces.DXF_2_0 )
+ public List<DataSet> getDataSets()
+ {
+ return dataSets;
+ }
+
+ public void setDataSets( List<DataSet> dataSets )
+ {
+ this.dataSets = dataSets;
+ }
+
+ @JsonProperty
+ @JsonSerialize( contentAs = BaseNameableObject.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 )
+ public List<OrganisationUnit> getOrganisationUnits()
+ {
+ return organisationUnits;
+ }
+
+ public void setOrganisationUnits( List<OrganisationUnit> organisationUnits )
+ {
+ this.organisationUnits = organisationUnits;
+ }
+
+ @JsonProperty
+ @JsonSerialize( contentUsing = JacksonPeriodSerializer.class )
+ @JsonDeserialize( contentUsing = JacksonPeriodDeserializer.class )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "periods", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "period", namespace = DxfNamespaces.DXF_2_0 )
+ public List<Period> getPeriods()
+ {
+ return periods;
+ }
+
+ public void setPeriods( List<Period> periods )
+ {
+ this.periods = periods;
+ }
+
+ @JsonProperty( value = "relativePeriods" )
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public RelativePeriods getRelatives()
+ {
+ return relatives;
+ }
+
+ public void setRelatives( RelativePeriods relatives )
+ {
+ this.relatives = relatives;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "dataElementGroups", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "dataElementGroup", namespace = DxfNamespaces.DXF_2_0 )
+ public List<DataElementGroup> getDataElementGroups()
+ {
+ return dataElementGroups;
+ }
+
+ public void setDataElementGroups( List<DataElementGroup> dataElementGroups )
+ {
+ this.dataElementGroups = dataElementGroups;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0 )
+ public List<OrganisationUnitGroup> getOrganisationUnitGroups()
+ {
+ return organisationUnitGroups;
+ }
+
+ public void setOrganisationUnitGroups( List<OrganisationUnitGroup> organisationUnitGroups )
+ {
+ this.organisationUnitGroups = organisationUnitGroups;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlElementWrapper( localName = "organisationUnitLevels", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "organisationUnitLevel", namespace = DxfNamespaces.DXF_2_0 )
+ public List<Integer> getOrganisationUnitLevels()
+ {
+ return organisationUnitLevels;
+ }
+
+ public void setOrganisationUnitLevels( List<Integer> organisationUnitLevels )
+ {
+ this.organisationUnitLevels = organisationUnitLevels;
+ }
+}