Search in sources :

Example 11 with CategoryOptionGroupSet

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

the class ValidationResultStoreHqlTest method queryWithUserWithCategoryOptionGroupSet.

@Test
void queryWithUserWithCategoryOptionGroupSet() {
    CategoryOptionGroupSet groupSet = new CategoryOptionGroupSet();
    groupSet.setId(42L);
    setUpUser("orgUid", null, groupSet);
    store.query(new ValidationResultQuery());
    assertHQLMatches("from ValidationResult vr where (locate('orgUid',vr.organisationUnit.path) <> 0) and 1 = ...", 544);
}
Also used : ValidationResultQuery(org.hisp.dhis.validation.comparator.ValidationResultQuery) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) Test(org.junit.jupiter.api.Test)

Example 12 with CategoryOptionGroupSet

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

the class ValidationResultStoreTest method setUpTest.

@Override
public void setUpTest() throws Exception {
    // ---------------------------------------------------------------------
    // Add supporting data
    // ---------------------------------------------------------------------
    PeriodType periodType = PeriodType.getPeriodTypeByName("Monthly");
    periodA = createPeriod(new MonthlyPeriodType(), getDate(2017, 1, 1), getDate(2017, 1, 31));
    periodB = createPeriod(new MonthlyPeriodType(), getDate(2017, 2, 1), getDate(2017, 2, 28));
    periodService.addPeriod(periodA);
    periodService.addPeriod(periodB);
    sourceA = createOrganisationUnit('A');
    sourceB = createOrganisationUnit('B', sourceA);
    sourceC = createOrganisationUnit('C');
    organisationUnitService.addOrganisationUnit(sourceA);
    organisationUnitService.addOrganisationUnit(sourceB);
    organisationUnitService.addOrganisationUnit(sourceC);
    superUserService = getMockCurrentUserService("SuperUser", true, sourceA, UserAuthorityGroup.AUTHORITY_ALL);
    userAService = getMockCurrentUserService("UserA", false, sourceA);
    userBService = getMockCurrentUserService("UserB", false, sourceB);
    userCService = getMockCurrentUserService("UserC", false, sourceB);
    userDService = getMockCurrentUserService("UserD", false, sourceB);
    userZ = createUser('Z');
    userService.addUser(userZ);
    UserGroup userGroupC = createUserGroup('A', Sets.newHashSet(userCService.getCurrentUser()));
    UserGroup userGroupD = createUserGroup('B', Sets.newHashSet(userDService.getCurrentUser()));
    userGroupService.addUserGroup(userGroupC);
    userGroupService.addUserGroup(userGroupD);
    userCService.getCurrentUser().getGroups().add(userGroupC);
    userService.updateUser(userCService.getCurrentUser());
    userDService.getCurrentUser().getGroups().add(userGroupD);
    userService.updateUser(userDService.getCurrentUser());
    optionA = new CategoryOption("CategoryOptionA");
    optionB = new CategoryOption("CategoryOptionB");
    categoryService.addCategoryOption(optionA);
    categoryService.addCategoryOption(optionB);
    categoryA = createCategory('A', optionA, optionB);
    categoryService.addCategory(categoryA);
    categoryComboA = createCategoryCombo('A', categoryA);
    categoryService.addCategoryCombo(categoryComboA);
    optionComboA = createCategoryOptionCombo(categoryComboA, optionA);
    optionComboB = createCategoryOptionCombo(categoryComboA, optionB);
    optionComboC = createCategoryOptionCombo(categoryComboA, optionA, optionB);
    categoryService.addCategoryOptionCombo(optionComboA);
    categoryService.addCategoryOptionCombo(optionComboB);
    categoryService.addCategoryOptionCombo(optionComboC);
    optionGroupA = createCategoryOptionGroup('A', optionA);
    optionGroupB = createCategoryOptionGroup('B', optionB);
    categoryService.saveCategoryOptionGroup(optionGroupA);
    categoryService.saveCategoryOptionGroup(optionGroupB);
    optionGroupSetB = new CategoryOptionGroupSet("OptionGroupSetB");
    categoryService.saveCategoryOptionGroupSet(optionGroupSetB);
    optionGroupSetB.addCategoryOptionGroup(optionGroupA);
    optionGroupSetB.addCategoryOptionGroup(optionGroupB);
    optionGroupA.getGroupSets().add(optionGroupSetB);
    optionGroupB.getGroupSets().add(optionGroupSetB);
    setPrivateAccess(optionA, userGroupC);
    setPrivateAccess(optionB);
    setPrivateAccess(optionGroupA);
    setPrivateAccess(optionGroupB, userGroupD);
    categoryService.updateCategoryOptionGroupSet(optionGroupSetB);
    categoryService.updateCategoryOptionGroup(optionGroupA);
    categoryService.updateCategoryOptionGroup(optionGroupB);
    userCService.getCurrentUser().getCatDimensionConstraints().add(categoryA);
    userDService.getCurrentUser().getCogsDimensionConstraints().add(optionGroupSetB);
    expressionA = new Expression("expressionA", "descriptionA");
    expressionB = new Expression("expressionB", "descriptionB");
    validationRuleA = createValidationRule('A', equal_to, expressionA, expressionB, periodType);
    validationRuleB = createValidationRule('B', equal_to, expressionB, expressionA, periodType);
    validationRuleStore.save(validationRuleA);
    validationRuleStore.save(validationRuleB);
    validationResultAA = new ValidationResult(validationRuleA, periodA, sourceA, optionComboA, 1.0, 2.0, 3);
    validationResultAB = new ValidationResult(validationRuleA, periodA, sourceA, optionComboB, 1.0, 2.0, 3);
    validationResultAC = new ValidationResult(validationRuleA, periodA, sourceA, optionComboC, 1.0, 2.0, 3);
    validationResultBA = new ValidationResult(validationRuleB, periodB, sourceB, optionComboA, 1.0, 2.0, 3);
    validationResultBB = new ValidationResult(validationRuleB, periodB, sourceB, optionComboB, 1.0, 2.0, 3);
    validationResultBC = new ValidationResult(validationRuleB, periodB, sourceB, optionComboC, 1.0, 2.0, 3);
    validationResultCA = new ValidationResult(validationRuleB, periodB, sourceC, optionComboA, 1.0, 2.0, 3);
    validationResultAB.setNotificationSent(true);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) Expression(org.hisp.dhis.expression.Expression) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) CategoryOption(org.hisp.dhis.category.CategoryOption) UserGroup(org.hisp.dhis.user.UserGroup)

