Search in sources :

Example 56 with Category

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);
}
Also used : Category(org.hisp.dhis.category.Category) ValidationResultQuery(org.hisp.dhis.validation.comparator.ValidationResultQuery) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) Test(org.junit.jupiter.api.Test)

Example 57 with Category

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);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) User(org.hisp.dhis.user.User) Category(org.hisp.dhis.category.Category) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet)

Example 58 with Category

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;
}
Also used : Category(org.hisp.dhis.category.Category) CategoryOption(org.hisp.dhis.category.CategoryOption)

Example 59 with 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();
}
Also used : Category(org.hisp.dhis.category.Category)

Example 60 with Category

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();
}
Also used : Category(org.hisp.dhis.category.Category) CategoryCombo(org.hisp.dhis.category.CategoryCombo) CategoryOption(org.hisp.dhis.category.CategoryOption) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Category (org.hisp.dhis.category.Category)61 CategoryOption (org.hisp.dhis.category.CategoryOption)25 CategoryCombo (org.hisp.dhis.category.CategoryCombo)22 Test (org.junit.jupiter.api.Test)21 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)13 CategoryOptionGroupSet (org.hisp.dhis.category.CategoryOptionGroupSet)13 ArrayList (java.util.ArrayList)12 User (org.hisp.dhis.user.User)12 DataElement (org.hisp.dhis.dataelement.DataElement)11 HashSet (java.util.HashSet)8 DataSet (org.hisp.dhis.dataset.DataSet)8 OrganisationUnitGroupSet (org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)8 HashMap (java.util.HashMap)7 Date (java.util.Date)5 AnalyticsTableColumn (org.hisp.dhis.analytics.AnalyticsTableColumn)5 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)5 OrganisationUnitLevel (org.hisp.dhis.organisationunit.OrganisationUnitLevel)5 List (java.util.List)4 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)4 Attribute (org.hisp.dhis.attribute.Attribute)4