Search in sources :

Example 6 with CategoryOptionGroupSet

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

the class DefaultDataApprovalLevelService method getLowestDataApprovalLevel.

@Override
@Transactional(readOnly = true)
public DataApprovalLevel getLowestDataApprovalLevel(OrganisationUnit orgUnit, CategoryOptionCombo attributeOptionCombo) {
    Set<CategoryOptionGroupSet> cogSets = null;
    if (attributeOptionCombo != null && attributeOptionCombo != categoryService.getDefaultCategoryOptionCombo()) {
        cogSets = new HashSet<>();
        for (CategoryOption option : attributeOptionCombo.getCategoryOptions()) {
            if (option.getGroupSets() != null) {
                cogSets.addAll(option.getGroupSets());
            }
        }
    }
    int orgUnitLevel = orgUnit.getLevel();
    List<DataApprovalLevel> approvalLevels = getDataApprovalLevelsByOrgUnitLevel(orgUnitLevel);
    for (DataApprovalLevel level : Lists.reverse(approvalLevels)) {
        if (level.getCategoryOptionGroupSet() == null) {
            if (cogSets == null) {
                return level;
            }
        } else if (cogSets != null && cogSets.contains(level.getCategoryOptionGroupSet())) {
            return level;
        }
    }
    return null;
}
Also used : CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) CategoryOption(org.hisp.dhis.category.CategoryOption) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with CategoryOptionGroupSet

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

the class DefaultDataApprovalLevelService method subsetUserDataApprovalLevels.

/**
 * Returns the subset of approval levels that the user is allowed to access.
 *
 * @param approvalLevels the approval levels to test.
 * @param user the user to test access for.
 * @param lowestLevel return lowest level if nothing else.
 * @return the subset of approval levels to which the user has access.
 */
private List<DataApprovalLevel> subsetUserDataApprovalLevels(List<DataApprovalLevel> approvalLevels, User user, boolean lowestLevel) {
    int lowestNumberOrgUnitLevel = getCurrentUsersLowestNumberOrgUnitLevel();
    boolean canSeeAllDimensions = CollectionUtils.isEmpty(categoryService.getCoDimensionConstraints(user)) && CollectionUtils.isEmpty(categoryService.getCogDimensionConstraints(user));
    List<DataApprovalLevel> userDataApprovalLevels = new ArrayList<>();
    boolean addLevel = false;
    for (DataApprovalLevel approvalLevel : approvalLevels) {
        if (!addLevel && approvalLevel.getOrgUnitLevel() >= lowestNumberOrgUnitLevel) {
            CategoryOptionGroupSet cogs = approvalLevel.getCategoryOptionGroupSet();
            addLevel = aclService.canRead(user, approvalLevel) && cogs == null ? canSeeAllDimensions : (aclService.canRead(user, cogs) && !CollectionUtils.isEmpty(categoryService.getCategoryOptionGroups(cogs)));
        }
        if (addLevel) {
            userDataApprovalLevels.add(approvalLevel);
        }
    }
    if (userDataApprovalLevels.size() == 0 && approvalLevels.size() != 0 && lowestLevel) {
        userDataApprovalLevels.add(approvalLevels.get(approvalLevels.size() - 1));
    }
    return userDataApprovalLevels;
}
Also used : ArrayList(java.util.ArrayList) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet)

Example 8 with CategoryOptionGroupSet

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

the class DataApprovalServiceCategoryOptionGroupTest method setUpTest.