Example 13 with CategoryOptionGroupSet

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

the class HibernateValidationResultStore method getUserRestrictions.

/**
 * If we should, restrict which validation results the user is entitled to
 * see, based on the user's organisation units and on the user's dimension
 * constraints if the user has them.
 * <p>
 * If the current user is null (e.g. running a system process or a JUnit
 * test) or superuser, there is no restriction.
 *
 * @param sqlHelper to help with "where" and/or "and" in the where clause.
 * @return String to add restrictions to the HQL query.
 */
private String getUserRestrictions(SqlHelper sqlHelper) {
    final User user = currentUserService.getCurrentUser();
    if (user == null || currentUserService.currentUserIsSuper()) {
        return "";
    }
    StringBuilder restrictions = new StringBuilder();
    // ---------------------------------------------------------------------
    // Restrict by the user's organisation unit sub-trees, if any
    // ---------------------------------------------------------------------
    Set<OrganisationUnit> userOrgUnits = user.getDataViewOrganisationUnitsWithFallback();
    if (!userOrgUnits.isEmpty()) {
        for (OrganisationUnit ou : userOrgUnits) {
            restrictions.append((restrictions.length() == 0 ? " " + sqlHelper.whereAnd() + " (" : " or ") + "locate('" + ou.getUid() + "',vr.organisationUnit.path) <> 0");
        }
        restrictions.append(")");
    }
    // ---------------------------------------------------------------------
    // Restrict by the user's category dimension constraints, if any
    // ---------------------------------------------------------------------
    Set<Category> categories = user.getCatDimensionConstraints();
    if (!isEmpty(categories)) {
        String validCategoryOptionByCategory = isReadable("co", user) + " and exists (select 'x' from Category c where co in elements(c.categoryOptions)" + " and c.id in (" + StringUtils.join(IdentifiableObjectUtils.getIdentifiers(categories), ",") + ") )";
        restrictions.append(" " + sqlHelper.whereAnd() + " 1 = (select min(case when " + validCategoryOptionByCategory + " then 1 else 0 end)" + " from CategoryOption co" + " where co in elements(vr.attributeOptionCombo.categoryOptions) )");
    }
    // ---------------------------------------------------------------------
    // Restrict by the user's cat option group dimension constraints, if any
    // ---------------------------------------------------------------------
    Set<CategoryOptionGroupSet> cogsets = user.getCogsDimensionConstraints();
    if (!isEmpty(cogsets)) {
        String validCategoryOptionByCategoryOptionGroup = "exists (select 'x' from CategoryOptionGroup g" + " join g.groupSets s" + " where g.id in elements(co.groups)" + " and s.id in (" + StringUtils.join(IdentifiableObjectUtils.getIdentifiers(cogsets), ",") + ")" + " and " + isReadable("g", user) + " )";
        restrictions.append(" " + sqlHelper.whereAnd() + " 1 = (select min(case when " + validCategoryOptionByCategoryOptionGroup + " then 1 else 0 end)" + " from CategoryOption co" + " where co in elements(vr.attributeOptionCombo.categoryOptions) )");
    }
    log.debug("Restrictions = " + restrictions);
    return restrictions.toString();
}
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 14 with CategoryOptionGroupSet

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

