use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.
the class AnalyticalObjectEmbeddedDimensionUpgrader method executeInTransaction.
@Override
public void executeInTransaction() {
BiConsumer<BaseDimensionalEmbeddedObject, AnalyticalObject> dataElementGroupSetConsumer = (embeddedDimension, analyticalObject) -> {
DataElementGroupSetDimension dimension = new DataElementGroupSetDimension();
dimension.setDimension((DataElementGroupSet) embeddedDimension.getDimension());
dimension.setItems(DimensionalObjectUtils.asTypedList(embeddedDimension.getItems()));
analyticalObject.addDataElementGroupSetDimension(dimension);
};
BiConsumer<BaseDimensionalEmbeddedObject, AnalyticalObject> orgUnitGroupSetConsumer = (embeddedDimension, analyticalObject) -> {
OrganisationUnitGroupSetDimension dimension = new OrganisationUnitGroupSetDimension();
dimension.setDimension((OrganisationUnitGroupSet) embeddedDimension.getDimension());
dimension.setItems(DimensionalObjectUtils.asTypedList(embeddedDimension.getItems()));
analyticalObject.addOrganisationUnitGroupSetDimension(dimension);
};
BiConsumer<BaseDimensionalEmbeddedObject, AnalyticalObject> categoryOptionGroupSetConsumer = (embeddedDimension, analyticalObject) -> {
CategoryOptionGroupSetDimension dimension = new CategoryOptionGroupSetDimension();
dimension.setDimension((CategoryOptionGroupSet) embeddedDimension.getDimension());
dimension.setItems(DimensionalObjectUtils.asTypedList(embeddedDimension.getItems()));
analyticalObject.addCategoryOptionGroupSetDimension(dimension);
};
try {
upgradeGrupSetDimensions("reporttable", "orgunitgroupset", "orgunitgroup", ReportTable.class, OrganisationUnitGroupSet.class, OrganisationUnitGroup.class, orgUnitGroupSetConsumer);
upgradeGrupSetDimensions("reporttable", "dataelementgroupset", "dataelementgroup", ReportTable.class, DataElementGroupSet.class, DataElementGroup.class, dataElementGroupSetConsumer);
upgradeGrupSetDimensions("reporttable", "categoryoptiongroupset", "categoryoptiongroup", ReportTable.class, CategoryOptionGroupSet.class, CategoryOptionGroup.class, categoryOptionGroupSetConsumer);
upgradeGrupSetDimensions("chart", "orgunitgroupset", "orgunitgroup", Chart.class, OrganisationUnitGroupSet.class, OrganisationUnitGroup.class, orgUnitGroupSetConsumer);
upgradeGrupSetDimensions("chart", "dataelementgroupset", "dataelementgroup", Chart.class, DataElementGroupSet.class, DataElementGroup.class, dataElementGroupSetConsumer);
upgradeGrupSetDimensions("chart", "categoryoptiongroupset", "categoryoptiongroup", Chart.class, CategoryOptionGroupSet.class, CategoryOptionGroup.class, categoryOptionGroupSetConsumer);
upgradeGrupSetDimensions("eventreport", "orgunitgroupset", "orgunitgroup", EventReport.class, OrganisationUnitGroupSet.class, OrganisationUnitGroup.class, orgUnitGroupSetConsumer);
upgradeGrupSetDimensions("eventchart", "orgunitgroupset", "orgunitgroup", EventChart.class, OrganisationUnitGroupSet.class, OrganisationUnitGroup.class, orgUnitGroupSetConsumer);
} catch (Exception ex) {
log.debug("Error during group set dimensions upgrade of favorite, probably because upgrade was already done", ex);
return;
}
}
use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.
the class ReportStoreTest method setUpTest.
// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@Override
public void setUpTest() {
reportTableA = new ReportTable();
reportTableA.setName("ReportTableA");
reportTableService.saveReportTable(reportTableA);
}
use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.
the class AclServiceTest method testCanUpdatePrivateReportTable.
@Test
public void testCanUpdatePrivateReportTable() {
User user = createAdminUser("F_DATAELEMENT_PRIVATE_ADD");
ReportTable reportTable = new ReportTable();
reportTable.setAutoFields();
reportTable.setUser(user);
reportTable.setPublicAccess(AccessStringHelper.DEFAULT);
assertTrue(aclService.canUpdate(user, reportTable));
}
use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.
the class ObjectBundleServiceFavoritesTest method testCreateMetadataWithReportTables1.
@Test
public void testCreateMetadataWithReportTables1() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/favorites/metadata_with_rt1.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<ReportTable> reportTables = manager.getAll(ReportTable.class);
assertEquals(1, dataSets.size());
assertEquals(1, organisationUnits.size());
assertEquals(4, dataElements.size());
assertEquals(3, reportTables.size());
}
use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.
the class ReportTableController method deserializeJsonEntity.
//--------------------------------------------------------------------------
// CRUD
//--------------------------------------------------------------------------
@Override
protected ReportTable deserializeJsonEntity(HttpServletRequest request, HttpServletResponse response) throws IOException {
ReportTable reportTable = super.deserializeJsonEntity(request, response);
mergeReportTable(reportTable);
return reportTable;
}
Aggregations