← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18325: Event analytics, persistence for value dim

 

------------------------------------------------------------
revno: 18325
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-02-18 18:33:23 +0100
message:
  Event analytics, persistence for value dim
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/DimensionService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/EventAnalyticalObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventchart/EventChart.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/util/ObjectUtils.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/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventchart/EventChart.hbm.xml
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.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	2015-02-05 06:53:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java	2015-02-18 17:33:23 +0000
@@ -136,7 +136,7 @@
     protected transient List<DimensionalObject> filters = new ArrayList<>();
 
     protected transient Map<String, String> parentGraphMap = new HashMap<>();
-
+    
     // -------------------------------------------------------------------------
     // Transient properties
     // -------------------------------------------------------------------------
@@ -986,7 +986,7 @@
     }
 
     // -------------------------------------------------------------------------
-    // Web domain properties
+    // Analytical properties
     // -------------------------------------------------------------------------
 
     @Override

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionService.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionService.java	2015-02-18 17:33:23 +0000
@@ -56,4 +56,6 @@
     DimensionalObject getDimensionalObjectCopy( String uid, boolean filterCanRead );
     
     void mergeAnalyticalObject( BaseAnalyticalObject object );
+    
+    void mergeEventAnalyticalObject( EventAnalyticalObject object );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/EventAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/EventAnalyticalObject.java	2015-02-16 14:25:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/EventAnalyticalObject.java	2015-02-18 17:33:23 +0000
@@ -30,9 +30,11 @@
 
 import java.util.Date;
 
+import org.hisp.dhis.analytics.EventOutputType;
+import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.analytics.EventOutputType;
+import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 
 /**
  * @author Lars Helge Overland
@@ -49,4 +51,18 @@
     Date getEndDate();
     
     EventOutputType getOutputType();
+    
+    NameableObject getValue();
+
+    // -------------------------------------------------------------------------
+    // Base class emulation methods
+    // -------------------------------------------------------------------------
+    
+    DataElement getDataElementValueDimension();
+
+    void setDataElementValueDimension( DataElement dataElementValueDimension );
+
+    TrackedEntityAttribute getAttributeValueDimension();
+    
+    void setAttributeValueDimension( TrackedEntityAttribute attributeValueDimension );   
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventchart/EventChart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventchart/EventChart.java	2015-02-17 16:50:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventchart/EventChart.java	2015-02-18 17:33:23 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.analytics.EventOutputType;
 import org.hisp.dhis.chart.BaseChart;
 import org.hisp.dhis.common.AnalyticsType;
+import org.hisp.dhis.common.BaseDimensionalObject;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DimensionalObject;
 import org.hisp.dhis.common.DimensionalObjectUtils;
@@ -46,14 +47,18 @@
 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.DataElement;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.user.User;
+import org.hisp.dhis.util.ObjectUtils;
 
 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;
@@ -70,21 +75,61 @@
     public static final String COUNT_TYPE_EVENTS = "events";
     public static final String COUNT_TYPE_TRACKED_ENTITY_INSTANCES = "tracked_entity_instances";
 
+    /**
+     * Program. Required.
+     */
     private Program program;
 
+    /**
+     * Program stage.
+     */
     private ProgramStage programStage;
 
+    /**
+     * Start date.
+     */
     private Date startDate;
 
+    /**
+     * End date.
+     */
     private Date endDate;
 
+    /**
+     * Data element value dimension.
+     */
+    private DataElement dataElementValueDimension;
+    
+    /**
+     * Attribute value dimension.
+     */
+    private TrackedEntityAttribute attributeValueDimension;
+
+    /**
+     * Dimensions to crosstabulate / use as columns.
+     */
     private List<String> columnDimensions = new ArrayList<>();
 
+    /**
+     * Dimensions to use as rows.
+     */
     private List<String> rowDimensions = new ArrayList<>();
 
+    /**
+     * Indicates output type.
+     */
     private EventOutputType outputType;
 
     // -------------------------------------------------------------------------
+    // Analytical properties
+    // -------------------------------------------------------------------------
+
+    /**
+     * Value dimension.
+     */
+    private transient NameableObject value;
+
+    // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
 
@@ -127,6 +172,8 @@
         {
             filters.addAll( getDimensionalObjectList( filter ) );
         }
+        
+        value = ObjectUtils.firstNonNull( dataElementValueDimension, attributeValueDimension );
     }
 
     @Override
