use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class DefaultChartService method getJFreeOrganisationUnitChart.
@Override
@Transactional(readOnly = true)
public JFreeChart getJFreeOrganisationUnitChart(Indicator indicator, OrganisationUnit parent, boolean title, I18nFormat format) {
List<Period> periods = periodService.reloadPeriods(new RelativePeriods().setThisYear(true).getRelativePeriods(format, true));
Visualization visualization = new Visualization();
if (title) {
visualization.setName(indicator.getName());
}
visualization.setType(VisualizationType.COLUMN);
visualization.setColumnDimensions(Arrays.asList(DimensionalObject.DATA_X_DIM_ID));
visualization.setRowDimensions(Arrays.asList(DimensionalObject.ORGUNIT_DIM_ID));
visualization.setFilterDimensions(Arrays.asList(DimensionalObject.PERIOD_DIM_ID));
visualization.setHideLegend(true);
visualization.addDataDimensionItem(indicator);
visualization.setPeriods(periods);
visualization.setOrganisationUnits(parent.getSortedChildren());
visualization.setHideSubtitle(title);
visualization.setFormat(format);
return getJFreeChart(new PlotData(visualization));
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class AnalyticalObjectOrgUnitSplitHandlerTest method testSplitVisualizations.
@Test
void testSplitVisualizations() {
Visualization vA = createVisualization('A');
vA.addDataDimensionItem(deA);
vA.getOrganisationUnits().add(ouA);
Visualization vB = createVisualization('B');
vB.addDataDimensionItem(deA);
vB.getOrganisationUnits().add(ouA);
idObjectManager.save(vA);
idObjectManager.save(vB);
assertEquals(2, getVisualizationCount(ouA));
assertEquals(0, getVisualizationCount(ouB));
assertEquals(0, getVisualizationCount(ouC));
OrgUnitSplitRequest request = new OrgUnitSplitRequest.Builder().withSource(ouA).addTarget(ouB).addTarget(ouC).withPrimaryTarget(ouB).build();
handler.splitAnalyticalObjects(request);
idObjectManager.update(ouC);
assertEquals(0, getVisualizationCount(ouA));
assertEquals(2, getVisualizationCount(ouB));
assertEquals(2, getVisualizationCount(ouC));
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class DashboardServiceTest method createVisualization.
private Visualization createVisualization(String name) {
Visualization visualization = createVisualization('X');
visualization.setName(name);
return visualization;
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class DashboardCascadeSharingTest method testCascadeIndicatorAndDataElement.
@Test
void testCascadeIndicatorAndDataElement() {
IndicatorType indicatorType = createIndicatorType('A');
objectManager.save(indicatorType);
Indicator indicatorA = createIndicator('A', indicatorType);
indicatorA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
objectManager.save(indicatorA, false);
DataElement dataElementA = createDEWithDefaultSharing('A');
objectManager.save(dataElementA, false);
Visualization visualizationA = createVisualization('A');
visualizationA.addDataDimensionItem(dataElementA);
visualizationA.addDataDimensionItem(indicatorA);
visualizationA.setSharing(defaultSharing());
objectManager.save(visualizationA, false);
Dashboard dashboard = createDashboardWithItem("a", sharingReadForUserA);
dashboard.getItems().get(0).setVisualization(visualizationA);
objectManager.save(dashboard, false);
CascadeSharingReport report = cascadeSharingService.cascadeSharing(dashboard, new CascadeSharingParameters());
assertEquals(0, report.getErrorReports().size());
assertEquals(3, report.getUpdateObjects().size());
assertEquals(1, report.getUpdateObjects().get(DataElementSchemaDescriptor.PLURAL).size());
assertEquals(1, report.getUpdateObjects().get(IndicatorSchemaDescriptor.PLURAL).size());
assertEquals(1, report.getUpdateObjects().get(VisualizationSchemaDescriptor.PLURAL).size());
DataElement updatedDataElementA = objectManager.get(DataElement.class, dataElementA.getUid());
Indicator updatedIndicatorA = objectManager.get(Indicator.class, indicatorA.getUid());
assertTrue(aclService.canRead(userA, visualizationA));
assertTrue(aclService.canRead(userA, updatedDataElementA));
assertTrue(aclService.canRead(userA, updatedIndicatorA));
assertFalse(aclService.canRead(userB, visualizationA));
assertFalse(aclService.canRead(userB, updatedDataElementA));
assertFalse(aclService.canRead(userB, updatedIndicatorA));
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class DashboardCascadeSharingTest method testCascadeShareVisualizationError.
@Test
void testCascadeShareVisualizationError() {
DataElement dataElementA = createDataElement('A');
dataElementA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
objectManager.save(dataElementA, false);
Visualization vzA = createVisualization('A');
vzA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
vzA.addDataDimensionItem(dataElementA);
objectManager.save(vzA, false);
Sharing sharing = new Sharing();
sharing.setPublicAccess(DEFAULT);
sharing.addUserAccess(new UserAccess(userB, DEFAULT));
Dashboard dashboard = createDashboardWithItem("A", sharing);
dashboard.getItems().get(0).setVisualization(vzA);
objectManager.save(dashboard, false);
CascadeSharingReport report = cascadeSharingService.cascadeSharing(dashboard, new CascadeSharingParameters());
assertEquals(0, report.getUpdateObjects().size());
assertFalse(aclService.canRead(userB, vzA));
assertFalse(aclService.canRead(userB, dataElementA));
}
Aggregations