use of org.hisp.dhis.dataelement.DataElementGroupSet 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.dataelement.DataElementGroupSet in project dhis2-core by dhis2.
the class ListMapTest method testGetListMapValueMapper.
@Test
public void testGetListMapValueMapper() {
DataElementGroupSet groupSetA = new DataElementGroupSet("GroupSetA");
DataElementGroupSet groupSetB = new DataElementGroupSet("GroupSetB");
DataElementGroupSet groupSetC = new DataElementGroupSet("GroupSetC");
DataElementGroupSet groupSetZ = new DataElementGroupSet("GroupSetZ");
DataElementGroup groupA = new DataElementGroup("GroupA");
DataElementGroup groupB = new DataElementGroup("GroupB");
DataElementGroup groupC = new DataElementGroup("GroupC");
DataElementGroup groupD = new DataElementGroup("GroupD");
DataElementGroup groupE = new DataElementGroup("GroupE");
DataElementGroup groupF = new DataElementGroup("GroupF");
groupA.getGroupSets().add(groupSetA);
groupB.getGroupSets().add(groupSetB);
groupC.getGroupSets().add(groupSetC);
groupD.getGroupSets().add(groupSetA);
groupE.getGroupSets().add(groupSetB);
groupF.getGroupSets().add(groupSetA);
List<DataElementGroup> groups = Lists.newArrayList(groupA, groupB, groupC, groupD, groupE, groupF);
ListMap<DataElementGroupSet, DataElementGroup> map = ListMap.getListMap(groups, group -> group.getGroupSets().iterator().next());
assertEquals(Lists.newArrayList(groupA, groupD, groupF), map.get(groupSetA));
assertEquals(Lists.newArrayList(groupB, groupE), map.get(groupSetB));
assertEquals(Lists.newArrayList(groupC), map.get(groupSetC));
assertNull(map.get(groupSetZ));
}
use of org.hisp.dhis.dataelement.DataElementGroupSet in project dhis2-core by dhis2.
the class SetMapTest method testGetListMapValueMapper.
@Test
public void testGetListMapValueMapper() {
DataElementGroupSet groupSetA = new DataElementGroupSet("GroupSetA");
DataElementGroupSet groupSetB = new DataElementGroupSet("GroupSetB");
DataElementGroupSet groupSetC = new DataElementGroupSet("GroupSetC");
DataElementGroupSet groupSetZ = new DataElementGroupSet("GroupSetZ");
DataElementGroup groupA = new DataElementGroup("GroupA");
DataElementGroup groupB = new DataElementGroup("GroupB");
DataElementGroup groupC = new DataElementGroup("GroupC");
DataElementGroup groupD = new DataElementGroup("GroupD");
DataElementGroup groupE = new DataElementGroup("GroupE");
DataElementGroup groupF = new DataElementGroup("GroupF");
groupA.getGroupSets().add(groupSetA);
groupB.getGroupSets().add(groupSetB);
groupC.getGroupSets().add(groupSetC);
groupD.getGroupSets().add(groupSetA);
groupE.getGroupSets().add(groupSetB);
groupF.getGroupSets().add(groupSetA);
Set<DataElementGroup> groups = Sets.newHashSet(groupA, groupB, groupC, groupD, groupE, groupF);
SetMap<DataElementGroupSet, DataElementGroup> map = SetMap.getSetMap(groups, group -> group.getGroupSets().iterator().next());
assertEquals(Sets.newHashSet(groupA, groupD, groupF), map.get(groupSetA));
assertEquals(Sets.newHashSet(groupB, groupE), map.get(groupSetB));
assertEquals(Sets.newHashSet(groupC), map.get(groupSetC));
assertNull(map.get(groupSetZ));
}
use of org.hisp.dhis.dataelement.DataElementGroupSet in project dhis2-core by dhis2.
the class DefaultDataIntegrityService method getDataElementsViolatingExclusiveGroupSets.
@Override
public SortedMap<DataElement, Collection<DataElementGroup>> getDataElementsViolatingExclusiveGroupSets() {
Collection<DataElementGroupSet> groupSets = dataElementService.getAllDataElementGroupSets();
SortedMap<DataElement, Collection<DataElementGroup>> targets = new TreeMap<>();
for (DataElementGroupSet groupSet : groupSets) {
Collection<DataElement> duplicates = getDuplicates(new ArrayList<>(groupSet.getDataElements()));
for (DataElement duplicate : duplicates) {
targets.put(duplicate, duplicate.getGroups());
}
}
return targets;
}
use of org.hisp.dhis.dataelement.DataElementGroupSet in project dhis2-core by dhis2.
the class DefaultDimensionService method getDimensionType.
@Override
public DimensionType getDimensionType(String uid) {
DataElementCategory cat = idObjectManager.get(DataElementCategory.class, uid);
if (cat != null) {
return DimensionType.CATEGORY;
}
DataElementGroupSet degs = idObjectManager.get(DataElementGroupSet.class, uid);
if (degs != null) {
return DimensionType.DATA_ELEMENT_GROUP_SET;
}
OrganisationUnitGroupSet ougs = idObjectManager.get(OrganisationUnitGroupSet.class, uid);
if (ougs != null) {
return DimensionType.ORGANISATION_UNIT_GROUP_SET;
}
CategoryOptionGroupSet cogs = idObjectManager.get(CategoryOptionGroupSet.class, uid);
if (cogs != null) {
return DimensionType.CATEGORY_OPTION_GROUP_SET;
}
TrackedEntityAttribute tea = idObjectManager.get(TrackedEntityAttribute.class, uid);
if (tea != null) {
return DimensionType.PROGRAM_ATTRIBUTE;
}
DataElement pde = idObjectManager.get(DataElement.class, uid);
if (pde != null && DataElementDomain.TRACKER.equals(pde.getDomainType())) {
return DimensionType.PROGRAM_DATA_ELEMENT;
}
ProgramIndicator pin = idObjectManager.get(ProgramIndicator.class, uid);
if (pin != null) {
return DimensionType.PROGRAM_INDICATOR;
}
final Map<String, DimensionType> dimObjectTypeMap = new HashMap<>();
dimObjectTypeMap.put(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X);
dimObjectTypeMap.put(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD);
dimObjectTypeMap.put(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT);
return dimObjectTypeMap.get(uid);
}
Aggregations