Search in sources :

Example 11 with DataElementGroupSet

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);
}
Also used : DataElementGroupSet(org.hisp.dhis.dataelement.DataElementGroupSet) DataElement(org.hisp.dhis.dataelement.DataElement) DimensionType(org.hisp.dhis.common.DimensionType) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) HashMap(java.util.HashMap) DataElementCategory(org.hisp.dhis.dataelement.DataElementCategory) CategoryOptionGroupSet(org.hisp.dhis.dataelement.CategoryOptionGroupSet) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)

Example 12 with DataElementGroupSet

use of org.hisp.dhis.dataelement.DataElementGroupSet 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

DataElementGroupSet (org.hisp.dhis.dataelement.DataElementGroupSet)12 DataElementGroup (org.hisp.dhis.dataelement.DataElementGroup)5 CategoryOptionGroupSet (org.hisp.dhis.dataelement.CategoryOptionGroupSet)4 OrganisationUnitGroupSet (org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)4 DataElement (org.hisp.dhis.dataelement.DataElement)3 DataElementCategory (org.hisp.dhis.dataelement.DataElementCategory)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 DimensionalObject (org.hisp.dhis.common.DimensionalObject)2 PeriodType (org.hisp.dhis.period.PeriodType)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 BiConsumer (java.util.function.BiConsumer)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 Chart (org.hisp.dhis.chart.Chart)1 AnalyticalObject (org.hisp.dhis.common.AnalyticalObject)1 BaseDimensionalObject (org.hisp.dhis.common.BaseDimensionalObject)1