use of org.hisp.dhis.eventchart.EventChart in project dhis2-core by dhis2.
the class EventChartController method deserializeJsonEntity.
//--------------------------------------------------------------------------
// CRUD
//--------------------------------------------------------------------------
@Override
protected EventChart deserializeJsonEntity(HttpServletRequest request, HttpServletResponse response) throws IOException {
EventChart eventChart = super.deserializeJsonEntity(request, response);
mergeEventChart(eventChart);
return eventChart;
}
use of org.hisp.dhis.eventchart.EventChart in project dhis2-core by dhis2.
the class EventChartController method getChart.
//--------------------------------------------------------------------------
// Get data
//--------------------------------------------------------------------------
@RequestMapping(value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET)
public void getChart(@PathVariable("uid") String uid, @RequestParam(value = "date", required = false) Date date, @RequestParam(value = "ou", required = false) String ou, @RequestParam(value = "width", defaultValue = "800", required = false) int width, @RequestParam(value = "height", defaultValue = "500", required = false) int height, @RequestParam(value = "attachment", required = false) boolean attachment, HttpServletResponse response) throws IOException, WebMessageException {
// TODO no acl?
EventChart chart = eventChartService.getEventChart(uid);
if (chart == null) {
throw new WebMessageException(WebMessageUtils.notFound("Event chart does not exist: " + uid));
}
OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit(ou) : null;
JFreeChart jFreeChart = chartService.getJFreeChart(chart, date, unit, i18nManager.getI18nFormat());
String filename = CodecUtils.filenameEncode(chart.getName()) + ".png";
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, attachment);
ChartUtilities.writeChartAsPNG(response.getOutputStream(), jFreeChart, width, height);
}
use of org.hisp.dhis.eventchart.EventChart in project dhis2-core by dhis2.
the class InterpretationController method writeEventChartInterpretation.
@RequestMapping(value = "/eventChart/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" })
public void writeEventChartInterpretation(@PathVariable("uid") String uid, @RequestParam(value = "ou", required = false) String orgUnitUid, @RequestBody String text, HttpServletResponse response, HttpServletRequest request) throws WebMessageException {
EventChart eventChart = idObjectManager.get(EventChart.class, uid);
if (eventChart == null) {
throw new WebMessageException(WebMessageUtils.conflict("Event chart does not exist or is not accessible: " + uid));
}
OrganisationUnit orgUnit = getUserOrganisationUnit(orgUnitUid, eventChart, currentUserService.getCurrentUser());
createIntepretation(new Interpretation(eventChart, orgUnit, text), request, response);
}
use of org.hisp.dhis.eventchart.EventChart in project dhis2-core by dhis2.
the class BaseAnalyticalObjectTest method testPopulateAnalyticalProperties.
@Test
public void testPopulateAnalyticalProperties() {
TrackedEntityAttribute tea = new TrackedEntityAttribute();
tea.setAutoFields();
TrackedEntityAttributeDimension tead = new TrackedEntityAttributeDimension(tea, null, "EQ:10");
EventChart eventChart = new EventChart();
eventChart.setAutoFields();
eventChart.getColumnDimensions().add(tea.getUid());
eventChart.getAttributeDimensions().add(tead);
eventChart.populateAnalyticalProperties();
assertEquals(1, eventChart.getColumns().size());
DimensionalObject dim = eventChart.getColumns().get(0);
assertNotNull(dim);
assertEquals(DimensionType.PROGRAM_ATTRIBUTE, dim.getDimensionType());
assertEquals(AnalyticsType.EVENT, dim.getAnalyticsType());
assertEquals(tead.getFilter(), dim.getFilter());
}
use of org.hisp.dhis.eventchart.EventChart in project dhis2-core by dhis2.
the class EventDataQueryServiceTest method testGetFromAnalyticalObjectA.
@Test
public void testGetFromAnalyticalObjectA() {
EventChart eventChart = new EventChart();
eventChart.setAutoFields();
eventChart.setProgram(prA);
eventChart.getColumnDimensions().add(atA.getUid());
eventChart.getRowDimensions().add(DimensionalObject.ORGUNIT_DIM_ID);
eventChart.getFilterDimensions().add(DimensionalObject.PERIOD_DIM_ID);
eventChart.getAttributeDimensions().add(new TrackedEntityAttributeDimension(atA, null, "LE:5"));
eventChart.getPeriods().add(peA);
eventChart.getPeriods().add(peB);
eventChart.getOrganisationUnits().add(ouA);
eventChart.getOrganisationUnits().add(ouB);
EventQueryParams params = dataQueryService.getFromAnalyticalObject(eventChart);
assertNotNull(params);
assertEquals(1, params.getItems().size());
assertEquals(2, params.getOrganisationUnits().size());
assertEquals(2, params.getFilterPeriods().size());
}
Aggregations