dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02972
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 982: Introduced interface DimensionOptionElement. CategoryOptionCombo and DataElement now implement th...
------------------------------------------------------------
revno: 982
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Thu 2009-11-05 20:04:58 +0100
message:
Introduced interface DimensionOptionElement. CategoryOptionCombo and DataElement now implement this interface. This allowed for turning Dimension into an abstract class and implementing a general implementation of the Dimension.getDimensionOption( DimensionOptionElement ) method there.
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/DimensionOptionElement.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/DataElementCategory.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/DataElementCategoryOption.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.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/dimension/Dimension.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/DimensionOption.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/Measure.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/period/Period.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/source/Source.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/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2009-11-03 11:04:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2009-11-05 19:04:58 +0000
@@ -40,6 +40,7 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dimension.Dimension;
import org.hisp.dhis.dimension.DimensionOption;
+import org.hisp.dhis.dimension.DimensionOptionElement;
import org.hisp.dhis.dimension.DimensionSet;
import org.hisp.dhis.period.PeriodType;
@@ -53,11 +54,14 @@
* Hiearchies of DataElements are used to give more fine- or course-grained
* representations of the entities.
*
+ * DataElement acts as a DimensionSet in the dynamic dimensional model, and as a
+ * DimensionOption in the static DataElement dimension.
+ *
* @author Kristian Nordal
* @version $Id: DataElement.java 5540 2008-08-19 10:47:07Z larshelg $
*/
public class DataElement
- extends IdentifiableObject implements DimensionOption, DimensionSet
+ extends IdentifiableObject implements DimensionSet, DimensionOption, DimensionOptionElement
{
public static final String TYPE_STRING = "string";
public static final String TYPE_INT = "int";
@@ -155,7 +159,7 @@
public static Dimension DIMENSION = new DataElementDimension();
public static class DataElementDimension
- implements Dimension
+ extends Dimension
{
private static final String NAME = "DataElement";
@@ -169,7 +173,7 @@
return null;
}
- public DimensionOption getDimensionOption( Object object )
+ public DimensionOption getDimensionOption( DimensionOptionElement element )
{
return null;
}
@@ -215,6 +219,11 @@
return groupSets;
}
+ public List<? extends DimensionOptionElement> getDimensionOptionElements()
+ {
+ return null;
+ }
+
public boolean isDimensionSet()
{
return groupSets != null && groupSets.size() > 0;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java 2009-10-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategory.java 2009-11-05 19:04:58 +0000
@@ -30,9 +30,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.dimension.Dimension;
-import org.hisp.dhis.dimension.DimensionOption;
/**
@@ -45,7 +43,7 @@
* @version $Id$
*/
public class DataElementCategory
- extends IdentifiableObject implements Dimension
+ extends Dimension
{
public static final String DEFAULT_NAME = "default";
@@ -79,19 +77,6 @@
return categoryOptions;
}
- public DimensionOption getDimensionOption( Object object )
- {
- for ( DataElementCategoryOption categoryOption : categoryOptions )
- {
- if ( categoryOption.getCategoryOptionCombos().contains( object ) )
- {
- return categoryOption;
- }
- }
-
- return null;
- }
-
// -------------------------------------------------------------------------
// hashCode, equals and toString
// -------------------------------------------------------------------------
=== 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-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java 2009-11-05 19:04:58 +0000
@@ -66,7 +66,7 @@
private Set<DataElementCategoryOptionCombo> optionCombos = new HashSet<DataElementCategoryOptionCombo>();
// -------------------------------------------------------------------------
- // Constructors
+ // Dimension
// -------------------------------------------------------------------------
public List<? extends Dimension> getDimensions()
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java 2009-10-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java 2009-11-05 19:04:58 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.dimension.DimensionOption;
+import org.hisp.dhis.dimension.DimensionOptionElement;
/**
* @author Abyot Asalefew
@@ -61,6 +62,15 @@
{
this.name = name;
}
+
+ // -------------------------------------------------------------------------
+ // Constructors
+ // -------------------------------------------------------------------------
+
+ public List<? extends DimensionOptionElement> getDimensionOptionElements()
+ {
+ return categoryOptionCombos;
+ }
// -------------------------------------------------------------------------
// hashCode, equals and toString
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java 2009-10-15 17:28:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java 2009-11-05 19:04:58 +0000
@@ -35,13 +35,14 @@
import java.util.Set;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.dimension.DimensionOptionElement;
/**
* @author Abyot Aselefew
* @version $Id$
*/
public class DataElementCategoryOptionCombo
- extends IdentifiableObject
+ extends IdentifiableObject implements DimensionOptionElement
{
public static final String DEFAULT_NAME = "default";
=== 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 2009-10-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroup.java 2009-11-05 19:04:58 +0000
@@ -27,11 +27,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.dimension.DimensionOption;
+import org.hisp.dhis.dimension.DimensionOptionElement;
/**
* @author Kristian Nordal
@@ -61,6 +64,15 @@
}
// -------------------------------------------------------------------------
+ // Dimension
+ // -------------------------------------------------------------------------
+
+ public List<? extends DimensionOptionElement> getDimensionOptionElements()
+ {
+ return new ArrayList<DataElement>( members );
+ }
+
+ // -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
=== 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-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java 2009-11-05 19:04:58 +0000
@@ -32,7 +32,7 @@
import org.hisp.dhis.dimension.Dimension;
import org.hisp.dhis.dimension.DimensionOption;
-import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.dimension.DimensionOptionElement;
/**
* DataElementGroupSet is a set of DataElementGroups. It is by default exclusive,
@@ -42,8 +42,7 @@
* @author Lars Helge Overland
*/
public class DataElementGroupSet
- extends IdentifiableObject
- implements Dimension
+ extends Dimension
{
private List<DataElementGroup> members = new ArrayList<DataElementGroup>();
@@ -69,13 +68,13 @@
return members;
}
- public DimensionOption getDimensionOption( Object object )
+ public DimensionOption getDimensionOption( DimensionOptionElement dimensionOptionElement )
{
- for ( DataElementGroup group : members )
+ for ( DimensionOption dimensionOption : members )
{
- if ( group.getMembers().contains( object ) )
+ if ( dimensionOption.getDimensionOptionElements().contains( dimensionOptionElement ) )
{
- return group;
+ return dimensionOption;
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/Dimension.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/Dimension.java 2009-10-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/Dimension.java 2009-11-05 19:04:58 +0000
@@ -29,14 +29,26 @@
import java.util.List;
+import org.hisp.dhis.common.IdentifiableObject;
+
/**
* @author Lars Helge Overland
*/
-public interface Dimension
-{
- String getName();
-
- List<? extends DimensionOption> getDimensionOptions();
-
- DimensionOption getDimensionOption( Object object );
+public abstract class Dimension
+ extends IdentifiableObject
+{
+ public abstract List<? extends DimensionOption> getDimensionOptions();
+
+ public DimensionOption getDimensionOption( DimensionOptionElement dimensionOptionElement )
+ {
+ for ( DimensionOption dimensionOption : getDimensionOptions() )
+ {
+ if ( dimensionOption.getDimensionOptionElements().contains( dimensionOptionElement ) )
+ {
+ return dimensionOption;
+ }
+ }
+
+ return null;
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/DimensionOption.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/DimensionOption.java 2009-10-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/DimensionOption.java 2009-11-05 19:04:58 +0000
@@ -27,10 +27,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.List;
+
/**
* @author Lars Helge Overland
*/
public interface DimensionOption
{
String getName();
+
+ List<? extends DimensionOptionElement> getDimensionOptionElements();
}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/DimensionOptionElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/DimensionOptionElement.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/DimensionOptionElement.java 2009-11-05 19:04:58 +0000
@@ -0,0 +1,36 @@
+package org.hisp.dhis.dimension;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author Lars Helge Overland
+ */
+public interface DimensionOptionElement
+{
+ String getName();
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/Measure.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/Measure.java 2009-11-03 11:34:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dimension/Measure.java 2009-11-05 19:04:58 +0000
@@ -37,6 +37,4 @@
Map<Dimension, DimensionOption> getDimensions();
Map<Dimension, DimensionOption> getDimensions( DimensionSet dimensionSet );
-
- String getMeasure();
}
=== 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-11-03 11:04:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java 2009-11-05 19:04:58 +0000
@@ -34,6 +34,7 @@
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.datadictionary.ExtendedDataElement;
import org.hisp.dhis.dimension.Dimension;
+import org.hisp.dhis.dimension.DimensionOptionElement;
import org.hisp.dhis.dimension.DimensionSet;
/**
@@ -41,7 +42,7 @@
* @version $Id: Indicator.java 5540 2008-08-19 10:47:07Z larshelg $
*/
public class Indicator
- extends IdentifiableObject implements DimensionSet
+ extends IdentifiableObject implements DimensionSet, DimensionOptionElement
{
private Boolean annualized;
=== 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 2009-10-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroup.java 2009-11-05 19:04:58 +0000
@@ -27,11 +27,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.dimension.DimensionOption;
-import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.dimension.DimensionOptionElement;
/**
* @author Lars Helge Overland
@@ -41,7 +44,6 @@
extends IdentifiableObject
implements DimensionOption
{
-
private Set<Indicator> members = new HashSet<Indicator>();
// -------------------------------------------------------------------------
@@ -58,6 +60,15 @@
}
// -------------------------------------------------------------------------
+ // Dimension
+ // -------------------------------------------------------------------------
+
+ public List<? extends DimensionOptionElement> getDimensionOptionElements()
+ {
+ return new ArrayList<Indicator>( members );
+ }
+
+ // -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
=== 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 2009-10-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSet.java 2009-11-05 19:04:58 +0000
@@ -30,7 +30,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.dimension.Dimension;
import org.hisp.dhis.dimension.DimensionOption;
@@ -42,8 +41,7 @@
* @author Lars Helge Overland
*/
public class IndicatorGroupSet
- extends IdentifiableObject
- implements Dimension
+ extends Dimension
{
private List<IndicatorGroup> members = new ArrayList<IndicatorGroup>();
@@ -108,19 +106,6 @@
return members;
}
- public DimensionOption getDimensionOption( Object object )
- {
- for ( IndicatorGroup group : members )
- {
- if ( group.getMembers().contains( object ) )
- {
- return group;
- }
- }
-
- return null;
- }
-
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java 2009-10-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java 2009-11-05 19:04:58 +0000
@@ -33,6 +33,7 @@
import org.hisp.dhis.dimension.Dimension;
import org.hisp.dhis.dimension.DimensionOption;
+import org.hisp.dhis.dimension.DimensionOptionElement;
/**
* @author Kristian Nordal
@@ -85,7 +86,7 @@
public static Dimension DIMENSION = new PeriodDimension();
public static class PeriodDimension
- implements Dimension
+ extends Dimension
{
private static final String NAME = "Period";
@@ -99,7 +100,7 @@
return null;
}
- public DimensionOption getDimensionOption( Object object )
+ public DimensionOption getDimensionOption( DimensionOptionElement element )
{
return null;
}
@@ -139,6 +140,11 @@
return "[" + NAME + "]";
}
}
+
+ public List<? extends DimensionOptionElement> getDimensionOptionElements()
+ {
+ return null;
+ }
// -------------------------------------------------------------------------
// hashCode, equals and toString
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2009-11-05 15:09:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2009-11-05 19:04:58 +0000
@@ -43,12 +43,12 @@
String ID = ReportTableService.class.getName();
/**
- * Generate and set report parameters for reporting period, parent organisation
+ * Generates and sets report parameters for reporting period, parent organisation
* unit and organisation unit. Delegates to <code>createReportTable( ReportTable, boolean )</code>
* to generate the table.
*
* @param id the identifier.
- * @param mode the mode, can be <li>dataelements</i>, <i>indicators</i>, and <i>datasets</i>.
+ * @param mode the mode, can be <l>dataelements</i>, <i>indicators</i>, and <i>datasets</i>.
* @param reportingPeriod the number of months back in time which will be used
* as basis for the generation of relative periods.
* @param parentOrganisationUnitId the identifier of the parent organisation
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/source/Source.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/source/Source.java 2009-10-27 18:39:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/source/Source.java 2009-11-05 19:04:58 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dimension.Dimension;
import org.hisp.dhis.dimension.DimensionOption;
+import org.hisp.dhis.dimension.DimensionOptionElement;
/**
* @author Torgeir Lorange Ostby
@@ -52,7 +53,7 @@
public static Dimension DIMENSION = new SourceDimension();
public static class SourceDimension
- implements Dimension
+ extends Dimension
{
private static final String NAME = "Source";
@@ -66,7 +67,7 @@
return null;
}
- public DimensionOption getDimensionOption( Object object )
+ public DimensionOption getDimensionOption( DimensionOptionElement element )
{
return null;
}
@@ -106,6 +107,11 @@
return "[" + NAME + "]";
}
}
+
+ public List<? extends DimensionOptionElement> getDimensionOptionElements()
+ {
+ return null;
+ }
// -------------------------------------------------------------------------
// hashCode, equals and toString