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;
}
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;
}
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;
}
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());
}
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);
}
Aggregations