use of org.olat.group.BusinessGroupImpl in project openolat by klemens.
the class OLATUpgrade_9_4_0 method upgradeDisplayMembers.
private boolean upgradeDisplayMembers(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
if (!uhd.getBooleanDataValue(TASK_DISPLAY_MEMBERS)) {
int counter = 0;
List<BusinessGroupImpl> groups;
do {
groups = findGroups(counter, BATCH_SIZE);
for (BusinessGroupImpl group : groups) {
Property prop = findProperty(group);
if (prop != null) {
boolean changed = false;
Long internValue = prop.getLongValue();
if (internValue != null && internValue.longValue() > 0) {
long value = internValue.longValue();
boolean owners = (value & showOwnersVal) == showOwnersVal;
boolean participants = (value & showPartipsVal) == showPartipsVal;
boolean waiting = (value & showWaitingListVal) == showWaitingListVal;
group.setOwnersVisibleIntern(owners);
group.setParticipantsVisibleIntern(participants);
group.setWaitingListVisibleIntern(waiting);
changed = true;
}
String publicValue = prop.getStringValue();
if (publicValue != null && publicValue.length() > 0 && Character.isDigit(publicValue.toCharArray()[0])) {
try {
int value = Integer.parseInt(publicValue);
boolean owners = (value & showOwnersVal) == showOwnersVal;
boolean participants = (value & showPartipsVal) == showPartipsVal;
boolean waiting = (value & showWaitingListVal) == showWaitingListVal;
group.setOwnersVisiblePublic(owners);
group.setParticipantsVisiblePublic(participants);
group.setWaitingListVisiblePublic(waiting);
} catch (NumberFormatException e) {
log.error("", e);
}
changed = true;
}
Float downloadValue = prop.getFloatValue();
if (downloadValue != null && downloadValue != 0.0f) {
float value = downloadValue.floatValue();
// paranoid check
if (value > 0.9 && value < 1.1) {
group.setDownloadMembersLists(true);
changed = true;
} else if (value < -0.9 && value > -1.1) {
group.setDownloadMembersLists(true);
changed = true;
}
}
if (changed) {
prop.setCategory("configMoved");
dbInstance.getCurrentEntityManager().merge(group);
}
}
}
counter += groups.size();
log.audit("Business groups processed: " + groups.size());
dbInstance.commitAndCloseSession();
} while (groups.size() == BATCH_SIZE);
uhd.setBooleanDataValue(TASK_DISPLAY_MEMBERS, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return true;
}
Aggregations