Search in sources :

Example 1 with BusinessGroupUpgrade

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

the class OLATUpgrade_10_0_0 method upgradeRelationsRepoToBusinessGroups.

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

Example 2 with BusinessGroupUpgrade

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

the class OLATUpgrade_10_0_0 method upgradeRelationsRepoToBusinessGroups.

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

Example 3 with BusinessGroupUpgrade

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

the class OLATUpgrade_10_0_3 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) {
                processRightGroup(businessGroup);
            }
            counter += businessGroups.size();
            log.audit("Rights 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)

Example 4 with BusinessGroupUpgrade

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

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 5 with BusinessGroupUpgrade

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

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)

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