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;
}
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;
}
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;
}
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;
}
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();
}
}
}
}
Aggregations