dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28864
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14490: Event report, mergeWith
------------------------------------------------------------
revno: 14490
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-03-27 15:00:01 +0100
message:
Event report, mergeWith
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/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/eventreport/EventReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java 2014-03-27 13:53:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java 2014-03-27 14:00:01 +0000
@@ -33,12 +33,22 @@
import java.util.List;
import org.hisp.dhis.common.BaseAnalyticalObject;
+import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.IdentifiableObject;
+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.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.user.User;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+
/**
* @author Lars Helge Overland
*/
@@ -108,10 +118,29 @@
{
}
+ @Override
+ public void mergeWith( IdentifiableObject other )
+ {
+ super.mergeWith( other );
+
+ if ( other.getClass().isInstance( this ) )
+ {
+ EventReport report = (EventReport) other;
+
+ program = report.getProgram();
+ programStage = report.getProgramStage();
+ startDate = report.getStartDate();
+ endDate = report.getEndDate();
+ }
+ }
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public Program getProgram()
{
return program;
@@ -122,6 +151,9 @@
this.program = program;
}
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public ProgramStage getProgramStage()
{
return programStage;
@@ -132,6 +164,9 @@
this.programStage = programStage;
}
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public Date getStartDate()
{
return startDate;
@@ -142,6 +177,9 @@
this.startDate = startDate;
}
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public Date getEndDate()
{
return endDate;
@@ -152,6 +190,10 @@
this.endDate = endDate;
}
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class} )
+ @JacksonXmlElementWrapper( localName = "columnDimensions", namespace = DxfNamespaces.DXF_2_0)
+ @JacksonXmlProperty( localName = "column", namespace = DxfNamespaces.DXF_2_0)
public List<String> getColumnDimensions()
{
return columnDimensions;
@@ -162,6 +204,10 @@
this.columnDimensions = columnDimensions;
}
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class} )
+ @JacksonXmlElementWrapper( localName = "rowDimensions", namespace = DxfNamespaces.DXF_2_0)
+ @JacksonXmlProperty( localName = "row", namespace = DxfNamespaces.DXF_2_0)
public List<String> getRowDimensions()
{
return rowDimensions;
@@ -172,6 +218,10 @@
this.rowDimensions = rowDimensions;
}
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class} )
+ @JacksonXmlElementWrapper( localName = "filterDimensions", namespace = DxfNamespaces.DXF_2_0)
+ @JacksonXmlProperty( localName = "filter", namespace = DxfNamespaces.DXF_2_0)
public List<String> getFilterDimensions()
{
return filterDimensions;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventReportController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventReportController.java 2014-03-26 22:56:33 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventReportController.java 2014-03-27 14:00:01 +0000
@@ -41,6 +41,8 @@
import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.eventreport.EventReport;
import org.hisp.dhis.eventreport.EventReportService;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -62,6 +64,12 @@
@Autowired
private DimensionService dimensionService;
+ @Autowired
+ private ProgramService programService;
+
+ @Autowired
+ private ProgramStageService programStageService;
+
//--------------------------------------------------------------------------
// CRUD
//--------------------------------------------------------------------------
@@ -94,5 +102,15 @@
report.getColumnDimensions().addAll( getUniqueDimensions( report.getColumns() ) );
report.getRowDimensions().addAll( getUniqueDimensions( report.getRows() ) );
report.getFilterDimensions().addAll( getUniqueDimensions( report.getFilters() ) );
+
+ if ( report.getProgram() != null )
+ {
+ report.setProgram( programService.getProgram( report.getProgram().getUid() ) );
+ }
+
+ if ( report.getProgramStage() != null )
+ {
+ report.setProgramStage( programStageService.getProgramStage( report.getProgramStage().getUid() ) );
+ }
}
}