Search in sources :

Example 1 with Chart

use of org.hisp.dhis.chart.Chart in project dhis2-core by dhis2.

the class ActivityReportingServiceImpl method getInterpretation.

@Override
public Interpretation getInterpretation(String uId) throws NotAllowedException {
    Chart chart = chartService.getChart(uId);
    org.hisp.dhis.interpretation.Interpretation interpretationCore = interpretationService.getInterpretationByChart(chart.getId());
    Collection<InterpretationComment> interComments = new HashSet<>();
    for (org.hisp.dhis.interpretation.InterpretationComment interCommentsCore : interpretationCore.getComments()) {
        InterpretationComment interComment = new InterpretationComment();
        interComment.setText(interCommentsCore.getText());
        interComments.add(interComment);
    }
    Interpretation interpretation = new Interpretation();
    interpretation.setId(interpretationCore.getId());
    interpretation.setText(interpretationCore.getText());
    interpretation.setInComments(interComments);
    return interpretation;
}
Also used : InterpretationComment(org.hisp.dhis.api.mobile.model.InterpretationComment) Interpretation(org.hisp.dhis.api.mobile.model.Interpretation) Chart(org.hisp.dhis.chart.Chart) HashSet(java.util.HashSet)

Example 2 with Chart

use of org.hisp.dhis.chart.Chart in project dhis2-core by dhis2.

the class ActivityReportingServiceImpl method postInterpretation.

@Override
public String postInterpretation(String data) throws NotAllowedException {
    String uId = data.substring(0, 11);
    String interpretation = data.substring(11, data.length() - 0);
    Chart c = chartService.getChart(uId);
    org.hisp.dhis.interpretation.Interpretation i = new org.hisp.dhis.interpretation.Interpretation(c, null, interpretation);
    i.setUser(currentUserService.getCurrentUser());
    interpretationService.saveInterpretation(i);
    return INTERPRETATION_SENT;
}
Also used : Interpretation(org.hisp.dhis.api.mobile.model.Interpretation) Chart(org.hisp.dhis.chart.Chart)

Example 3 with Chart

use of org.hisp.dhis.chart.Chart in project dhis2-core by dhis2.

the class DhisConvenienceTest method createChart.

public static Chart createChart(char uniqueCharacter) {
    Chart chart = new Chart();
    chart.setAutoFields();
    chart.setName("Chart" + uniqueCharacter);
    chart.setDescription("Description" + uniqueCharacter);
    chart.setType(ChartType.COLUMN);
    return chart;
}
Also used : Chart(org.hisp.dhis.chart.Chart)

Example 4 with Chart

use of org.hisp.dhis.chart.Chart in project dhis2-core by dhis2.

the class ObjectBundleServiceFavoritesTest method testCreateMetadataWithChartsWithPeriods1.

@Test
public void testCreateMetadataWithChartsWithPeriods1() throws IOException {
    Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/favorites/metadata_with_chart_periods1.json").getInputStream(), RenderFormat.JSON);
    ObjectBundleParams params = new ObjectBundleParams();
    params.setObjectBundleMode(ObjectBundleMode.COMMIT);
    params.setImportStrategy(ImportStrategy.CREATE_AND_UPDATE);
    params.setObjects(metadata);
    ObjectBundle bundle = objectBundleService.create(params);
    ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle);
    assertTrue(validate.getErrorReports().isEmpty());
    objectBundleService.commit(bundle);
    List<DataSet> dataSets = manager.getAll(DataSet.class);
    List<OrganisationUnit> organisationUnits = manager.getAll(OrganisationUnit.class);
    List<DataElement> dataElements = manager.getAll(DataElement.class);
    List<Chart> charts = manager.getAll(Chart.class);
    assertEquals(1, dataSets.size());
    assertEquals(1, organisationUnits.size());
    assertEquals(4, dataElements.size());
    assertEquals(4, charts.size());
    Chart chart = manager.get(Chart.class, "ziCoxdcXRQz");
    assertNotNull(chart);
    assertEquals(5, chart.getPeriods().size());
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) ObjectBundleValidationReport(org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport) DataSet(org.hisp.dhis.dataset.DataSet) ClassPathResource(org.springframework.core.io.ClassPathResource) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject) DataElement(org.hisp.dhis.dataelement.DataElement) List(java.util.List) Chart(org.hisp.dhis.chart.Chart) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 5 with Chart

use of org.hisp.dhis.chart.Chart in project dhis2-core by dhis2.

the class ChartController 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 {
    Chart chart = chartService.getChartNoAcl(uid);
    if (chart == null) {
        throw new WebMessageException(WebMessageUtils.notFound("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) JFreeChart(org.jfree.chart.JFreeChart) Chart(org.hisp.dhis.chart.Chart) JFreeChart(org.jfree.chart.JFreeChart) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Chart (org.hisp.dhis.chart.Chart)12 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)4 List (java.util.List)3 DhisSpringTest (org.hisp.dhis.DhisSpringTest)3 EventChart (org.hisp.dhis.eventchart.EventChart)3 Test (org.junit.Test)3 Interpretation (org.hisp.dhis.api.mobile.model.Interpretation)2 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)2 DataElement (org.hisp.dhis.dataelement.DataElement)2 DataSet (org.hisp.dhis.dataset.DataSet)2 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)2 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)2 Interpretation (org.hisp.dhis.interpretation.Interpretation)2 JFreeChart (org.jfree.chart.JFreeChart)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 BiConsumer (java.util.function.BiConsumer)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1