Search in sources :

Example 6 with BusinessGroupImpl

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;
}
Also used : BusinessGroupImpl(org.olat.group.BusinessGroupImpl) Property(org.olat.properties.Property)

Aggregations

BusinessGroupImpl (org.olat.group.BusinessGroupImpl)6 Group (org.olat.basesecurity.Group)4 BusinessGroup (org.olat.group.BusinessGroup)4 EntityManager (javax.persistence.EntityManager)2 Test (org.junit.Test)2 GroupRoles (org.olat.basesecurity.GroupRoles)2 Identity (org.olat.core.id.Identity)2 Roles (org.olat.core.id.Roles)2 Property (org.olat.properties.Property)2 OLATResource (org.olat.resource.OLATResource)2