← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18421: Event report and event chart, added support for legend sets/ranges for favorites.

 

------------------------------------------------------------
revno: 18421
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-02-25 21:40:28 +0100
message:
  Event report and event chart, added support for legend sets/ranges for favorites.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeDimension.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityDataElementDimension.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/BaseAnalyticalObjectTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/DimensionalObjectTest.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/dimension/DefaultDimensionService.java
  dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttributeDimension.hbm.xml
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityDataElementDimension.hbm.xml


--
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	2015-02-19 09:18:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java	2015-02-25 20:40:28 +0000
@@ -375,7 +375,7 @@
             {
                 TrackedEntityAttributeDimension tead = attributes.get( dimension );
 
-                return new BaseDimensionalObject( dimension, DimensionType.TRACKED_ENTITY_ATTRIBUTE, null, tead.getDisplayName(), tead.getFilter() );
+                return new BaseDimensionalObject( dimension, DimensionType.TRACKED_ENTITY_ATTRIBUTE, null, tead.getDisplayName(), tead.getLegendSet(), tead.getFilter() );
             }
 
             // Tracked entity data element
@@ -391,7 +391,7 @@
             {
                 TrackedEntityDataElementDimension tedd = dataElements.get( dimension );
 
-                return new BaseDimensionalObject( dimension, DimensionType.TRACKED_ENTITY_DATAELEMENT, null, tedd.getDisplayName(), tedd.getFilter() );
+                return new BaseDimensionalObject( dimension, DimensionType.TRACKED_ENTITY_DATAELEMENT, null, tedd.getDisplayName(), tedd.getLegendSet(), tedd.getFilter() );
             }
         }
 
@@ -584,7 +584,7 @@
             {
                 TrackedEntityAttributeDimension tead = attributes.get( dimension );
 
-                objects.add( new BaseDimensionalObject( dimension, DimensionType.TRACKED_ENTITY_ATTRIBUTE, null, tead.getDisplayName(), tead.getFilter() ) );
+                objects.add( new BaseDimensionalObject( dimension, DimensionType.TRACKED_ENTITY_ATTRIBUTE, null, tead.getDisplayName(), tead.getLegendSet(), tead.getFilter() ) );
             }
 
             // Tracked entity data element
@@ -600,7 +600,7 @@
             {
                 TrackedEntityDataElementDimension tedd = dataElements.get( dimension );
 
-                objects.add( new BaseDimensionalObject( dimension, DimensionType.TRACKED_ENTITY_DATAELEMENT, null, tedd.getDisplayName(), tedd.getFilter() ) );
+                objects.add( new BaseDimensionalObject( dimension, DimensionType.TRACKED_ENTITY_DATAELEMENT, null, tedd.getDisplayName(), tedd.getLegendSet(), tedd.getFilter() ) );
             }
         }
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java	2015-02-25 19:56:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java	2015-02-25 20:40:28 +0000
@@ -107,12 +107,13 @@
         this.items = new ArrayList<>( items );
     }
 
-    public BaseDimensionalObject( String dimension, DimensionType dimensionType, String dimensionName, String displayName, String filter )
+    public BaseDimensionalObject( String dimension, DimensionType dimensionType, String dimensionName, String displayName, LegendSet legendSet, String filter )
     {
         this.uid = dimension;
         this.dimensionType = dimensionType;
         this.dimensionName = dimensionName;
         this.displayName = displayName;
+        this.legendSet = legendSet;
         this.filter = filter;
     }
 
@@ -120,28 +121,24 @@
     // Logic
     // -------------------------------------------------------------------------
 
-    /**
-     * Indicates whether this dimension should use all dimension items. All
-     * dimension options is represented as an option list of zero elements.
-     */
     @Override
     public boolean isAllItems()
     {
         return items != null && items.isEmpty();
     }
 
-    /**
-     * Indicates whether this dimension has any dimension items.
-     */
     @Override
     public boolean hasItems()
     {
         return items != null && !items.isEmpty();
     }
+    
+    @Override
+    public boolean hasLegendSet()
+    {
+        return legendSet != null;
+    }
 
