Search in sources :

Example 41 with DimensionalObject

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));
}
Also used : DimensionalObject(org.hisp.dhis.common.DimensionalObject) Test(org.junit.Test) DhisConvenienceTest(org.hisp.dhis.DhisConvenienceTest)

Example 42 with DimensionalObject

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());
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) DataElementCategoryCombo(org.hisp.dhis.dataelement.DataElementCategoryCombo) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo) DimensionalObject(org.hisp.dhis.common.DimensionalObject) Test(org.junit.Test) DhisConvenienceTest(org.hisp.dhis.DhisConvenienceTest)

Example 43 with DimensionalObject

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;
}
Also used : User(org.hisp.dhis.user.User) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) MergeParams(org.hisp.dhis.schema.MergeParams) BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject) DimensionalObject(org.hisp.dhis.common.DimensionalObject) BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject)

Example 44 with DimensionalObject

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);
}
Also used : DataElementGroupSet(org.hisp.dhis.dataelement.DataElementGroupSet) User(org.hisp.dhis.user.User) DataElementCategory(org.hisp.dhis.dataelement.DataElementCategory) CategoryOptionGroupSet(org.hisp.dhis.dataelement.CategoryOptionGroupSet) UniqueArrayList(org.hisp.dhis.commons.collection.UniqueArrayList) ArrayList(java.util.ArrayList) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet) DimensionalObject(org.hisp.dhis.common.DimensionalObject) BaseDimensionalObject(org.hisp.dhis.common.BaseDimensionalObject)

Aggregations

DimensionalObject (org.hisp.dhis.common.DimensionalObject)44 ArrayList (java.util.ArrayList)14 BaseDimensionalObject (org.hisp.dhis.common.BaseDimensionalObject)14 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)13 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)11 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)10 Test (org.junit.Test)8 List (java.util.List)6 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)5 Grid (org.hisp.dhis.common.Grid)5 DataElement (org.hisp.dhis.dataelement.DataElement)5 Period (org.hisp.dhis.period.Period)5 DateUtils.getMediumDateString (org.hisp.dhis.system.util.DateUtils.getMediumDateString)5 Calendar (org.hisp.dhis.calendar.Calendar)4 User (org.hisp.dhis.user.User)4 CategoryOptionGroupSet (org.hisp.dhis.dataelement.CategoryOptionGroupSet)3 DataSet (org.hisp.dhis.dataset.DataSet)3 Indicator (org.hisp.dhis.indicator.Indicator)3 OrganisationUnitGroup (org.hisp.dhis.organisationunit.OrganisationUnitGroup)3 ListGrid (org.hisp.dhis.system.grid.ListGrid)3