Search in sources :

Example 6 with EventChart

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;
}
Also used : EventChart(org.hisp.dhis.eventchart.EventChart)

Example 7 with 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);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) EventChart(org.hisp.dhis.eventchart.EventChart) JFreeChart(org.jfree.chart.JFreeChart) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with EventChart

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);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) EventChart(org.hisp.dhis.eventchart.EventChart) Interpretation(org.hisp.dhis.interpretation.Interpretation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with EventChart

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());
}
Also used : TrackedEntityAttributeDimension(org.hisp.dhis.trackedentity.TrackedEntityAttributeDimension) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) EventChart(org.hisp.dhis.eventchart.EventChart) Test(org.junit.Test)

Example 10 with EventChart

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());
}
Also used : TrackedEntityAttributeDimension(org.hisp.dhis.trackedentity.TrackedEntityAttributeDimension) EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) EventChart(org.hisp.dhis.eventchart.EventChart) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

EventChart (org.hisp.dhis.eventchart.EventChart)11 Test (org.junit.Test)6 DhisSpringTest (org.hisp.dhis.DhisSpringTest)5 TrackedEntityAttributeDimension (org.hisp.dhis.trackedentity.TrackedEntityAttributeDimension)5 EventQueryParams (org.hisp.dhis.analytics.event.EventQueryParams)3 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)2 DimensionalObject (org.hisp.dhis.common.DimensionalObject)2 CategoryOptionGroup (org.hisp.dhis.dataelement.CategoryOptionGroup)2 CategoryOptionGroupSet (org.hisp.dhis.dataelement.CategoryOptionGroupSet)2 DataElementGroupSet (org.hisp.dhis.dataelement.DataElementGroupSet)2 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)2 EventReport (org.hisp.dhis.eventreport.EventReport)2 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)2 OrganisationUnitGroupSet (org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 BiConsumer (java.util.function.BiConsumer)1 Log (org.apache.commons.logging.Log)1