-    /**
-     * Returns dimension name with fall back to dimension.
-     */
     @Override
     public String getDimensionName()
     {

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java	2015-02-25 17:10:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java	2015-02-25 20:40:28 +0000
@@ -98,7 +98,7 @@
     
     /**
      * Gets the dimension name, which corresponds to a column in the analytics
-     * tables.
+     * tables, with fall back to dimension.
      */
     String getDimensionName();
      
@@ -106,14 +106,15 @@
      * Dimension items.
      */
     List<NameableObject> getItems();
-    
+
     /**
-     * Indicates whether all items for this dimension should be used.
+     * Indicates whether this dimension should use all dimension items. All
+     * dimension options is represented as an option list of zero elements.
      */
     boolean isAllItems();
-    
+
     /**
-     * Indicates whether this dimension has any items.
+     * Indicates whether this dimension has any dimension items.
      */
     boolean hasItems();
     
@@ -121,6 +122,11 @@
      * Gets the legend set.
      */
     LegendSet getLegendSet();
+
+    /**
+     * Indicates whether this dimension has a legend set.
+     */
+    boolean hasLegendSet();
     
     /**
      * Gets the filter. Contains operator and filter. Applicable for events.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeDimension.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeDimension.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeDimension.java	2015-02-25 20:40:28 +0000
@@ -32,6 +32,7 @@
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
+import org.hisp.dhis.legend.LegendSet;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonView;
@@ -53,6 +54,11 @@
     private TrackedEntityAttribute attribute;
     
     /**
+     * Legend set.
+     */
+    private LegendSet legendSet;
+    
+    /**
      * Operator and filter on this format:
      * <operator>:<filter>;<operator>:<filter>
      * Operator and filter pairs can be repeated any number of times.
@@ -67,9 +73,10 @@
     {
     }
     
-    public TrackedEntityAttributeDimension( TrackedEntityAttribute attribute, String filter )
+    public TrackedEntityAttributeDimension( TrackedEntityAttribute attribute, LegendSet legendSet, String filter )
     {
         this.attribute = attribute;
+        this.legendSet = legendSet;
         this.filter = filter;
     }
 
@@ -90,15 +97,16 @@
     @Override
     public String toString()
     {
-        return "[Id: " + id + ", attribute: " + attribute + ", filter: " + filter + "]";
+        return "[Id: " + id + ", attribute: " + attribute + ", legend set: " + legendSet + ", filter: " + filter + "]";
     }
 
     @Override
     public int hashCode()
     {
         int result = id;
-        result = 31 * result + (attribute != null ? attribute.hashCode() : 0);
-        result = 31 * result + (filter != null ? filter.hashCode() : 0);
+        result = 31 * result + ( attribute != null ? attribute.hashCode() : 0 );
+        result = 31 * result + ( legendSet != null ? legendSet.hashCode() : 0 );
+        result = 31 * result + ( filter != null ? filter.hashCode() : 0 );
 
         return result;
     }
@@ -128,6 +136,11 @@
             return false;
         }
         
+        if ( legendSet != null ? !legendSet.equals( other.legendSet ) : other.legendSet != null )
+        {
+            return false;
+        }
+        
         if ( filter != null ? !filter.equals( other.filter ) : other.filter != null )
         {
             return false;
@@ -165,6 +178,20 @@
     }
 
     @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public LegendSet getLegendSet()
+    {
+        return legendSet;
+    }
+
+    public void setLegendSet( LegendSet legendSet )
+    {
+        this.legendSet = legendSet;
+    }
+
+    @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
     public String getFilter()

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityDataElementDimension.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityDataElementDimension.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityDataElementDimension.java	2015-02-25 20:40:28 +0000
@@ -33,6 +33,7 @@
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.legend.LegendSet;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonView;
@@ -54,6 +55,11 @@
     private DataElement dataElement;
 
     /**
+     * Legend set.
+     */
+    private LegendSet legendSet;
+    
+    /**
      * Operator and filter on this format:
      * <operator>:<filter>;<operator>:<filter>
      * Operator and filter pairs can be repeated any number of times.
@@ -68,9 +74,10 @@
     {
     }
 
-    public TrackedEntityDataElementDimension( DataElement dataElement, String filter )
+    public TrackedEntityDataElementDimension( DataElement dataElement, LegendSet legendSet, String filter )
     {
         this.dataElement = dataElement;
+        this.legendSet = legendSet;
         this.filter = filter;
     }
     
@@ -91,15 +98,16 @@
     @Override
     public String toString()
     {
-        return "[Id: " + id + ", data element: " + dataElement + ", filter: " + filter + "]";
+        return "[Id: " + id + ", data element: " + dataElement + ", legend set: " + legendSet + ", filter: " + filter + "]";
     }
 
     @Override
     public int hashCode()
     {
         int result = id;
-        result = 31 * result + (dataElement != null ? dataElement.hashCode() : 0);
-        result = 31 * result + (filter != null ? filter.hashCode() : 0);
+        result = 31 * result + ( dataElement != null ? dataElement.hashCode() : 0 );
+        result = 31 * result + ( legendSet != null ? legendSet.hashCode() : 0 );
+        result = 31 * result + ( filter != null ? filter.hashCode() : 0 );
 
         return result;
     }
@@ -129,6 +137,11 @@
             return false;
         }
         
+        if ( legendSet != null ? !legendSet.equals( other.legendSet ) : other.legendSet != null )
+        {
+            return false;
+        }
+        
         if ( filter != null ? !filter.equals( other.filter ) : other.filter != null )
         {
             return false;
@@ -166,6 +179,20 @@
     }
 
     @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public LegendSet getLegendSet()
+    {
+        return legendSet;
+    }
+
+    public void setLegendSet( LegendSet legendSet )
+    {
+        this.legendSet = legendSet;
+    }
+
+    @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
     public String getFilter()

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/BaseAnalyticalObjectTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/BaseAnalyticalObjectTest.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/BaseAnalyticalObjectTest.java	2015-02-25 20:40:28 +0000
@@ -111,7 +111,7 @@
     {
         TrackedEntityAttribute tea = new TrackedEntityAttribute();
 
-        TrackedEntityAttributeDimension tead = new TrackedEntityAttributeDimension( tea, "EQ:10" );
+        TrackedEntityAttributeDimension tead = new TrackedEntityAttributeDimension( tea, null, "EQ:10" );
         
         EventChart chart = new EventChart();
         chart.getColumnDimensions().add( tea.getUid() );

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/DimensionalObjectTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/DimensionalObjectTest.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/common/DimensionalObjectTest.java	2015-02-25 20:40:28 +0000
@@ -44,11 +44,11 @@
     @Test
     public void testGetFilterItemsAsList()
     {
-        BaseDimensionalObject objectA = new BaseDimensionalObject( "dimA", DimensionType.TRACKED_ENTITY_DATAELEMENT, null, null, "IN:uidA;uidB;uidC" );
+        BaseDimensionalObject objectA = new BaseDimensionalObject( "dimA", DimensionType.TRACKED_ENTITY_DATAELEMENT, null, null, null, "IN:uidA;uidB;uidC" );
         List<String> expectedA = new ArrayList<>( Arrays.asList( "uidA", "uidB", "uidC" ) );
         assertEquals( expectedA, objectA.getFilterItemsAsList() );
         
-        BaseDimensionalObject objectB = new BaseDimensionalObject( "dimA", DimensionType.TRACKED_ENTITY_DATAELEMENT, null, null, "EQ:uidA" );
+        BaseDimensionalObject objectB = new BaseDimensionalObject( "dimA", DimensionType.TRACKED_ENTITY_DATAELEMENT, null, null, null, "EQ:uidA" );
         assertEquals( null, objectB.getFilterItemsAsList() );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/dimension/DefaultDimensionService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/dimension/DefaultDimensionService.java	2015-02-18 17:33:23 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/dimension/DefaultDimensionService.java	2015-02-25 20:40:28 +0000
@@ -52,6 +52,7 @@
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.legend.LegendSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
@@ -535,6 +536,7 @@
                 {
                     TrackedEntityAttributeDimension attributeDimension = new TrackedEntityAttributeDimension();
                     attributeDimension.setAttribute( identifiableObjectManager.get( TrackedEntityAttribute.class, dimensionId ) );
+                    attributeDimension.setLegendSet( dimension.hasLegendSet() ? identifiableObjectManager.get( LegendSet.class, dimension.getLegendSet().getUid() ) : null );
                     attributeDimension.setFilter( dimension.getFilter() );
                     
                     object.getAttributeDimensions().add( attributeDimension );
@@ -543,6 +545,7 @@
                 {
                     TrackedEntityDataElementDimension dataElementDimension = new TrackedEntityDataElementDimension();
                     dataElementDimension.setDataElement( identifiableObjectManager.get( DataElement.class, dimensionId ) );
+                    dataElementDimension.setLegendSet( dimension.hasLegendSet() ? identifiableObjectManager.get( LegendSet.class, dimension.getLegendSet().getUid() ) : null );
                     dataElementDimension.setFilter( dimension.getFilter() );
                     
                     object.getDataElementDimensions().add( dataElementDimension );

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java	2015-02-17 21:46:41 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java	2015-02-25 20:40:28 +0000
@@ -197,7 +197,7 @@
         chart.getRowDimensions().add( DimensionalObject.ORGUNIT_DIM_ID );
         chart.getFilterDimensions().add( DimensionalObject.PERIOD_DIM_ID );
         
-        chart.getAttributeDimensions().add( new TrackedEntityAttributeDimension( atA, "LE:5" ) );
+        chart.getAttributeDimensions().add( new TrackedEntityAttributeDimension( atA, null, "LE:5" ) );
         chart.getPeriods().add( peA );
         chart.getPeriods().add( peB );
         chart.getOrganisationUnits().add( ouA );
@@ -222,8 +222,8 @@
         chart.getRowDimensions().add( DimensionalObject.PERIOD_DIM_ID );
         chart.getFilterDimensions().add( DimensionalObject.ORGUNIT_DIM_ID );
         
-        chart.getAttributeDimensions().add( new TrackedEntityAttributeDimension( atA, "LE:5" ) );
-        chart.getDataElementDimensions().add( new TrackedEntityDataElementDimension( deA, "GE:100" ) );
+        chart.getAttributeDimensions().add( new TrackedEntityAttributeDimension( atA, null, "LE:5" ) );
+        chart.getDataElementDimensions().add( new TrackedEntityDataElementDimension( deA, null, "GE:100" ) );
         chart.getPeriods().add( peA );
         chart.getPeriods().add( peB );
         chart.getOrganisationUnits().add( ouA );
@@ -242,7 +242,7 @@
     {
         TrackedEntityAttribute tea = new TrackedEntityAttribute();
 
-        TrackedEntityAttributeDimension tead = new TrackedEntityAttributeDimension( tea, "EQ:2" );
+        TrackedEntityAttributeDimension tead = new TrackedEntityAttributeDimension( tea, null, "EQ:2" );
         
         EventChart chart = new EventChart();
         chart.getColumnDimensions().add( tea.getUid() );

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttributeDimension.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttributeDimension.hbm.xml	2014-04-21 11:05:22 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttributeDimension.hbm.xml	2015-02-25 20:40:28 +0000
@@ -13,6 +13,9 @@
     <many-to-one name="attribute" class="org.hisp.dhis.trackedentity.TrackedEntityAttribute" 
         column="trackedentityattributeid" foreign-key="fk_attributedimension_attributeid" />
     
+    <many-to-one name="legendSet" class="org.hisp.dhis.legend.LegendSet"
+    	column="legendsetid" foreign-key="fk_attributedimension_legendsetid" />
+    
     <property name="filter" />
 
   </class>

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityDataElementDimension.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityDataElementDimension.hbm.xml	2014-04-21 11:05:22 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityDataElementDimension.hbm.xml	2015-02-25 20:40:28 +0000
@@ -13,6 +13,9 @@
     <many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" 
         column="dataelementid" foreign-key="fk_dataelementdimension_dataelementid" />
 
+	<many-to-one name="legendSet" class="org.hisp.dhis.legend.LegendSet"
+		column="legendsetid" foreign-key="fk_dataelementdimension_legendsetid" />
+
     <property name="filter" />
 
   </class>