@@ -224,6 +271,34 @@
     }
 
     @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public DataElement getDataElementValueDimension()
+    {
+        return dataElementValueDimension;
+    }
+
+    public void setDataElementValueDimension( DataElement dataElementValueDimension )
+    {
+        this.dataElementValueDimension = dataElementValueDimension;
+    }
+
+    @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public TrackedEntityAttribute getAttributeValueDimension()
+    {
+        return attributeValueDimension;
+    }
+
+    public void setAttributeValueDimension( TrackedEntityAttribute attributeValueDimension )
+    {
+        this.attributeValueDimension = attributeValueDimension;
+    }
+
+    @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlElementWrapper( localName = "columnDimensions", namespace = DxfNamespaces.DXF_2_0 )
     @JacksonXmlProperty( localName = "columnDimension", namespace = DxfNamespaces.DXF_2_0 )
@@ -265,6 +340,25 @@
     }
 
     // -------------------------------------------------------------------------
+    // Analytical properties
+    // -------------------------------------------------------------------------
+
+    @JsonProperty
+    @JsonDeserialize( as = BaseDimensionalObject.class )
+    @JsonSerialize( as = BaseDimensionalObject.class )
+    @JsonView( { DimensionalView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public NameableObject getValue()
+    {
+        return value;
+    }
+
+    public void setValue( NameableObject value )
+    {
+        this.value = value;
+    }
+
+    // -------------------------------------------------------------------------
     // Merge with
     // -------------------------------------------------------------------------
 
@@ -279,6 +373,8 @@
 
             if ( MergeStrategy.MERGE_ALWAYS.equals( strategy ) )
             {
+                dataElementValueDimension = eventChart.getDataElementValueDimension();
+                attributeValueDimension = eventChart.getAttributeValueDimension();
                 program = eventChart.getProgram();
                 programStage = eventChart.getProgramStage();
                 startDate = eventChart.getStartDate();
@@ -287,6 +383,8 @@
             }
             else if ( MergeStrategy.MERGE_IF_NOT_NULL.equals( strategy ) )
             {
+                dataElementValueDimension = eventChart.getDataElementValueDimension() == null ? dataElementValueDimension : eventChart.getDataElementValueDimension();
+                attributeValueDimension = eventChart.getAttributeValueDimension() == null ? attributeValueDimension : eventChart.getAttributeValueDimension();
                 program = eventChart.getProgram() == null ? program : eventChart.getProgram();
                 programStage = eventChart.getProgramStage() == null ? programStage : eventChart.getProgramStage();
                 startDate = eventChart.getStartDate() == null ? startDate : eventChart.getStartDate();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java	2015-02-17 17:51:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java	2015-02-18 17:33:23 +0000
@@ -28,31 +28,38 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.hisp.dhis.analytics.EventOutputType;
 import org.hisp.dhis.common.BaseAnalyticalObject;
+import org.hisp.dhis.common.BaseDimensionalObject;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.EventAnalyticalObject;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.MergeStrategy;
+import org.hisp.dhis.common.NameableObject;
 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.DataElement;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.user.User;
-import org.hisp.dhis.analytics.EventOutputType;
+import org.hisp.dhis.util.ObjectUtils;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+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;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 
 /**
  * @author Lars Helge Overland
@@ -86,6 +93,16 @@
     private Date endDate;
     
     /**
+     * Data element value dimension.
+     */
+    private DataElement dataElementValueDimension;
+    
+    /**
+     * Attribute value dimension.
+     */
+    private TrackedEntityAttribute attributeValueDimension;
+    
+    /**
      * Type of data, can be aggregated values and individual cases.
      */
     private String dataType;
@@ -156,6 +173,15 @@
     private boolean showDimensionLabels;
 
     // -------------------------------------------------------------------------
+    // Analytical properties
+    // -------------------------------------------------------------------------
+
+    /**
+     * Value dimension.
+     */
+    private transient NameableObject value;
+
+    // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
 
@@ -196,6 +222,8 @@
         {
             filters.addAll( getDimensionalObjectList( filter ) );
         }
+        
+        value = ObjectUtils.firstNonNull( dataElementValueDimension, attributeValueDimension );
     }
 
     // -------------------------------------------------------------------------
@@ -261,6 +289,34 @@
     }
 
     @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public DataElement getDataElementValueDimension()
+    {
+        return dataElementValueDimension;
+    }
+
+    public void setDataElementValueDimension( DataElement dataElementValueDimension )
+    {
+        this.dataElementValueDimension = dataElementValueDimension;
+    }
+
+    @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public TrackedEntityAttribute getAttributeValueDimension()
+    {
+        return attributeValueDimension;
+    }
+
+    public void setAttributeValueDimension( TrackedEntityAttribute attributeValueDimension )
+    {
+        this.attributeValueDimension = attributeValueDimension;
+    }
+
+    @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getDataType()
@@ -445,6 +501,29 @@
         this.showDimensionLabels = showDimensionLabels;
     }
 