// -------------------------------------------------------------------------
// Set up/tear down
// -------------------------------------------------------------------------
@Override
public void setUpTest() throws Exception {
    userService = _userService;
    // ---------------------------------------------------------------------
    // Add supporting data
    // ---------------------------------------------------------------------
    global = createOrganisationUnit("Global");
    americas = createOrganisationUnit("Americas", global);
    asia = createOrganisationUnit("Asia", global);
    brazil = createOrganisationUnit("Brazil", americas);
    china = createOrganisationUnit("China", asia);
    india = createOrganisationUnit("India", asia);
    organisationUnitService.addOrganisationUnit(global);
    organisationUnitService.addOrganisationUnit(americas);
    organisationUnitService.addOrganisationUnit(asia);
    organisationUnitService.addOrganisationUnit(brazil);
    organisationUnitService.addOrganisationUnit(china);
    organisationUnitService.addOrganisationUnit(india);
    userA = createUser('A');
    userService.addUser(userA);
    dateA = new Date();
    superUser = mockUser("SuperUser", global, AUTHORITY_ALL);
    superUser.setSuperUserFlag(true);
    globalConsultant = mockUser("GlobalConsultant", global, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS, AUTH_APPROVE_LOWER_LEVELS);
    globalUser = mockUser("GlobalUser", global, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS);
    globalApproveOnly = mockUser("GlobalApproveOnly", global, AUTH_APPROVE);
    globalAcceptOnly = mockUser("GlobalAcceptOnly", global, AUTH_ACCEPT_LOWER_LEVELS);
    globalReadAll = mockUser("GlobalReadEverything", global, AUTH_VIEW_UNAPPROVED_DATA);
    globalAgencyAUser = mockUser("GlobalAgencyAUser", global, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS);
    globalAgencyBUser = mockUser("GlobalAgencyBUser", global, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS);
    brazilInteragencyUser = mockUser("BrazilInteragencyUser", brazil, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS);
    chinaInteragencyUser = mockUser("ChinaInteragencyUser", china, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS);
    chinaInteragencyApproveOnly = mockUser("ChinaInteragencyApproveOnly", china, AUTH_APPROVE);
    chinalInteragencyAcceptOnly = mockUser("ChinalInteragencyAcceptOnly", china, AUTH_ACCEPT_LOWER_LEVELS);
    indiaInteragencyUser = mockUser("IndiaInteragencyUser", india, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS);
    brazilAgencyAUser = mockUser("BrazilAgencyAUser", brazil, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS);
    chinaAgencyAUser = mockUser("ChinaAgencyAUser", china, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS);
    chinaAgencyAApproveOnly = mockUser("ChinaAgencyAApproveOnly", china, AUTH_APPROVE);
    chinaAgencyAAcceptOnly = mockUser("ChinaAgencyAAcceptOnly", china, AUTH_ACCEPT_LOWER_LEVELS);
    chinaAgencyBUser = mockUser("ChinaAgencyBUser", china, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS);
    indiaAgencyAUser = mockUser("IndiaAgencyAUser", india, AUTH_APPROVE, AUTH_ACCEPT_LOWER_LEVELS);
    brazilPartner1User = mockUser("BrazilPartner1User", brazil, AUTH_APPROVE);
    chinaPartner1User = mockUser("ChinaPartner1User", china, AUTH_APPROVE);
    chinaPartner2User = mockUser("ChinaPartner2User", china, AUTH_APPROVE);
    indiaPartner1User = mockUser("IndiaPartner1User", india, AUTH_APPROVE);
    currentMockUserService = null;
    UserGroup globalUsers = getUserGroup("GlobalUsers", userSet(globalUser, globalApproveOnly, globalAcceptOnly, globalConsultant, globalReadAll));
    UserGroup globalAgencyAUsers = getUserGroup("GlobalAgencyAUsers", userSet(globalAgencyAUser));
    UserGroup globalAgencyBUsers = getUserGroup("GlobalAgencyBUsers", userSet(globalAgencyBUser));
    UserGroup brazilInteragencyUsers = getUserGroup("BrazilInteragencyUsers", userSet(brazilInteragencyUser));
    UserGroup chinaInteragencyUsers = getUserGroup("ChinaInteragencyUsers", userSet(chinaInteragencyUser, chinaInteragencyApproveOnly, chinalInteragencyAcceptOnly));
    UserGroup indiaInteragencyUsers = getUserGroup("IndiaInteragencyUsers", userSet(indiaInteragencyUser));
    UserGroup brazilAgencyAUsers = getUserGroup("BrazilAgencyAUsers", userSet(brazilAgencyAUser));
    UserGroup chinaAgencyAUsers = getUserGroup("ChinaAgencyAUsers", userSet(chinaAgencyAUser, chinaAgencyAApproveOnly, chinaAgencyAAcceptOnly));
    UserGroup chinaAgencyBUsers = getUserGroup("ChinaAgencyBUsers", userSet(chinaAgencyBUser));
    UserGroup indiaAgencyAUsers = getUserGroup("IndiaAgencyAUsers", userSet(indiaAgencyAUser));
    UserGroup brazilPartner1Users = getUserGroup("BrazilPartner1Users", userSet(brazilPartner1User));
    UserGroup chinaPartner1Users = getUserGroup("ChinaPartner1Users", userSet(chinaPartner1User));
    UserGroup chinaPartner2Users = getUserGroup("ChinaPartner2Users", userSet(chinaPartner2User));
    UserGroup indiaPartner1Users = getUserGroup("IndiaPartner1Users", userSet(indiaPartner1User));
    brazilA1 = new CategoryOption("BrazilA1");
    chinaA1_1 = new CategoryOption("ChinaA1_1");
    chinaA1_2 = new CategoryOption("ChinaA1_2");
    chinaA2 = new CategoryOption("ChinaA2");
    chinaB2 = new CategoryOption("ChinaB2");
    indiaA1 = new CategoryOption("IndiaA1");
    brazilA1.setOrganisationUnits(Sets.newHashSet(brazil));
    chinaA1_1.setOrganisationUnits(Sets.newHashSet(china));
    chinaA1_2.setOrganisationUnits(Sets.newHashSet(china));
    chinaA2.setOrganisationUnits(Sets.newHashSet(china));
    chinaB2.setOrganisationUnits(Sets.newHashSet(china));
    indiaA1.setOrganisationUnits(Sets.newHashSet(india));
    categoryService.addCategoryOption(brazilA1);
    categoryService.addCategoryOption(chinaA1_1);
    categoryService.addCategoryOption(chinaA1_2);
    categoryService.addCategoryOption(chinaA2);
    categoryService.addCategoryOption(chinaB2);
    categoryService.addCategoryOption(indiaA1);
    setAccess(brazilA1, globalUsers, globalAgencyAUsers, brazilInteragencyUsers, brazilAgencyAUsers, brazilPartner1Users);
    setAccess(chinaA1_1, globalUsers, globalAgencyAUsers, chinaInteragencyUsers, chinaAgencyAUsers, chinaPartner1Users);
    setAccess(chinaA1_2, globalUsers, globalAgencyAUsers, chinaInteragencyUsers, chinaAgencyAUsers, chinaPartner1Users);
    setAccess(chinaA2, globalUsers, globalAgencyAUsers, chinaInteragencyUsers, chinaAgencyAUsers, chinaPartner2Users);
    setAccess(chinaB2, globalUsers, globalAgencyBUsers, chinaInteragencyUsers, chinaAgencyBUsers, chinaPartner2Users);
    setAccess(indiaA1, globalUsers, globalAgencyAUsers, indiaInteragencyUsers, indiaAgencyAUsers, indiaPartner1Users);
    mechanismCategory = createCategory('A', brazilA1, chinaA1_1, chinaA1_2, chinaA2, chinaB2, indiaA1);
    categoryService.addCategory(mechanismCategory);
    mechanismCategoryCombo = createCategoryCombo('A', mechanismCategory);
    categoryService.addCategoryCombo(mechanismCategoryCombo);
    constrainByMechanism(globalAgencyAUser);
    constrainByMechanism(globalAgencyBUser);
    constrainByMechanism(brazilAgencyAUser);
    constrainByMechanism(chinaAgencyAUser);
    constrainByMechanism(chinaAgencyAApproveOnly);
    constrainByMechanism(chinaAgencyAAcceptOnly);
    constrainByMechanism(chinaAgencyBUser);
    constrainByMechanism(indiaAgencyAUser);
    constrainByMechanism(brazilPartner1User);
    constrainByMechanism(chinaPartner1User);
    constrainByMechanism(chinaPartner2User);
    constrainByMechanism(indiaPartner1User);
    userService.updateUser(globalAgencyAUser.getCurrentUser());
    userService.updateUser(globalAgencyBUser.getCurrentUser());
    userService.updateUser(brazilAgencyAUser.getCurrentUser());
    userService.updateUser(chinaAgencyAUser.getCurrentUser());
    userService.updateUser(chinaAgencyAApproveOnly.getCurrentUser());
    userService.updateUser(chinaAgencyAAcceptOnly.getCurrentUser());
    userService.updateUser(chinaAgencyBUser.getCurrentUser());
    userService.updateUser(indiaAgencyAUser.getCurrentUser());
    userService.updateUser(brazilPartner1User.getCurrentUser());
    userService.updateUser(chinaPartner1User.getCurrentUser());
    userService.updateUser(chinaPartner2User.getCurrentUser());
    userService.updateUser(indiaPartner1User.getCurrentUser());
    brazilA1Combo = createCategoryOptionCombo(mechanismCategoryCombo, brazilA1);
    chinaA1_1Combo = createCategoryOptionCombo(mechanismCategoryCombo, chinaA1_1);
    chinaA1_2Combo = createCategoryOptionCombo(mechanismCategoryCombo, chinaA1_2);
    chinaA2Combo = createCategoryOptionCombo(mechanismCategoryCombo, chinaA2);
    chinaB2Combo = createCategoryOptionCombo(mechanismCategoryCombo, chinaB2);
    indiaA1Combo = createCategoryOptionCombo(mechanismCategoryCombo, indiaA1);
    categoryService.addCategoryOptionCombo(brazilA1Combo);
    categoryService.addCategoryOptionCombo(chinaA1_1Combo);
    categoryService.addCategoryOptionCombo(chinaA1_2Combo);
    categoryService.addCategoryOptionCombo(chinaA2Combo);
    categoryService.addCategoryOptionCombo(chinaB2Combo);
    categoryService.addCategoryOptionCombo(indiaA1Combo);
    mechanismCategoryCombo.getOptionCombos().add(brazilA1Combo);
    mechanismCategoryCombo.getOptionCombos().add(chinaA1_1Combo);
    mechanismCategoryCombo.getOptionCombos().add(chinaA1_2Combo);
    mechanismCategoryCombo.getOptionCombos().add(chinaA2Combo);
    mechanismCategoryCombo.getOptionCombos().add(chinaB2Combo);
    mechanismCategoryCombo.getOptionCombos().add(indiaA1Combo);
    categoryService.updateCategoryCombo(mechanismCategoryCombo);
    agencyA = createCategoryOptionGroup('A', brazilA1, chinaA1_1, chinaA1_2, chinaA2, indiaA1);
    agencyB = createCategoryOptionGroup('B', chinaB2);
    partner1 = createCategoryOptionGroup('1', brazilA1, chinaA1_1, chinaA1_2, indiaA1);
    partner2 = createCategoryOptionGroup('2', chinaA2, chinaB2);
    categoryService.saveCategoryOptionGroup(agencyA);
    categoryService.saveCategoryOptionGroup(agencyB);
    categoryService.saveCategoryOptionGroup(partner1);
    categoryService.saveCategoryOptionGroup(partner2);
    setAccess(agencyA, globalUsers, globalAgencyAUsers, brazilInteragencyUsers, chinaInteragencyUsers, indiaInteragencyUsers, brazilAgencyAUsers, chinaAgencyAUsers, indiaAgencyAUsers);
    setAccess(agencyB, globalUsers, globalAgencyBUsers, chinaInteragencyUsers, chinaAgencyBUsers);
    setAccess(partner1, globalUsers, brazilInteragencyUsers, chinaInteragencyUsers, indiaInteragencyUsers, brazilAgencyAUsers, chinaAgencyAUsers, indiaAgencyAUsers, brazilPartner1Users, chinaPartner1Users, indiaPartner1Users);
    setAccess(partner2, globalUsers, chinaInteragencyUsers, chinaAgencyAUsers, chinaPartner2Users);
    agencies = new CategoryOptionGroupSet("Agencies");
    partners = new CategoryOptionGroupSet("Partners");
    categoryService.saveCategoryOptionGroupSet(partners);
    categoryService.saveCategoryOptionGroupSet(agencies);
    setAccess(agencies, globalUsers, globalAgencyAUsers, globalAgencyBUsers, brazilInteragencyUsers, chinaInteragencyUsers, indiaInteragencyUsers, brazilAgencyAUsers, chinaAgencyAUsers, chinaAgencyBUsers, chinaAgencyBUsers, indiaAgencyAUsers);
    setAccess(partners, globalUsers, brazilInteragencyUsers, chinaInteragencyUsers, indiaInteragencyUsers, brazilAgencyAUsers, chinaAgencyAUsers, chinaAgencyBUsers, chinaAgencyBUsers, indiaAgencyAUsers, brazilPartner1Users, chinaPartner1Users, chinaPartner2Users, indiaPartner1Users);
    agencies.addCategoryOptionGroup(agencyA);
    agencies.addCategoryOptionGroup(agencyB);
    partners.addCategoryOptionGroup(partner1);
    partners.addCategoryOptionGroup(partner2);
    agencyA.getGroupSets().add(agencies);
    agencyB.getGroupSets().add(agencies);
    partner1.getGroupSets().add(partners);
    partner2.getGroupSets().add(partners);
    categoryService.updateCategoryOptionGroupSet(partners);
    categoryService.updateCategoryOptionGroupSet(agencies);
    categoryService.updateCategoryOptionGroup(agencyA);
    categoryService.updateCategoryOptionGroup(agencyB);
    categoryService.updateCategoryOptionGroup(partner1);
    categoryService.updateCategoryOptionGroup(partner2);
    globalLevel1 = new DataApprovalLevel("GlobalLevel1", 1, null);
    globalAgencyLevel2 = new DataApprovalLevel("GlobalAgencyLevel2", 1, agencies);
    countryLevel3 = new DataApprovalLevel("CountryLevel3", 3, null);
    agencyLevel4 = new DataApprovalLevel("AgencyLevel4", 3, agencies);
    partnerLevel5 = new DataApprovalLevel("PartnerLevel5", 3, partners);
    dataApprovalLevelService.addDataApprovalLevel(globalLevel1, 1);
    dataApprovalLevelService.addDataApprovalLevel(globalAgencyLevel2, 2);
    dataApprovalLevelService.addDataApprovalLevel(countryLevel3, 3);
    dataApprovalLevelService.addDataApprovalLevel(agencyLevel4, 4);
    dataApprovalLevelService.addDataApprovalLevel(partnerLevel5, 5);
    periodType = periodService.reloadPeriodType(PeriodType.getPeriodTypeByName("Monthly"));
    periodA = createPeriod("201801");
    periodService.addPeriod(periodA);
    workflow1 = new DataApprovalWorkflow("workflow1", periodType, newHashSet(globalLevel1, countryLevel3, agencyLevel4, partnerLevel5));
    workflow2 = new DataApprovalWorkflow("workflow2", periodType, newHashSet(globalLevel1, globalAgencyLevel2, agencyLevel4, partnerLevel5));
    dataApprovalService.addWorkflow(workflow1);
    dataApprovalService.addWorkflow(workflow2);
    dataSetA = createDataSet('A', periodType, mechanismCategoryCombo);
    dataSetB = createDataSet('B', periodType, mechanismCategoryCombo);
    dataSetA.assignWorkflow(workflow1);
    dataSetB.assignWorkflow(workflow2);
    dataSetA.addOrganisationUnit(global);
    dataSetA.addOrganisationUnit(americas);
    dataSetA.addOrganisationUnit(asia);
    dataSetA.addOrganisationUnit(brazil);
    dataSetA.addOrganisationUnit(china);
    dataSetA.addOrganisationUnit(india);
    dataSetB.addOrganisationUnit(global);
    dataSetB.addOrganisationUnit(americas);
    dataSetB.addOrganisationUnit(asia);
    dataSetB.addOrganisationUnit(brazil);
    dataSetB.addOrganisationUnit(china);
    dataSetB.addOrganisationUnit(india);
    dataSetService.addDataSet(dataSetA);
    dataSetService.addDataSet(dataSetB);
    systemSettingManager.saveSystemSetting(SettingKey.IGNORE_ANALYTICS_APPROVAL_YEAR_THRESHOLD, 0);
    systemSettingManager.saveSystemSetting(SettingKey.ACCEPTANCE_REQUIRED_FOR_APPROVAL, true);
}
Also used : CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) CategoryOption(org.hisp.dhis.category.CategoryOption) Date(java.util.Date) UserGroup(org.hisp.dhis.user.UserGroup)