the class DataApprovalAuditServiceTest method setUpTest.

@Override
public void setUpTest() throws Exception {
    // ---------------------------------------------------------------------
    // Add supporting data
    // ---------------------------------------------------------------------
    PeriodType periodType = PeriodType.getPeriodTypeByName("Monthly");
    periodA = createPeriod(new MonthlyPeriodType(), getDate(2017, 1, 1), getDate(2017, 1, 31));
    periodB = createPeriod(new MonthlyPeriodType(), getDate(2018, 1, 1), getDate(2018, 1, 31));
    periodService.addPeriod(periodA);
    periodService.addPeriod(periodB);
    sourceA = createOrganisationUnit('A');
    sourceB = createOrganisationUnit('B', sourceA);
    organisationUnitService.addOrganisationUnit(sourceA);
    organisationUnitService.addOrganisationUnit(sourceB);
    superUserService = getMockCurrentUserService("SuperUser", true, sourceA, UserAuthorityGroup.AUTHORITY_ALL);
    userAService = getMockCurrentUserService("UserA", false, sourceA);
    userBService = getMockCurrentUserService("UserB", false, sourceB);
    userCService = getMockCurrentUserService("UserC", false, sourceB);
    userDService = getMockCurrentUserService("UserD", false, sourceB);
    userZ = createUser('Z');
    userService.addUser(userZ);
    UserGroup userGroupC = getUserGroup("UserGroupA", Sets.newHashSet(userCService.getCurrentUser()));
    UserGroup userGroupD = getUserGroup("UserGroupB", Sets.newHashSet(userDService.getCurrentUser()));
    userCService.getCurrentUser().getGroups().add(userGroupC);
    userDService.getCurrentUser().getGroups().add(userGroupD);
    optionA = new CategoryOption("CategoryOptionA");
    optionB = new CategoryOption("CategoryOptionB");
    categoryService.addCategoryOption(optionA);
    categoryService.addCategoryOption(optionB);
    categoryA = createCategory('A', optionA, optionB);
    categoryService.addCategory(categoryA);
    categoryComboA = createCategoryCombo('A', categoryA);
    categoryService.addCategoryCombo(categoryComboA);
    optionComboA = createCategoryOptionCombo(categoryComboA, optionA);
    optionComboB = createCategoryOptionCombo(categoryComboA, optionB);
    optionComboC = createCategoryOptionCombo(categoryComboA, optionA, optionB);
    categoryService.addCategoryOptionCombo(optionComboA);
    categoryService.addCategoryOptionCombo(optionComboB);
    categoryService.addCategoryOptionCombo(optionComboC);
    optionGroupA = createCategoryOptionGroup('A', optionA);
    optionGroupB = createCategoryOptionGroup('B', optionB);
    categoryService.saveCategoryOptionGroup(optionGroupA);
    categoryService.saveCategoryOptionGroup(optionGroupB);
    optionGroupSetB = new CategoryOptionGroupSet("OptionGroupSetB");
    categoryService.saveCategoryOptionGroupSet(optionGroupSetB);
    optionGroupSetB.addCategoryOptionGroup(optionGroupA);
    optionGroupSetB.addCategoryOptionGroup(optionGroupB);
    optionGroupA.getGroupSets().add(optionGroupSetB);
    optionGroupB.getGroupSets().add(optionGroupSetB);
    setPrivateAccess(optionA, userGroupC);
    setPrivateAccess(optionB);
    setPrivateAccess(optionGroupA);
    setPrivateAccess(optionGroupB, userGroupD);
    categoryService.updateCategoryOptionGroupSet(optionGroupSetB);
    categoryService.updateCategoryOptionGroup(optionGroupA);
    categoryService.updateCategoryOptionGroup(optionGroupB);
    userCService.getCurrentUser().getCatDimensionConstraints().add(categoryA);
    userDService.getCurrentUser().getCogsDimensionConstraints().add(optionGroupSetB);
    dateA = getDate(2017, 1, 1);
    dateB = getDate(2018, 1, 1);
    level1 = new DataApprovalLevel("01", 1, null);
    level2 = new DataApprovalLevel("02", 2, null);
    level3 = new DataApprovalLevel("03", 2, optionGroupSetB);
    dataApprovalLevelService.addDataApprovalLevel(level1);
    dataApprovalLevelService.addDataApprovalLevel(level2);
    dataApprovalLevelService.addDataApprovalLevel(level3);
    workflowA = new DataApprovalWorkflow("workflowA", periodType, newHashSet(level1));
    workflowB = new DataApprovalWorkflow("workflowB", periodType, newHashSet(level1, level2, level3));
    dataApprovalService.addWorkflow(workflowA);
    dataApprovalService.addWorkflow(workflowB);
    DataApproval approvalAA1 = new DataApproval(level1, workflowA, periodA, sourceA, optionComboA, false, dateA, userZ);
    DataApproval approvalAB1 = new DataApproval(level1, workflowA, periodA, sourceA, optionComboB, false, dateA, userZ);
    DataApproval approvalAC1 = new DataApproval(level1, workflowA, periodA, sourceA, optionComboC, false, dateA, userZ);
    DataApproval approvalBA2 = new DataApproval(level2, workflowB, periodB, sourceB, optionComboA, false, dateB, userZ);
    DataApproval approvalBB2 = new DataApproval(level2, workflowB, periodB, sourceB, optionComboB, false, dateB, userZ);
    DataApproval approvalBC2 = new DataApproval(level2, workflowB, periodB, sourceB, optionComboC, false, dateB, userZ);
    DataApproval approvalBA3 = new DataApproval(level3, workflowB, periodB, sourceB, optionComboA, false, dateB, userZ);
    DataApproval approvalBB3 = new DataApproval(level3, workflowB, periodB, sourceB, optionComboB, false, dateB, userZ);
    DataApproval approvalBC3 = new DataApproval(level3, workflowB, periodB, sourceB, optionComboC, false, dateB, userZ);
    auditAA1 = new DataApprovalAudit(approvalAA1, APPROVE);
    auditAB1 = new DataApprovalAudit(approvalAB1, UNAPPROVE);
    auditAC1 = new DataApprovalAudit(approvalAC1, ACCEPT);
    auditBA2 = new DataApprovalAudit(approvalBA2, UNACCEPT);
    auditBB2 = new DataApprovalAudit(approvalBB2, APPROVE);
    auditBC2 = new DataApprovalAudit(approvalBC2, UNAPPROVE);
    auditBA3 = new DataApprovalAudit(approvalBA3, ACCEPT);
    auditBB3 = new DataApprovalAudit(approvalBB3, UNACCEPT);
    auditBC3 = new DataApprovalAudit(approvalBC3, APPROVE);
    dataApprovalAuditStore.save(auditAA1);
    dataApprovalAuditStore.save(auditAB1);
    dataApprovalAuditStore.save(auditAC1);
    dataApprovalAuditStore.save(auditBA2);
    dataApprovalAuditStore.save(auditBB2);
    dataApprovalAuditStore.save(auditBC2);
    dataApprovalAuditStore.save(auditBA3);
    dataApprovalAuditStore.save(auditBB3);
    dataApprovalAuditStore.save(auditBC3);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) CategoryOption(org.hisp.dhis.category.CategoryOption) UserGroup(org.hisp.dhis.user.UserGroup)

