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;
}
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;
}
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;
}
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;
}
Aggregations