use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class InterpretationController method writeEventVisualizationInterpretation.
@PostMapping(value = "/eventVisualization/{uid}", consumes = { "text/html", "text/plain" })
@ResponseBody
public WebMessage writeEventVisualizationInterpretation(@PathVariable("uid") final String uid, @RequestParam(value = "ou", required = false) final String orgUnitUid, @RequestBody final String text) throws WebMessageException {
final EventVisualization eventVisualization = idObjectManager.get(EventVisualization.class, uid);
if (eventVisualization == null) {
return conflict("EventVisualization does not exist or is not accessible: " + uid);
}
final OrganisationUnit orgUnit = getUserOrganisationUnit(orgUnitUid, eventVisualization, currentUserService.getCurrentUser());
/*
* This is needed until the deprecated entities (EventChart and
* EventReport) are completely removed from the code base. Until there
* all interpretations saved on the new EventVisualization entity should
* also be available for the deprecated ones.
*/
switch(eventVisualization.getType()) {
case LINE_LIST:
case PIVOT_TABLE:
final EventReport eventReport = idObjectManager.get(EventReport.class, eventVisualization.getUid());
return createInterpretation(new Interpretation(eventVisualization, eventReport, orgUnit, text));
default:
final EventChart eventChart = idObjectManager.get(EventChart.class, eventVisualization.getUid());
return createInterpretation(new Interpretation(eventVisualization, eventChart, orgUnit, text));
}
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class DashboardCascadeSharingTest method testCascadeShareEventVisualization.
/**
* Dashboard has sharingUserA and eventVisualizationA
* <p>
* eventVisualizationA has dataElementA
* <p>
* Expected: eventVisualizationA and dataElementA should be shared to userA
*/
@Test
void testCascadeShareEventVisualization() {
DataElement dataElementA = createDEWithDefaultSharing('A');
objectManager.save(dataElementA);
DataElement dataElementB = createDEWithDefaultSharing('B');
objectManager.save(dataElementB);
Program program = createProgram('Y', null, null);
objectManager.save(program);
EventVisualization eventVisualizationA = createEventVisualization('A', program);
eventVisualizationA.addDataDimensionItem(dataElementA);
eventVisualizationA.addDataDimensionItem(dataElementB);
eventVisualizationA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
objectManager.save(eventVisualizationA, false);
Dashboard dashboard = createDashboardWithItem("A", sharingReadForUserAB);
dashboard.getItems().get(0).setEventVisualization(eventVisualizationA);
objectManager.save(dashboard, false);
CascadeSharingReport report = cascadeSharingService.cascadeSharing(dashboard, new CascadeSharingParameters());
assertEquals(0, report.getErrorReports().size());
DataElement updatedDataElementA = objectManager.get(DataElement.class, dataElementA.getUid());
DataElement updatedDataElementB = objectManager.get(DataElement.class, dataElementB.getUid());
assertTrue(aclService.canRead(userA, eventVisualizationA));
assertTrue(aclService.canRead(userB, eventVisualizationA));
assertTrue(aclService.canRead(userA, updatedDataElementA));
assertTrue(aclService.canRead(userB, updatedDataElementB));
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class DimensionServiceTest method testMergeEventAnalyticalObject.
@Test
void testMergeEventAnalyticalObject() {
// Given
EventVisualization eventVisualization = new EventVisualization("any");
eventVisualization.setValue(deC);
// When
dimensionService.mergeEventAnalyticalObject(eventVisualization);
// Then
assertNotNull(eventVisualization.getDataElementValueDimension());
assertNull(eventVisualization.getAttributeValueDimension());
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class DimensionServiceTest method testMergeAnalyticalEventObjectA.
@Test
void testMergeAnalyticalEventObjectA() {
// Given
EventVisualization eventVisualization = new EventVisualization("any");
eventVisualization.getColumns().add(new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB)));
eventVisualization.getRows().add(new BaseDimensionalObject(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, Lists.newArrayList(ouA, ouB, ouC, ouD, ouE)));
eventVisualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA, peB)));
// When
dimensionService.mergeAnalyticalObject(eventVisualization);
// Then
assertEquals(2, eventVisualization.getDataDimensionItems().size());
assertEquals(2, eventVisualization.getPeriods().size());
assertEquals(5, eventVisualization.getOrganisationUnits().size());
}
use of org.hisp.dhis.eventvisualization.EventVisualization in project dhis2-core by dhis2.
the class DimensionServiceTest method testMergeAnalyticalEventObjectOrgUnitLevel.
@Test
void testMergeAnalyticalEventObjectOrgUnitLevel() {
// Given
EventVisualization eventVisualization = new EventVisualization("any");
eventVisualization.getColumns().add(new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB)));
eventVisualization.getRows().add(new BaseDimensionalObject(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, Lists.newArrayList(ouLevel2, ouA)));
eventVisualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA)));
// When
dimensionService.mergeAnalyticalObject(eventVisualization);
// Then
assertEquals(2, eventVisualization.getDataDimensionItems().size());
assertEquals(1, eventVisualization.getPeriods().size());
assertEquals(1, eventVisualization.getOrganisationUnits().size());
assertEquals(Integer.valueOf(2), eventVisualization.getOrganisationUnitLevels().get(0));
}
Aggregations