Search in sources :

Example 1 with InvitationUpgrade

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

the class OLATUpgrade_10_0_0 method upgradeInvitation.

private boolean upgradeInvitation(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    if (!uhd.getBooleanDataValue(TASK_INVITATION)) {
        int counter = 0;
        List<InvitationUpgrade> invitations;
        do {
            invitations = findInvitations(counter, BATCH_SIZE);
            for (InvitationUpgrade invitation : invitations) {
                if (invitation.getBaseGroup() == null) {
                    processInvitation(invitation);
                }
            }
            counter += invitations.size();
            log.audit("Invitations processed: " + invitations.size() + ", total processed (" + counter + ")");
            dbInstance.commitAndCloseSession();
        } while (invitations.size() == BATCH_SIZE);
        uhd.setBooleanDataValue(TASK_INVITATION, true);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return true;
}
Also used : InvitationUpgrade(org.olat.upgrade.model.InvitationUpgrade)

Example 2 with InvitationUpgrade

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

the class OLATUpgrade_10_0_0 method upgradeInvitation.

private boolean upgradeInvitation(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    if (!uhd.getBooleanDataValue(TASK_INVITATION)) {
        int counter = 0;
        List<InvitationUpgrade> invitations;
        do {
            invitations = findInvitations(counter, BATCH_SIZE);
            for (InvitationUpgrade invitation : invitations) {
                if (invitation.getBaseGroup() == null) {
                    processInvitation(invitation);
                }
            }
            counter += invitations.size();
            log.audit("Invitations processed: " + invitations.size() + ", total processed (" + counter + ")");
            dbInstance.commitAndCloseSession();
        } while (invitations.size() == BATCH_SIZE);
        uhd.setBooleanDataValue(TASK_INVITATION, true);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return true;
}
Also used : InvitationUpgrade(org.olat.upgrade.model.InvitationUpgrade)

Example 3 with InvitationUpgrade

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

the class OLATUpgrade_10_0_0 method processMapPolicy.

private EPMapUpgradeToGroupRelation processMapPolicy(Policy policy, EPMapUpgrade element) {
    String permission = policy.getPermission();
    SecurityGroup secGroup = policy.getSecurityGroup();
    Group group;
    String role;
    if (permission.startsWith(EPMapPolicy.Type.user.name())) {
        group = groupDao.createGroup();
        processSecurityGroup(group, GroupRoles.participant.name(), secGroup);
        role = EPMapPolicy.Type.user.name();
    } else if (permission.startsWith(EPMapPolicy.Type.group.name())) {
        group = findGroupOfBusinessGroup(secGroup);
        role = EPMapPolicy.Type.group.name();
    } else if (permission.startsWith(EPMapPolicy.Type.invitation.name())) {
        InvitationUpgrade invitation = findInvitation(policy.getSecurityGroup());
        if (invitation == null) {
            return null;
        }
        group = invitation.getBaseGroup();
        role = EPMapPolicy.Type.invitation.name();
    } else if (permission.startsWith(EPMapPolicy.Type.allusers.name())) {
        group = groupDao.createGroup(EPMapPolicy.Type.allusers.name());
        role = EPMapPolicy.Type.allusers.name();
    } else {
        return null;
    }
    if (group == null) {
        log.error("Group not resolve for policy of map: " + element.getKey() + " and policy: " + policy.getKey());
        return null;
    }
    EPMapUpgradeToGroupRelation relation = new EPMapUpgradeToGroupRelation();
    relation.setDefaultGroup(false);
    relation.setCreationDate(new Date());
    relation.setEntry(element);
    relation.setValidTo(policy.getTo());
    relation.setValidFrom(policy.getFrom());
    relation.setGroup(group);
    relation.setRole(role);
    return relation;
}
Also used : Group(org.olat.basesecurity.Group) SecurityGroup(org.olat.basesecurity.SecurityGroup) EPMapUpgradeToGroupRelation(org.olat.upgrade.model.EPMapUpgradeToGroupRelation) InvitationUpgrade(org.olat.upgrade.model.InvitationUpgrade) SecurityGroup(org.olat.basesecurity.SecurityGroup) Date(java.util.Date)

Example 4 with InvitationUpgrade

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

the class OLATUpgrade_10_0_0 method processMapPolicy.

private EPMapUpgradeToGroupRelation processMapPolicy(Policy policy, EPMapUpgrade element) {
    String permission = policy.getPermission();
    SecurityGroup secGroup = policy.getSecurityGroup();
    Group group;
    String role;
    if (permission.startsWith(EPMapPolicy.Type.user.name())) {
        group = groupDao.createGroup();
        processSecurityGroup(group, GroupRoles.participant.name(), secGroup);
        role = EPMapPolicy.Type.user.name();
    } else if (permission.startsWith(EPMapPolicy.Type.group.name())) {
        group = findGroupOfBusinessGroup(secGroup);
        role = EPMapPolicy.Type.group.name();
    } else if (permission.startsWith(EPMapPolicy.Type.invitation.name())) {
        InvitationUpgrade invitation = findInvitation(policy.getSecurityGroup());
        if (invitation == null) {
            return null;
        }
        group = invitation.getBaseGroup();
        role = EPMapPolicy.Type.invitation.name();
    } else if (permission.startsWith(EPMapPolicy.Type.allusers.name())) {
        group = groupDao.createGroup(EPMapPolicy.Type.allusers.name());
        role = EPMapPolicy.Type.allusers.name();
    } else {
        return null;
    }
    if (group == null) {
        log.error("Group not resolve for policy of map: " + element.getKey() + " and policy: " + policy.getKey());
        return null;
    }
    EPMapUpgradeToGroupRelation relation = new EPMapUpgradeToGroupRelation();
    relation.setDefaultGroup(false);
    relation.setCreationDate(new Date());
    relation.setEntry(element);
    relation.setValidTo(policy.getTo());
    relation.setValidFrom(policy.getFrom());
    relation.setGroup(group);
    relation.setRole(role);
    return relation;
}
Also used : Group(org.olat.basesecurity.Group) SecurityGroup(org.olat.basesecurity.SecurityGroup) EPMapUpgradeToGroupRelation(org.olat.upgrade.model.EPMapUpgradeToGroupRelation) InvitationUpgrade(org.olat.upgrade.model.InvitationUpgrade) SecurityGroup(org.olat.basesecurity.SecurityGroup) Date(java.util.Date)

Aggregations

InvitationUpgrade (org.olat.upgrade.model.InvitationUpgrade)4 Date (java.util.Date)2 Group (org.olat.basesecurity.Group)2 SecurityGroup (org.olat.basesecurity.SecurityGroup)2 EPMapUpgradeToGroupRelation (org.olat.upgrade.model.EPMapUpgradeToGroupRelation)2