Search in sources :

Example 6 with BusinessGroupUpgrade

use of org.olat.upgrade.model.BusinessGroupUpgrade in project openolat by klemens.

the class OLATUpgrade_8_2_0 method upgradeGroups.

private boolean upgradeGroups(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    if (!uhd.getBooleanDataValue(TASK_CONTEXTS)) {
        int counter = 0;
        List<BusinessGroupUpgrade> groups;
        do {
            groups = findBusinessGroups(counter, REPO_ENTRIES_BATCH_SIZE);
            for (BusinessGroupUpgrade group : groups) {
                processBusinessGroup(group);
            }
            counter += groups.size();
            log.audit("Processed context: " + groups.size());
            dbInstance.intermediateCommit();
        } while (groups.size() == REPO_ENTRIES_BATCH_SIZE);
        uhd.setBooleanDataValue(TASK_CONTEXTS, true);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return true;
}
Also used : BusinessGroupUpgrade(org.olat.upgrade.model.BusinessGroupUpgrade)

Example 7 with BusinessGroupUpgrade

use of org.olat.upgrade.model.BusinessGroupUpgrade in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_7_1_1 method getGroupsOfBGContext.

private List<BusinessGroupUpgrade> getGroupsOfBGContext(BGContextImpl bgContext) {
    String q = "select bg from org.olat.upgrade.model.BusinessGroupImpl bg where bg.groupContextKey = :contextKey";
    DBQuery query = DBFactory.getInstance().createQuery(q);
    query.setLong("contextKey", bgContext.getKey());
    @SuppressWarnings("unchecked") List<BusinessGroupUpgrade> groups = query.list();
    return groups;
}
Also used : BusinessGroupUpgrade(org.olat.upgrade.model.BusinessGroupUpgrade) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 8 with BusinessGroupUpgrade

use of org.olat.upgrade.model.BusinessGroupUpgrade in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_7_1_1 method migrateRepoEntrySecurityGroups.

private void migrateRepoEntrySecurityGroups(RepositoryEntryUpgrade entry) {
    BaseSecurity securityManager = BaseSecurityManager.getInstance();
    List<BGContextImpl> contexts = findBGContextsForResource(entry.getOlatResource(), true, true);
    for (BGContextImpl context : contexts) {
        List<BusinessGroupUpgrade> groups = getGroupsOfBGContext(context);
        for (BusinessGroupUpgrade group : groups) {
            // migrate tutors
            if (group.getOwnerGroup() != null) {
                int count = 0;
                List<Identity> owners = securityManager.getIdentitiesOfSecurityGroup(group.getOwnerGroup());
                SecurityGroup tutorGroup = entry.getTutorGroup();
                for (Identity owner : owners) {
                    if (securityManager.isIdentityInSecurityGroup(owner, tutorGroup)) {
                        continue;
                    }
                    securityManager.addIdentityToSecurityGroup(owner, tutorGroup);
                    if (count++ % 20 == 0) {
                        DBFactory.getInstance().intermediateCommit();
                    }
                }
                DBFactory.getInstance().intermediateCommit();
            }
            // migrate participants
            if (group.getPartipiciantGroup() != null) {
                int count = 0;
                List<Identity> participants = securityManager.getIdentitiesOfSecurityGroup(group.getPartipiciantGroup());
                SecurityGroup participantGroup = entry.getParticipantGroup();
                for (Identity participant : participants) {
                    if (securityManager.isIdentityInSecurityGroup(participant, participantGroup)) {
                        continue;
                    }
                    securityManager.addIdentityToSecurityGroup(participant, participantGroup);
                    if (count++ % 20 == 0) {
                        DBFactory.getInstance().intermediateCommit();
                    }
                }
                DBFactory.getInstance().intermediateCommit();
            }
        }
    }
}
Also used : BGContextImpl(org.olat.upgrade.model.BGContextImpl) BusinessGroupUpgrade(org.olat.upgrade.model.BusinessGroupUpgrade) Identity(org.olat.core.id.Identity) SecurityGroup(org.olat.basesecurity.SecurityGroup) BaseSecurity(org.olat.basesecurity.BaseSecurity)

Example 9 with BusinessGroupUpgrade

use of org.olat.upgrade.model.BusinessGroupUpgrade in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_8_2_0 method upgradeGroups.

private boolean upgradeGroups(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    if (!uhd.getBooleanDataValue(TASK_CONTEXTS)) {
        int counter = 0;
        List<BusinessGroupUpgrade> groups;
        do {
            groups = findBusinessGroups(counter, REPO_ENTRIES_BATCH_SIZE);
            for (BusinessGroupUpgrade group : groups) {
                processBusinessGroup(group);
            }
            counter += groups.size();
            log.audit("Processed context: " + groups.size());
            dbInstance.intermediateCommit();
        } while (groups.size() == REPO_ENTRIES_BATCH_SIZE);
        uhd.setBooleanDataValue(TASK_CONTEXTS, true);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return true;
}
Also used : BusinessGroupUpgrade(org.olat.upgrade.model.BusinessGroupUpgrade)

Example 10 with BusinessGroupUpgrade

use of org.olat.upgrade.model.BusinessGroupUpgrade in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_10_0_0 method upgradeBusinessGroups.

private boolean upgradeBusinessGroups(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    if (!uhd.getBooleanDataValue(TASK_BUSINESS_GROUPS)) {
        int counter = 0;
        List<BusinessGroupUpgrade> businessGroups;
        do {
            businessGroups = findBusinessGroups(counter, BATCH_SIZE);
            for (BusinessGroupUpgrade businessGroup : businessGroups) {
                processBusinessGroup(businessGroup);
            }
            counter += businessGroups.size();
            log.audit("Business groups processed: " + businessGroups.size() + ", total processed (" + counter + ")");
            dbInstance.commitAndCloseSession();
        } while (businessGroups.size() == BATCH_SIZE);
        uhd.setBooleanDataValue(TASK_BUSINESS_GROUPS, true);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return true;
}
Also used : BusinessGroupUpgrade(org.olat.upgrade.model.BusinessGroupUpgrade)

Aggregations

BusinessGroupUpgrade (org.olat.upgrade.model.BusinessGroupUpgrade)12 BaseSecurity (org.olat.basesecurity.BaseSecurity)2 SecurityGroup (org.olat.basesecurity.SecurityGroup)2 DBQuery (org.olat.core.commons.persistence.DBQuery)2 Identity (org.olat.core.id.Identity)2 BGContextImpl (org.olat.upgrade.model.BGContextImpl)2