dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02659
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 899: Added interface DimensionSet and made DataElement, Indicator and CategoryCombo implement it. Gene...
------------------------------------------------------------
revno: 899
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Thu 2009-10-22 09:54:37 +0200
message:
Added interface DimensionSet and made DataElement, Indicator and CategoryCombo implement it. Generalised method DataValue.getDimensions( DimensionSet ).
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionSet.java
modified:
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/DataElementGroupSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.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.
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionSet.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionSet.java 2009-10-22 07:54:37 +0000
@@ -0,0 +1,40 @@
+package org.hisp.dhis.common;
+
+/*
+ * Copyright (c) 2004-2007, 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.List;
+
+/**
+ * @author Lars Helge Overland
+ */
+public interface DimensionSet
+{
+ String getName();
+
+ List<? extends Dimension> getDimensions();
+}
=== 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 2009-10-21 18:41:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2009-10-22 07:54:37 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.Dimension;
import org.hisp.dhis.common.DimensionOption;
+import org.hisp.dhis.common.DimensionSet;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.datadictionary.ExtendedDataElement;
import org.hisp.dhis.dataset.DataSet;
@@ -55,7 +56,7 @@
* @version $Id: DataElement.java 5540 2008-08-19 10:47:07Z larshelg $
*/
public class DataElement
- extends IdentifiableObject implements DimensionOption
+ extends IdentifiableObject implements DimensionOption, DimensionSet
{
public static final String TYPE_STRING = "string";
public static final String TYPE_INT = "int";
@@ -126,7 +127,7 @@
/**
* A Set of DataElementGroupSets.
*/
- private Set<DataElementGroupSet> groupSets = new HashSet<DataElementGroupSet>();
+ private List<DataElementGroupSet> groupSets = new ArrayList<DataElementGroupSet>();
// -------------------------------------------------------------------------
// Constructors
@@ -203,6 +204,11 @@
}
}
+ public List<? extends Dimension> getDimensions()
+ {
+ return groupSets;
+ }
+
// -------------------------------------------------------------------------
// hashCode, equals and toString
// -------------------------------------------------------------------------
@@ -425,12 +431,12 @@
this.aggregationLevels = aggregationLevels;
}
- public Set<DataElementGroupSet> getGroupSets()
+ public List<DataElementGroupSet> getGroupSets()
{
return groupSets;
}
- public void setGroupSets( Set<DataElementGroupSet> groupSets )
+ public void setGroupSets( List<DataElementGroupSet> groupSets )
{
this.groupSets = groupSets;
}
=== 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 2009-10-15 18:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java 2009-10-22 07:54:37 +0000
@@ -33,20 +33,26 @@
import java.util.List;
import java.util.Set;
+import org.hisp.dhis.common.Dimension;
+import org.hisp.dhis.common.DimensionSet;
+
/**
* @author Abyot Aselefew
* @version $Id$
*/
public class DataElementCategoryCombo
- implements Serializable
+ implements Serializable, DimensionSet
{
public static final String DEFAULT_CATEGORY_COMBO_NAME = "default";
/**
- * The database internal identifier for this DataElementCategoryCombo.
+ * The database internal identifier.
*/
private int id;
+ /**
+ * The name.
+ */
private String name;
/**
@@ -55,9 +61,18 @@
private List<DataElementCategory> categories = new ArrayList<DataElementCategory>();
/**
- *
+ * A set of category option combos.
*/
private Set<DataElementCategoryOptionCombo> optionCombos = new HashSet<DataElementCategoryOptionCombo>();
+
+ // -------------------------------------------------------------------------
+ // Constructors
+ // -------------------------------------------------------------------------
+
+ public List<? extends Dimension> getDimensions()
+ {
+ return categories;
+ }
// -------------------------------------------------------------------------
// Constructors
=== 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 2009-10-21 18:41:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2009-10-22 07:54:37 +0000
@@ -73,7 +73,6 @@
{
for ( DataElementGroup group : members )
{
- System.out.println( "group: " + group + " object " + object );
if ( group.getMembers().contains( object ) )
{
return group;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2009-10-21 18:41:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2009-10-22 07:54:37 +0000
@@ -34,10 +34,10 @@
import org.hisp.dhis.common.Dimension;
import org.hisp.dhis.common.DimensionOption;
+import org.hisp.dhis.common.DimensionSet;
+import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.source.Source;
@@ -164,13 +164,13 @@
return dimensions;
}
- public Map<Dimension, DimensionOption> getDimensions( DataElement dataElement )
+ public Map<Dimension, DimensionOption> getDimensions( DimensionSet dimensionSet )
{
Map<Dimension, DimensionOption> dimensions = getDimensions();
- for ( DataElementGroupSet groupSet : dataElement.getGroupSets() )
+ for ( Dimension dimension : dimensionSet.getDimensions() )
{
- dimensions.put( groupSet, groupSet.getDimensionOption( this.dataElement ) );
+ dimensions.put( dimension, dimension.getDimensionOption( dataElement ) );
}
return dimensions;
=== 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 2009-10-21 18:41:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java 2009-10-22 07:54:37 +0000
@@ -27,9 +27,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.HashSet;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
+import org.hisp.dhis.common.Dimension;
+import org.hisp.dhis.common.DimensionSet;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.datadictionary.ExtendedDataElement;
@@ -38,7 +40,7 @@
* @version $Id: Indicator.java 5540 2008-08-19 10:47:07Z larshelg $
*/
public class Indicator
- extends IdentifiableObject
+ extends IdentifiableObject implements DimensionSet
{
private Boolean annualized;
@@ -62,7 +64,7 @@
private String url;
- private Set<IndicatorGroupSet> groupSets = new HashSet<IndicatorGroupSet>();
+ private List<IndicatorGroupSet> groupSets = new ArrayList<IndicatorGroupSet>();
// -------------------------------------------------------------------------
// Constructors
@@ -90,6 +92,15 @@
this.denominatorDescription = denominatorDescription;
this.denominatorAggregationOperator = denominatorAggregationOperator;
}
+
+ // -------------------------------------------------------------------------
+ // Dimension
+ // -------------------------------------------------------------------------
+
+ public List<? extends Dimension> getDimensions()
+ {
+ return groupSets;
+ }
// -------------------------------------------------------------------------
// hashCode and equals
@@ -134,7 +145,6 @@
// Getters and setters
// -------------------------------------------------------------------------
-
public Boolean getAnnualized()
{
return annualized;
@@ -245,12 +255,12 @@
this.url = url;
}
- public Set<IndicatorGroupSet> getGroupSets()
+ public List<IndicatorGroupSet> getGroupSets()
{
return groupSets;
}
- public void setGroupSets( Set<IndicatorGroupSet> groupSets )
+ public void setGroupSets( List<IndicatorGroupSet> groupSets )
{
this.groupSets = groupSets;
}