Search in sources :

Example 6 with CategoryOptionGroup

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

the class CategoryOptionGroupResolver method getCategoryOptionCombosIntersection.

private List<String> getCategoryOptionCombosIntersection(List<String> cogUidList, String dataElementId) {
    List<String> cocUidIntersection = null;
    for (String cogUid : cogUidList) {
        CategoryOptionGroup cog = categoryOptionGroupStore.getByUid(cogUid);
        List<String> cocUids = categoryOptionComboStore.getCategoryOptionCombosByGroupUid(cog.getUid(), dataElementId).stream().map(BaseIdentifiableObject::getUid).collect(Collectors.toList());
        if (cocUidIntersection == null) {
            cocUidIntersection = cocUids;
        } else {
            cocUidIntersection.retainAll(cocUids);
        }
    }
    return cocUidIntersection;
}
Also used : CategoryOptionGroup(org.hisp.dhis.category.CategoryOptionGroup)

Example 7 with CategoryOptionGroup

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

the class DefaultCategoryService method getCogDimensionConstraints.

@Override
@Transactional(readOnly = true)
public Set<CategoryOptionGroup> getCogDimensionConstraints(User user) {
    Set<CategoryOptionGroup> groups = null;
    Set<CategoryOptionGroupSet> cogsConstraints = user.getCogsDimensionConstraints();
    if (cogsConstraints != null && !cogsConstraints.isEmpty()) {
        groups = new HashSet<>();
        for (CategoryOptionGroupSet cogs : cogsConstraints) {
            groups.addAll(getCategoryOptionGroups(cogs));
        }
    }
    return groups;
}
Also used : CategoryOptionGroup(org.hisp.dhis.category.CategoryOptionGroup) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with CategoryOptionGroup

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

the class DhisConvenienceTest method createCategoryOptionGroupSet.

/**
 * @param categoryGroupSetUniqueIdentifier A unique character to identify
 *        the category option group set.
 * @param categoryOptionGroups the category option groups.
 * @return CategoryOptionGroupSet
 */
public static CategoryOptionGroupSet createCategoryOptionGroupSet(char categoryGroupSetUniqueIdentifier, CategoryOptionGroup... categoryOptionGroups) {
    CategoryOptionGroupSet categoryOptionGroupSet = new CategoryOptionGroupSet("CategoryOptionGroupSet" + categoryGroupSetUniqueIdentifier);
    categoryOptionGroupSet.setAutoFields();
    for (CategoryOptionGroup categoryOptionGroup : categoryOptionGroups) {
        categoryOptionGroupSet.addCategoryOptionGroup(categoryOptionGroup);
    }
    return categoryOptionGroupSet;
}
Also used : CategoryOptionGroup(org.hisp.dhis.category.CategoryOptionGroup) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet)

Example 9 with CategoryOptionGroup

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

the class DhisConvenienceTest method createCategoryOptionGroup.

/**
 * @param uniqueIdentifier A unique character to identify the category
 *        option group.
 * @param categoryOptions the category options.
 * @return CategoryOptionGroup
 */
public static CategoryOptionGroup createCategoryOptionGroup(char uniqueIdentifier, CategoryOption... categoryOptions) {
    CategoryOptionGroup categoryOptionGroup = new CategoryOptionGroup("CategoryOptionGroup" + uniqueIdentifier);
    categoryOptionGroup.setShortName("ShortName" + uniqueIdentifier);
    categoryOptionGroup.setAutoFields();
    categoryOptionGroup.setMembers(new HashSet<>());
    for (CategoryOption categoryOption : categoryOptions) {
        categoryOptionGroup.addCategoryOption(categoryOption);
    }
    return categoryOptionGroup;
}
Also used : CategoryOptionGroup(org.hisp.dhis.category.CategoryOptionGroup) CategoryOption(org.hisp.dhis.category.CategoryOption)

Aggregations

CategoryOptionGroup (org.hisp.dhis.category.CategoryOptionGroup)9 CategoryOptionGroupSet (org.hisp.dhis.category.CategoryOptionGroupSet)4 ArrayList (java.util.ArrayList)3 CategoryOption (org.hisp.dhis.category.CategoryOption)2 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 DhisConvenienceTest.createCategoryOptionCombo (org.hisp.dhis.DhisConvenienceTest.createCategoryOptionCombo)1 DhisConvenienceTest.createCategoryOptionGroup (org.hisp.dhis.DhisConvenienceTest.createCategoryOptionGroup)1 AnalyticsAggregationType (org.hisp.dhis.analytics.AnalyticsAggregationType)1 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)1 Category (org.hisp.dhis.category.Category)1 CategoryCombo (org.hisp.dhis.category.CategoryCombo)1 CategoryOptionGroupSetDimension (org.hisp.dhis.category.CategoryOptionGroupSetDimension)1 AnalyticalObject (org.hisp.dhis.common.AnalyticalObject)1 ReportingRate (org.hisp.dhis.common.ReportingRate)1 DataElement (org.hisp.dhis.dataelement.DataElement)1 DataSet (org.hisp.dhis.dataset.DataSet)1 Expression (org.hisp.dhis.expression.Expression)1