use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class ObjectBundleServiceFavoritesTest method testCreateMetadataWithVisualizationsWithPeriods.
@Test
void testCreateMetadataWithVisualizationsWithPeriods() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/favorites/metadata_with_visualization_periods.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);
assertFalse(validate.hasErrorReports());
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<Visualization> visualizations = manager.getAll(Visualization.class);
assertEquals(1, dataSets.size());
assertEquals(1, organisationUnits.size());
assertEquals(4, dataElements.size());
assertEquals(4, visualizations.size());
Visualization visualization = manager.get(Visualization.class, "ziCoxdcXRQz");
assertNotNull(visualization);
assertEquals(5, visualization.getPeriods().size());
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class InterpretationController method writeVisualizationInterpretation.
// -------------------------------------------------------------------------
// Interpretation create
// -------------------------------------------------------------------------
@PostMapping(value = "/visualization/{uid}", consumes = { "text/html", "text/plain" })
@ResponseBody
public WebMessage writeVisualizationInterpretation(@PathVariable("uid") String uid, @RequestParam(value = "ou", required = false) String orgUnitUid, @CurrentUser User currentUser, @RequestBody String text) throws WebMessageException {
final Visualization visualization = idObjectManager.get(Visualization.class, uid);
if (visualization == null) {
return conflict("Visualization does not exist or is not accessible: " + uid);
}
final OrganisationUnit orgUnit = getUserOrganisationUnit(orgUnitUid, visualization, currentUser);
return createInterpretation(new Interpretation(visualization, orgUnit, text));
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class DashboardCascadeSharingTest method testCascadeShareVisualization.
/**
* Dashboard has sharingUserA and visualizationA
* <p>
* visualizationA has dataElementA
* <p>
* Expected: visualizationA and dataElementA should be shared to userA
*/
@Test
void testCascadeShareVisualization() {
DataElement dataElementA = createDEWithDefaultSharing('A');
objectManager.save(dataElementA);
DataElement dataElementB = createDEWithDefaultSharing('B');
objectManager.save(dataElementB);
Visualization visualizationA = createVisualization('A');
visualizationA.addDataDimensionItem(dataElementA);
visualizationA.addDataDimensionItem(dataElementB);
visualizationA.setSharing(Sharing.builder().publicAccess(DEFAULT).build());
objectManager.save(visualizationA, false);
Dashboard dashboard = createDashboardWithItem("A", sharingReadForUserAB);
dashboard.getItems().get(0).setVisualization(visualizationA);
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, visualizationA));
assertTrue(aclService.canRead(userB, visualizationA));
assertTrue(aclService.canRead(userA, updatedDataElementA));
assertTrue(aclService.canRead(userB, updatedDataElementB));
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class InterpretationControllerTest method setUp.
@BeforeEach
void setUp() {
OrganisationUnit ouA = createOrganisationUnit('A');
manager.save(ouA);
Visualization vzA = createVisualization('A');
visualizationService.save(vzA);
Interpretation ipA = new Interpretation(vzA, ouA, "Interpration of visualization A");
interpretationService.saveInterpretation(ipA);
uid = ipA.getUid();
ouId = ouA.getUid();
}
use of org.hisp.dhis.visualization.Visualization in project dhis2-core by dhis2.
the class DimensionServiceTest method testMergeAnalyticalObjectDataElementGroupSet.
@Test
void testMergeAnalyticalObjectDataElementGroupSet() {
Visualization visualization = new Visualization();
visualization.getColumns().add(new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB)));
visualization.getRows().add(deGroupSetA);
visualization.getFilters().add(new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList(peA, peB)));
dimensionService.mergeAnalyticalObject(visualization);
assertEquals(2, visualization.getDataDimensionItems().size());
assertEquals(2, visualization.getPeriods().size());
assertEquals(1, visualization.getDataElementGroupSetDimensions().size());
assertEquals(3, visualization.getDataElementGroupSetDimensions().get(0).getItems().size());
}
Aggregations