use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class ValidationResultStoreHqlTest method queryWithUserWithCategoryAndCategoryOptionGroupSet.
@Test
void queryWithUserWithCategoryAndCategoryOptionGroupSet() {
Category category = new Category();
category.setId(42L);
CategoryOptionGroupSet groupSet = new CategoryOptionGroupSet();
groupSet.setId(42L);
setUpUser("orgUid", category, groupSet);
store.query(new ValidationResultQuery());
assertHQLMatches("from ValidationResult vr where (locate('orgUid',vr.organisationUnit.path) <> 0) and 1 = ...", 988);
}
use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class ValidationResultStoreHqlTest method setUpUser.
private void setUpUser(String orgUnitUid, Category category, CategoryOptionGroupSet groupSet) {
User user = new User();
when(currentUserService.getCurrentUser()).thenReturn(user);
user.setGroups(emptySet());
OrganisationUnit unit = new OrganisationUnit();
unit.setUid(orgUnitUid);
user.setDataViewOrganisationUnits(singleton(unit));
// categories
Set<Category> categories = category == null ? emptySet() : singleton(category);
user.setCatDimensionConstraints(categories);
// option groups
Set<CategoryOptionGroupSet> options = groupSet == null ? emptySet() : singleton(groupSet);
user.setCogsDimensionConstraints(options);
}
use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class DhisConvenienceTest method createCategory.
/**
* @param categoryUniqueIdentifier A unique character to identify the
* category.
* @param categoryOptions the category options.
* @return Category
*/
public static Category createCategory(char categoryUniqueIdentifier, CategoryOption... categoryOptions) {
Category category = new Category("Category" + categoryUniqueIdentifier, DataDimensionType.DISAGGREGATION);
category.setAutoFields();
category.setShortName(category.getName());
for (CategoryOption categoryOption : categoryOptions) {
category.addCategoryOption(categoryOption);
}
return category;
}
use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class DataIntegrityCategoriesControllerTest method updateDefaultCategoryToUid.
private String updateDefaultCategoryToUid(String uid) {
transactionTemplate.execute(status -> {
Category category = categoryService.getDefaultCategory();
category.setUid(uid);
categoryStore.save(category);
return null;
});
// OBS! we need to read this to force the TX to be applied
return categoryService.getDefaultCategory().getUid();
}
use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class DimensionControllerTest method setUp.
@BeforeEach
void setUp() {
CategoryOption categoryOptionA = new CategoryOption("Male");
CategoryOption categoryOptionB = new CategoryOption("Female");
categoryService.addCategoryOption(categoryOptionA);
categoryService.addCategoryOption(categoryOptionB);
Category categoryA = new Category("Gender", DataDimensionType.DISAGGREGATION);
categoryA.setShortName(categoryA.getName());
categoryA.addCategoryOption(categoryOptionA);
categoryA.addCategoryOption(categoryOptionB);
categoryService.addCategory(categoryA);
CategoryCombo categoryComboA = new CategoryCombo("Gender", DataDimensionType.DISAGGREGATION);
categoryComboA.addCategory(categoryA);
categoryService.addCategoryCombo(categoryComboA);
ccId = categoryComboA.getUid();
}
Aggregations