Example 9 with CategoryOptionGroupSet

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

the class DataApprovalLevelServiceTest method setUpTest.

// -------------------------------------------------------------------------
// Set up/tear down
// -------------------------------------------------------------------------
@Override
public void setUpTest() {
    // ---------------------------------------------------------------------
    // Add supporting data
    // ---------------------------------------------------------------------
    setA = new CategoryOptionGroupSet("Set A");
    setB = new CategoryOptionGroupSet("Set B");
    setC = new CategoryOptionGroupSet("Set C");
    setD = new CategoryOptionGroupSet("Set D");
    categoryService.saveCategoryOptionGroupSet(setA);
    categoryService.saveCategoryOptionGroupSet(setB);
    categoryService.saveCategoryOptionGroupSet(setC);
    categoryService.saveCategoryOptionGroupSet(setD);
    level1 = new DataApprovalLevel("01", 1, null);
    level1A = new DataApprovalLevel("1A", 1, setA);
    level1B = new DataApprovalLevel("1B", 1, setB);
    level1C = new DataApprovalLevel("1C", 1, setC);
    level1D = new DataApprovalLevel("1D", 1, setD);
    level2 = new DataApprovalLevel("02", 2, null);
    level2A = new DataApprovalLevel("2A", 2, setA);
    level2B = new DataApprovalLevel("2B", 2, setB);
    level2C = new DataApprovalLevel("2C", 2, setC);
    level2D = new DataApprovalLevel("2D", 2, setD);
    level3 = new DataApprovalLevel("03", 3, null);
    level3A = new DataApprovalLevel("3A", 3, setA);
    level3B = new DataApprovalLevel("3B", 3, setB);
    level3C = new DataApprovalLevel("3C", 3, setC);
    level4 = new DataApprovalLevel("04", 4, null);
    level4A = new DataApprovalLevel("4A", 4, setA);
    level4B = new DataApprovalLevel("4B", 4, setB);
    level4D = new DataApprovalLevel("4D", 4, setD);
    level5 = new DataApprovalLevel("05", 5, null);
    // 
    // Org Organisation
    // unit unit
    // level: hierarchy:
    // 
    // 1 A
    // |
    // 2 B
    // / | \
    // 3 C F I
    // | | |
    // 4 D G J
    // | | |
    // 5 E H K
    // 
    // Note: E through K are optionally added by the test if desired.
    organisationUnitA = createOrganisationUnit('A');
    organisationUnitB = createOrganisationUnit('B', organisationUnitA);
    organisationUnitC = createOrganisationUnit('C', organisationUnitB);
    organisationUnitD = createOrganisationUnit('D', organisationUnitC);
    organisationUnitE = createOrganisationUnit('E', organisationUnitD);
    organisationUnitF = createOrganisationUnit('F', organisationUnitB);
    organisationUnitG = createOrganisationUnit('G', organisationUnitF);
    organisationUnitH = createOrganisationUnit('H', organisationUnitG);
    organisationUnitI = createOrganisationUnit('I', organisationUnitB);
    organisationUnitJ = createOrganisationUnit('J', organisationUnitI);
    organisationUnitK = createOrganisationUnit('K', organisationUnitJ);
    organisationUnitService.addOrganisationUnit(organisationUnitA);
    organisationUnitService.addOrganisationUnit(organisationUnitB);
    organisationUnitService.addOrganisationUnit(organisationUnitC);
    organisationUnitService.addOrganisationUnit(organisationUnitD);
}
Also used : CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet)