+    // -------------------------------------------------------------------------
+    // Analytical properties
+    // -------------------------------------------------------------------------
+
+    @JsonProperty
+    @JsonDeserialize( as = BaseDimensionalObject.class )
+    @JsonSerialize( as = BaseDimensionalObject.class )
+    @JsonView( { DimensionalView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public NameableObject getValue()
+    {
+        return value;
+    }
+
+    public void setValue( NameableObject value )
+    {
+        this.value = value;
+    }
+
+    // -------------------------------------------------------------------------
+    // Merge with
+    // -------------------------------------------------------------------------
+
     @Override
     public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
     {
@@ -464,6 +543,8 @@
 
             if ( MergeStrategy.MERGE_ALWAYS.equals( strategy ) )
             {
+                dataElementValueDimension = eventReport.getDataElementValueDimension();
+                attributeValueDimension = eventReport.getAttributeValueDimension();
                 dataType = eventReport.getDataType();
                 program = eventReport.getProgram();
                 programStage = eventReport.getProgramStage();
@@ -475,6 +556,8 @@
             }
             else if ( MergeStrategy.MERGE_IF_NOT_NULL.equals( strategy ) )
             {
+                dataElementValueDimension = eventReport.getDataElementValueDimension() == null ? dataElementValueDimension : eventReport.getDataElementValueDimension();
+                attributeValueDimension = eventReport.getAttributeValueDimension() == null ? attributeValueDimension : eventReport.getAttributeValueDimension();
                 dataType = eventReport.getDataType() == null ? dataType : eventReport.getDataType();
                 program = eventReport.getProgram() == null ? program : eventReport.getProgram();
                 programStage = eventReport.getProgramStage() == null ? programStage : eventReport.getProgramStage();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/util/ObjectUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/util/ObjectUtils.java	2015-02-10 18:40:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/util/ObjectUtils.java	2015-02-18 17:33:23 +0000
@@ -50,4 +50,27 @@
         put( TrackedEntityAttribute.TYPE_OPTION_SET, String.class );
         put( TrackedEntityAttribute.TYPE_EMAIL, String.class );
     } };
+    
+    /**
+     * Returns the first non-null argument. Returns null if all arguments are null.
+     * 
+     * @param objects the objects.
+     * @return the first non-null argument.
+     */
+    @SafeVarargs
+    public static final <T> T firstNonNull( T... objects )
+    {
+        if ( objects != null )
+        {
+            for ( T object : objects )
+            {
+                if ( object != null )
+                {
+                    return object;
+                }
+            }
+        }
+        
+        return null;
+    }
 }

=== 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-05 06:53:38 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/dimension/DefaultDimensionService.java	2015-02-18 17:33:23 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.common.DimensionType;
 import org.hisp.dhis.common.DimensionalObject;
 import org.hisp.dhis.common.DimensionalObjectUtils;
+import org.hisp.dhis.common.EventAnalyticalObject;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.MergeStrategy;
@@ -342,6 +343,32 @@
             mergeDimensionalObjects( object, object.getFilters() );
         }
     }
+
+    @Override
+    public void mergeEventAnalyticalObject( EventAnalyticalObject object )
+    {
+        if ( object != null )
+        {
+            if ( object.getValue() != null )
+            {
+                String uid = object.getValue().getUid();
+                
+                DataElement dataElement = identifiableObjectManager.get( DataElement.class, uid );
+                
+                if ( dataElement != null )
+                {
+                    object.setDataElementValueDimension( dataElement );
+                }
+                
+                TrackedEntityAttribute attribute = identifiableObjectManager.get( TrackedEntityAttribute.class, uid );
+                
+                if ( attribute != null )
+                {
+                    object.setAttributeValueDimension( attribute );
+                }
+            }
+        }
+    }
     
     @Override
     public DimensionalObject getDimensionalObjectCopy( String uid, boolean filterCanRead )

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-02-18 16:33:18 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-02-18 17:33:23 +0000
@@ -513,6 +513,7 @@
             params.setProgramStage( object.getProgramStage() );
             params.setStartDate( object.getStartDate() );
             params.setEndDate( object.getEndDate() );
