use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class DataQueryParamsTest method addDimension.
@Test
public void addDimension() {
DimensionalObject doA = new BaseDimensionalObject(DimensionalObject.ORGUNIT_DIM_ID, DimensionType.ORGANISATION_UNIT, Lists.newArrayList());
DimensionalObject doB = new BaseDimensionalObject(DimensionalObject.CATEGORYOPTIONCOMBO_DIM_ID, DimensionType.CATEGORY_OPTION_COMBO, Lists.newArrayList());
DimensionalObject doC = new BaseDimensionalObject(DimensionalObject.PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList());
DimensionalObject doD = new BaseDimensionalObject(DimensionalObject.ATTRIBUTEOPTIONCOMBO_DIM_ID, DimensionType.ATTRIBUTE_OPTION_COMBO, Lists.newArrayList());
DimensionalObject doE = new BaseDimensionalObject("WpDi1seZU0Z", DimensionType.DATA_ELEMENT_GROUP_SET, Lists.newArrayList());
DimensionalObject doF = new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList());
DimensionalObject doG = new BaseDimensionalObject("Cz3WQznvrCM", DimensionType.ORGANISATION_UNIT_GROUP_SET, Lists.newArrayList());
DataQueryParams params = DataQueryParams.newBuilder().addDimension(doA).addDimension(doB).addDimension(doC).addDimension(doD).addDimension(doE).addDimension(doF).addDimension(doG).build();
List<DimensionalObject> dimensions = params.getDimensions();
assertEquals(7, dimensions.size());
assertEquals(doF, dimensions.get(0));
assertEquals(doB, dimensions.get(1));
assertEquals(doD, dimensions.get(2));
assertEquals(doA, dimensions.get(3));
assertEquals(doC, dimensions.get(4));
assertEquals(doE, dimensions.get(5));
assertEquals(doG, dimensions.get(6));
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class AnalyticsUtilsTest method testGetCocNameMap.
@Test
public void testGetCocNameMap() {
DataElementCategoryCombo ccA = createCategoryCombo('A', new DataElementCategory[0]);
DataElementCategoryCombo ccB = createCategoryCombo('B', new DataElementCategory[0]);
DataElementCategoryOptionCombo cocA = createCategoryOptionCombo('A');
DataElementCategoryOptionCombo cocB = createCategoryOptionCombo('B');
ccA.getOptionCombos().add(cocA);
ccB.getOptionCombos().add(cocB);
DataElement deA = createDataElement('A');
DataElement deB = createDataElement('B');
deA.setDataElementCategoryCombo(ccA);
deB.setDataElementCategoryCombo(ccB);
DimensionalObject dx = new BaseDimensionalObject(DimensionalObject.DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(deA, deB));
DataQueryParams params = DataQueryParams.newBuilder().addDimension(dx).withDisplayProperty(DisplayProperty.NAME).build();
Map<String, String> map = AnalyticsUtils.getCocNameMap(params);
assertEquals(map.get(cocA.getUid()), cocA.getName());
assertEquals(map.get(cocB.getUid()), cocB.getName());
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class DefaultDimensionService method getDimensionalObjectCopy.
@Override
public DimensionalObject getDimensionalObjectCopy(String uid, boolean filterCanRead) {
DimensionalObject dimension = idObjectManager.get(DimensionalObject.DYNAMIC_DIMENSION_CLASSES, uid);
BaseDimensionalObject copy = new BaseDimensionalObject();
mergeService.merge(new MergeParams<>(dimension, copy).setMergeMode(MergeMode.MERGE));
if (filterCanRead) {
User user = currentUserService.getCurrentUser();
List<DimensionalItemObject> items = getCanReadObjects(user, dimension.getItems());
copy.setItems(items);
}
return copy;
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class DefaultDimensionService method getAllDimensions.
@Override
public List<DimensionalObject> getAllDimensions() {
Collection<DataElementCategory> dcs = idObjectManager.getDataDimensions(DataElementCategory.class);
Collection<CategoryOptionGroupSet> cogs = idObjectManager.getDataDimensions(CategoryOptionGroupSet.class);
Collection<DataElementGroupSet> degs = idObjectManager.getDataDimensions(DataElementGroupSet.class);
Collection<OrganisationUnitGroupSet> ougs = idObjectManager.getDataDimensions(OrganisationUnitGroupSet.class);
final List<DimensionalObject> dimensions = new ArrayList<>();
dimensions.addAll(dcs);
dimensions.addAll(cogs);
dimensions.addAll(degs);
dimensions.addAll(ougs);
User user = currentUserService.getCurrentUser();
return getCanReadObjects(user, dimensions);
}
Aggregations