Example 10 with CategoryOptionGroupSet

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

the class AclServiceTest method testCanDataOrMetadataRead.

@Test
void testCanDataOrMetadataRead() {
    User user1 = createUser("user1A8", "F_CATEGORY_OPTION_GROUP_SET_PUBLIC_ADD");
    manager.save(user1);
    // non data shareable object //
    CategoryOptionGroupSet categoryOptionGroupSet = new CategoryOptionGroupSet();
    categoryOptionGroupSet.setAutoFields();
    categoryOptionGroupSet.setName("cogA");
    manager.save(categoryOptionGroupSet);
    assertTrue(aclService.canDataOrMetadataRead(user1, categoryOptionGroupSet));
    // data shareable object //
    CategoryOption categoryOption = new CategoryOption();
    categoryOption.setAutoFields();
    categoryOption.setName("coA");
    categoryOption.setPublicAccess(AccessStringHelper.DATA_READ);
    categoryOption.setCreatedBy(user1);
    categoryOption.getSharing().setOwner(user1);
    categoryOption.setPublicAccess("rwrw----");
    manager.save(categoryOption, false);
    assertTrue(aclService.canDataOrMetadataRead(user1, categoryOption));
}
Also used : User(org.hisp.dhis.user.User) CategoryOptionGroupSet(org.hisp.dhis.category.CategoryOptionGroupSet) CategoryOption(org.hisp.dhis.category.CategoryOption) TransactionalIntegrationTest(org.hisp.dhis.TransactionalIntegrationTest) Test(org.junit.jupiter.api.Test)

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