+            params.setValue( object.getValue() );
             params.setOutputType( object.getOutputType() );
         }
         

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventchart/EventChart.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventchart/EventChart.hbm.xml	2015-02-16 14:25:40 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventchart/EventChart.hbm.xml	2015-02-18 17:33:23 +0000
@@ -89,6 +89,12 @@
 
     <property name="endDate" />
 
+    <many-to-one name="dataElementValueDimension" class="org.hisp.dhis.dataelement.DataElement" 
+      column="dataelementvaluedimensionid" foreign-key="fk_eventchart_dataelementvaluedimensionid" />
+
+    <many-to-one name="attributeValueDimension" class="org.hisp.dhis.trackedentity.TrackedEntityAttribute" 
+      column="attributevaluedimensionid" foreign-key="fk_eventchart_attributevaluedimensionid" />
+
     <property name="type" not-null="true" />
 
     <list name="columnDimensions" table="eventchart_columns">

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml	2015-02-16 14:25:40 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml	2015-02-18 17:33:23 +0000
@@ -88,6 +88,12 @@
     <property name="startDate" />
 
     <property name="endDate" />
+    
+    <many-to-one name="dataElementValueDimension" class="org.hisp.dhis.dataelement.DataElement" 
+      column="dataelementvaluedimensionid" foreign-key="fk_eventreport_dataelementvaluedimensionid" />
+
+    <many-to-one name="attributeValueDimension" class="org.hisp.dhis.trackedentity.TrackedEntityAttribute" 
+      column="attributevaluedimensionid" foreign-key="fk_eventreport_attributevaluedimensionid" />
 
     <property name="dataType" not-null="true" />
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java	2015-02-17 06:00:52 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java	2015-02-18 17:33:23 +0000
@@ -216,26 +216,27 @@
     // Supportive methods
     //--------------------------------------------------------------------------
 
-    private void mergeEventChart( EventChart eventChart )
+    private void mergeEventChart( EventChart chart )
     {
-        dimensionService.mergeAnalyticalObject( eventChart );
-
-        eventChart.getColumnDimensions().clear();
-        eventChart.getRowDimensions().clear();
-        eventChart.getFilterDimensions().clear();
-
-        eventChart.getColumnDimensions().addAll( getDimensions( eventChart.getColumns() ) );
-        eventChart.getRowDimensions().addAll( getDimensions( eventChart.getRows() ) );
-        eventChart.getFilterDimensions().addAll( getDimensions( eventChart.getFilters() ) );
-
-        if ( eventChart.getProgram() != null )
+        dimensionService.mergeAnalyticalObject( chart );
+        dimensionService.mergeEventAnalyticalObject( chart );
+
+        chart.getColumnDimensions().clear();
+        chart.getRowDimensions().clear();
+        chart.getFilterDimensions().clear();
+
+        chart.getColumnDimensions().addAll( getDimensions( chart.getColumns() ) );
+        chart.getRowDimensions().addAll( getDimensions( chart.getRows() ) );
+        chart.getFilterDimensions().addAll( getDimensions( chart.getFilters() ) );
+
+        if ( chart.getProgram() != null )
         {
-            eventChart.setProgram( programService.getProgram( eventChart.getProgram().getUid() ) );
+            chart.setProgram( programService.getProgram( chart.getProgram().getUid() ) );
         }
 
-        if ( eventChart.getProgramStage() != null )
+        if ( chart.getProgramStage() != null )
         {
-            eventChart.setProgramStage( programStageService.getProgramStage( eventChart.getProgramStage().getUid() ) );
+            chart.setProgramStage( programStageService.getProgramStage( chart.getProgramStage().getUid() ) );
         }
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java	2015-02-17 06:00:52 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java	2015-02-18 17:33:23 +0000
@@ -166,6 +166,7 @@
     private void mergeEventReport( EventReport report )
     {
         dimensionService.mergeAnalyticalObject( report );
+        dimensionService.mergeEventAnalyticalObject( report );
 
         report.getColumnDimensions().clear();
         report.getRowDimensions().clear();