Example 15 with CategoryOptionGroupSet

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

the class DataApprovalServiceTest method setUpCategories.

// -------------------------------------------------------------------------
// Categories supportive methods
// -------------------------------------------------------------------------
private void setUpCategories() {
    optionA = new CategoryOption("CategoryOptionA");
    optionB = new CategoryOption("CategoryOptionB");
    optionC = new CategoryOption("CategoryOptionC");
    optionD = new CategoryOption("CategoryOptionD");
    optionE = new CategoryOption("CategoryOptionE");
    optionF = new CategoryOption("CategoryOptionF");
    optionG = new CategoryOption("CategoryOptionG");
    optionH = new CategoryOption("CategoryOptionH");
    categoryService.addCategoryOption(optionA);
    categoryService.addCategoryOption(optionB);
    categoryService.addCategoryOption(optionC);
    categoryService.addCategoryOption(optionD);
    categoryService.addCategoryOption(optionE);
    categoryService.addCategoryOption(optionF);
    categoryService.addCategoryOption(optionG);
    categoryService.addCategoryOption(optionH);
    optionA.setPublicAccess(CATEGORY_OPTION_DEFAULT);
    optionB.setPublicAccess(CATEGORY_OPTION_DEFAULT);
    optionC.setPublicAccess(CATEGORY_OPTION_DEFAULT);
    optionD.setPublicAccess(CATEGORY_OPTION_DEFAULT);
    optionE.setPublicAccess(CATEGORY_OPTION_DEFAULT);
    optionF.setPublicAccess(CATEGORY_OPTION_DEFAULT);
    optionG.setPublicAccess(CATEGORY_OPTION_DEFAULT);
    optionH.setPublicAccess(CATEGORY_OPTION_DEFAULT);
    categoryService.updateCategoryOption(optionA);
    categoryService.updateCategoryOption(optionB);
    categoryService.updateCategoryOption(optionC);
    categoryService.updateCategoryOption(optionD);
    categoryService.updateCategoryOption(optionE);
    categoryService.updateCategoryOption(optionF);
    categoryService.updateCategoryOption(optionG);
    categoryService.updateCategoryOption(optionH);
    categoryA = createCategory('A', optionA, optionB, optionC, optionD);
    categoryB = createCategory('B', optionE, optionF, optionG, optionH);
    categoryService.addCategory(categoryA);
    categoryService.addCategory(categoryB);
    categoryComboA = createCategoryCombo('A', categoryA, categoryB);
    categoryService.addCategoryCombo(categoryComboA);
    optionComboAE = createCategoryOptionCombo(categoryComboA, optionA, optionE);
    optionComboAF = createCategoryOptionCombo(categoryComboA, optionA, optionF);
    optionComboAG = createCategoryOptionCombo(categoryComboA, optionA, optionG);
    optionComboAH = createCategoryOptionCombo(categoryComboA, optionA, optionH);
    optionComboBE = createCategoryOptionCombo(categoryComboA, optionB, optionE);
    optionComboBF = createCategoryOptionCombo(categoryComboA, optionB, optionF);
    optionComboBG = createCategoryOptionCombo(categoryComboA, optionB, optionG);
    optionComboBH = createCategoryOptionCombo(categoryComboA, optionB, optionH);
    optionComboCE = createCategoryOptionCombo(categoryComboA, optionC, optionE);
    optionComboCF = createCategoryOptionCombo(categoryComboA, optionC, optionF);
    optionComboCG = createCategoryOptionCombo(categoryComboA, optionC, optionG);
    optionComboCH = createCategoryOptionCombo(categoryComboA, optionC, optionH);
    optionComboDE = createCategoryOptionCombo(categoryComboA, optionD, optionE);
    optionComboDF = createCategoryOptionCombo(categoryComboA, optionD, optionF);
    optionComboDG = createCategoryOptionCombo(categoryComboA, optionD, optionG);
    optionComboDH = createCategoryOptionCombo(categoryComboA, optionD, optionH);
    optionComboAE.setUid("optionComAE");
    optionComboAF.setUid("optionComAF");
    optionComboAG.setUid("optionComAG");
    optionComboAH.setUid("optionComAH");
    optionComboBE.setUid("optionComBE");
    optionComboBF.setUid("optionComBF");
    optionComboBG.setUid("optionComBG");
    optionComboBH.setUid("optionComBH");
    optionComboCE.setUid("optionComCE");
    optionComboCF.setUid("optionComCF");
    optionComboCG.setUid("optionComCG");
    optionComboCH.setUid("optionComCH");
    optionComboDE.setUid("optionComDE");
    optionComboDF.setUid("optionComDF");
    optionComboDG.setUid("optionComDG");
    optionComboDH.setUid("optionComDH");
    categoryService.addCategoryOptionCombo(optionComboAE);
    categoryService.addCategoryOptionCombo(optionComboAF);
    categoryService.addCategoryOptionCombo(optionComboAG);
    categoryService.addCategoryOptionCombo(optionComboAH);
    categoryService.addCategoryOptionCombo(optionComboBE);
    categoryService.addCategoryOptionCombo(optionComboBF);
    categoryService.addCategoryOptionCombo(optionComboBG);
    categoryService.addCategoryOptionCombo(optionComboBH);
    categoryService.addCategoryOptionCombo(optionComboCE);
    categoryService.addCategoryOptionCombo(optionComboCF);
    categoryService.addCategoryOptionCombo(optionComboCG);
    categoryService.addCategoryOptionCombo(optionComboCH);
    categoryService.addCategoryOptionCombo(optionComboDE);
    categoryService.addCategoryOptionCombo(optionComboDF);
    categoryService.addCategoryOptionCombo(optionComboDG);
    categoryService.addCategoryOptionCombo(optionComboDH);
    categoryComboA.getOptionCombos().add(optionComboAE);
    categoryComboA.getOptionCombos().add(optionComboAF);
    categoryComboA.getOptionCombos().add(optionComboAG);
    categoryComboA.getOptionCombos().add(optionComboAH);
    categoryComboA.getOptionCombos().add(optionComboBE);
    categoryComboA.getOptionCombos().add(optionComboBF);
    categoryComboA.getOptionCombos().add(optionComboBG);
    categoryComboA.getOptionCombos().add(optionComboBH);
    categoryComboA.getOptionCombos().add(optionComboCF);
    categoryComboA.getOptionCombos().add(optionComboCG);
    categoryComboA.getOptionCombos().add(optionComboCH);
    categoryComboA.getOptionCombos().add(optionComboDE);
    categoryComboA.getOptionCombos().add(optionComboDF);
    categoryComboA.getOptionCombos().add(optionComboDG);
    categoryComboA.getOptionCombos().add(optionComboDH);
    categoryService.updateCategoryCombo(categoryComboA);
    groupAB = createCategoryOptionGroup('A', optionA, optionB);
    groupCD = createCategoryOptionGroup('C', optionC, optionD);
    groupEF = createCategoryOptionGroup('E', optionE, optionF);
    groupGH = createCategoryOptionGroup('G', optionG, optionH);
    categoryService.saveCategoryOptionGroup(groupAB);
    categoryService.saveCategoryOptionGroup(groupCD);
    categoryService.saveCategoryOptionGroup(groupEF);
    categoryService.saveCategoryOptionGroup(groupGH);
    groupSetABCD = new CategoryOptionGroupSet("GroupSetABCD");
    groupSetEFGH = new CategoryOptionGroupSet("GroupSetEFGH");
    categoryService.saveCategoryOptionGroupSet(groupSetABCD);
    categoryService.saveCategoryOptionGroupSet(groupSetEFGH);
    groupSetABCD.addCategoryOptionGroup(groupAB);
    groupSetABCD.addCategoryOptionGroup(groupCD);
    groupSetEFGH.addCategoryOptionGroup(groupAB);
    groupSetEFGH.addCategoryOptionGroup(groupEF);
    groupAB.getGroupSets().add(groupSetABCD);
    groupCD.getGroupSets().add(groupSetABCD);
    groupEF.getGroupSets().add(groupSetEFGH);
    groupGH.getGroupSets().add(groupSetEFGH);
    level2ABCD = new DataApprovalLevel("level2ABCD", 2, groupSetABCD);
    level2EFGH = new DataApprovalLevel("level2EFGH", 2, groupSetEFGH);
    dataApprovalLevelService.addDataApprovalLevel(level2EFGH);
    dataApprovalLevelService.addDataApprovalLevel(level2ABCD);
    workflow12A_H = new DataApprovalWorkflow("workflow12A_H", periodType, newHashSet(level1, level2, level2ABCD, level2EFGH));
    workflow12A_H.setUid("workflo12AH");
    dataApprovalService.addWorkflow(workflow12A_H);
    dataSetH = createDataSet('H', periodType, categoryComboA);
    dataSetH.assignWorkflow(workflow12A_H);
    dataSetH.addOrganisationUnit(organisationUnitA);
    dataSetH.addOrganisationUnit(organisationUnitB);
    dataSetService.addDataSet(dataSetH);
    workflow12A_H.getDataSets().add(dataSetH);
    dataApprovalService.updateWorkflow(workflow12A_H);
}
Also used : CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) CategoryOption(org.hisp.dhis.category.CategoryOption)

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