Search in sources :

Example 16 with CategoryOptionGroupSet

use of org.hisp.dhis.category.CategoryOptionGroupSet in project dhis2-core by dhis2.

the class DefaultCascadeSharingService method handleCategoryOptionGroupSetDimensions.

/**
 * Check if can merge sharing from given source to given analyticalObject's
 * {@link CategoryOptionGroupSetDimension} and all related objects that has
 * Sharing enabled.
 *
 * @param sourceSharing {@link Sharing}
 * @param analyticalObject any object extends {@link BaseAnalyticalObject}
 * @param listUpdateObjects Set of objects need to be updated
 * @param parameters {@link CascadeSharingParameters}
 */
private void handleCategoryOptionGroupSetDimensions(final Sharing sourceSharing, BaseAnalyticalObject analyticalObject, Set<IdentifiableObject> listUpdateObjects, CascadeSharingParameters parameters) {
    List<CategoryOptionGroupSetDimension> catOptionGroupSetDimensions = analyticalObject.getCategoryOptionGroupSetDimensions();
    if (CollectionUtils.isEmpty(catOptionGroupSetDimensions)) {
        return;
    }
    catOptionGroupSetDimensions.forEach(categoryOptionGroupSetDimension -> {
        CategoryOptionGroupSet catOptionGroupSet = categoryOptionGroupSetDimension.getDimension();
        handleIdentifiableObject(sourceSharing, CategoryOptionGroupSet.class, catOptionGroupSet, listUpdateObjects, parameters);
        List<CategoryOptionGroup> catOptionGroups = catOptionGroupSet.getMembers();
        if (CollectionUtils.isEmpty(catOptionGroups)) {
            return;
        }
        catOptionGroups.forEach(catOptionGroup -> {
            handleIdentifiableObject(sourceSharing, CategoryOptionGroup.class, catOptionGroup, listUpdateObjects, parameters);
            handleIdentifiableObjects(sourceSharing, CategoryOption.class, catOptionGroup.getMembers(), listUpdateObjects, parameters);
        });
    });
}
Also used : CategoryOptionGroup(org.hisp.dhis.category.CategoryOptionGroup) CategoryOptionGroupSetDimension(org.hisp.dhis.category.CategoryOptionGroupSetDimension) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet)

Example 17 with CategoryOptionGroupSet

use of org.hisp.dhis.category.CategoryOptionGroupSet in project dhis2-core by dhis2.

the class User method getDimensionConstraints.

/**
 * Returns the dimensions to use as constrains (filters) in data analytics
 * aggregation.
 */
public Set<DimensionalObject> getDimensionConstraints() {
    Set<DimensionalObject> constraints = new HashSet<>();
    for (CategoryOptionGroupSet cogs : cogsDimensionConstraints) {
        cogs.setDimensionType(DimensionType.CATEGORY_OPTION_GROUP_SET);
        constraints.add(cogs);
    }
    for (Category cat : catDimensionConstraints) {
        cat.setDimensionType(DimensionType.CATEGORY);
        constraints.add(cat);
    }
    return constraints;
}
Also used : Category(org.hisp.dhis.category.Category) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) DimensionalObject(org.hisp.dhis.common.DimensionalObject) HashSet(java.util.HashSet)

Example 18 with CategoryOptionGroupSet

use of org.hisp.dhis.category.CategoryOptionGroupSet in project dhis2-core by dhis2.

the class DefaultDimensionService method getDimensionType.

@Override
public DimensionType getDimensionType(String uid) {
    Category cat = idObjectManager.get(Category.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) Category(org.hisp.dhis.category.Category) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) HashMap(java.util.HashMap) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)

Example 19 with CategoryOptionGroupSet

use of org.hisp.dhis.category.CategoryOptionGroupSet in project dhis2-core by dhis2.

the class DefaultDimensionService method getAllDimensions.

@Override
public List<DimensionalObject> getAllDimensions() {
    Collection<Category> dcs = idObjectManager.getDataDimensions(Category.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) Category(org.hisp.dhis.category.Category) User(org.hisp.dhis.user.User) CategoryOptionGroupSet(org.hisp.dhis.category.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)

Example 20 with CategoryOptionGroupSet

use of org.hisp.dhis.category.CategoryOptionGroupSet in project dhis2-core by dhis2.

the class JdbcCompletenessTargetTableManager method getDimensionColumns.

private List<AnalyticsTableColumn> getDimensionColumns() {
    List<AnalyticsTableColumn> columns = new ArrayList<>();
    List<OrganisationUnitGroupSet> orgUnitGroupSets = idObjectManager.getDataDimensionsNoAcl(OrganisationUnitGroupSet.class);
    List<OrganisationUnitLevel> levels = organisationUnitService.getFilledOrganisationUnitLevels();
    List<CategoryOptionGroupSet> attributeCategoryOptionGroupSets = categoryService.getAttributeCategoryOptionGroupSetsNoAcl();
    List<Category> attributeCategories = categoryService.getAttributeDataDimensionCategoriesNoAcl();
    for (OrganisationUnitGroupSet groupSet : orgUnitGroupSets) {
        columns.add(new AnalyticsTableColumn(quote(groupSet.getUid()), CHARACTER_11, "ougs." + quote(groupSet.getUid())).withCreated(groupSet.getCreated()));
    }
    for (OrganisationUnitLevel level : levels) {
        String column = quote(PREFIX_ORGUNITLEVEL + level.getLevel());
        columns.add(new AnalyticsTableColumn(column, CHARACTER_11, "ous." + column).withCreated(level.getCreated()));
    }
    for (CategoryOptionGroupSet groupSet : attributeCategoryOptionGroupSets) {
        columns.add(new AnalyticsTableColumn(quote(groupSet.getUid()), CHARACTER_11, "acs." + quote(groupSet.getUid())).withCreated(groupSet.getCreated()));
    }
    for (Category category : attributeCategories) {
        columns.add(new AnalyticsTableColumn(quote(category.getUid()), CHARACTER_11, "acs." + quote(category.getUid())).withCreated(category.getCreated()));
    }
    columns.addAll(getFixedColumns());
    return filterDimensionColumns(columns);
}
Also used : Category(org.hisp.dhis.category.Category) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) ArrayList(java.util.ArrayList) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) AnalyticsTableColumn(org.hisp.dhis.analytics.AnalyticsTableColumn) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)

Aggregations

CategoryOptionGroupSet (org.hisp.dhis.category.CategoryOptionGroupSet)26 Category (org.hisp.dhis.category.Category)14 CategoryOption (org.hisp.dhis.category.CategoryOption)7 OrganisationUnitGroupSet (org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)7 ArrayList (java.util.ArrayList)6 User (org.hisp.dhis.user.User)5 AnalyticsTableColumn (org.hisp.dhis.analytics.AnalyticsTableColumn)4 CategoryOptionGroup (org.hisp.dhis.category.CategoryOptionGroup)4 OrganisationUnitLevel (org.hisp.dhis.organisationunit.OrganisationUnitLevel)4 PeriodType (org.hisp.dhis.period.PeriodType)4 Test (org.junit.jupiter.api.Test)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 DataElement (org.hisp.dhis.dataelement.DataElement)3 DataElementGroupSet (org.hisp.dhis.dataelement.DataElementGroupSet)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 HashSet (java.util.HashSet)2 DimensionalObject (org.hisp.dhis.common.DimensionalObject)2 Expression (org.hisp.dhis.expression.Expression)2 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)2