Search in sources :

Example 1 with RepositoryEntryUpgradeToGroupRelation

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

the class OLATUpgrade_10_0_0 method processRepositoryEntry.

private void processRepositoryEntry(RepositoryEntryUpgrade repoEntry) {
    if (isDefaultGroupOk(repoEntry))
        return;
    Group group = groupDao.createGroup();
    // update owners
    processSecurityGroup(group, GroupRoles.owner.name(), repoEntry.getOwnerGroup());
    // update tutors
    processSecurityGroup(group, GroupRoles.coach.name(), repoEntry.getTutorGroup());
    // update participants
    processSecurityGroup(group, GroupRoles.participant.name(), repoEntry.getParticipantGroup());
    dbInstance.commit();
    RepositoryEntryUpgradeToGroupRelation relation = create(repoEntry, group, true);
    Set<RepositoryEntryUpgradeToGroupRelation> relations = new HashSet<>(2);
    relations.add(relation);
    repoEntry.setGroups(relations);
    dbInstance.commit();
}
Also used : Group(org.olat.basesecurity.Group) SecurityGroup(org.olat.basesecurity.SecurityGroup) RepositoryEntryUpgradeToGroupRelation(org.olat.upgrade.model.RepositoryEntryUpgradeToGroupRelation) HashSet(java.util.HashSet)

Example 2 with RepositoryEntryUpgradeToGroupRelation

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

the class OLATUpgrade_10_0_0 method processRelationToRepo.

private void processRelationToRepo(BusinessGroupUpgrade businessGroup) {
    try {
        List<BGResourceRelation> relationsToRepo = findRelations(businessGroup);
        if (relationsToRepo.size() > 0) {
            Group refGroup = businessGroup.getBaseGroup();
            for (BGResourceRelation relationToRepo : relationsToRepo) {
                RepositoryEntryUpgrade entry = lookupRepositoryEntry(relationToRepo.getResource());
                if (entry == null) {
                    continue;
                }
                boolean found = false;
                Set<RepositoryEntryUpgradeToGroupRelation> groupRelations = entry.getGroups();
                for (RepositoryEntryUpgradeToGroupRelation groupRelation : groupRelations) {
                    if (groupRelation.getGroup().equals(refGroup)) {
                        found = true;
                    }
                }
                if (!found) {
                    create(entry, refGroup, false);
                }
            }
        }
        dbInstance.commit();
    } catch (Exception e) {
        log.error("", e);
        throw e;
    }
}
Also used : Group(org.olat.basesecurity.Group) SecurityGroup(org.olat.basesecurity.SecurityGroup) RepositoryEntryUpgrade(org.olat.upgrade.model.RepositoryEntryUpgrade) RepositoryEntryUpgradeToGroupRelation(org.olat.upgrade.model.RepositoryEntryUpgradeToGroupRelation) BGResourceRelation(org.olat.upgrade.model.BGResourceRelation)

Example 3 with RepositoryEntryUpgradeToGroupRelation

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

the class OLATUpgrade_10_0_0 method processRepositoryEntry.

private void processRepositoryEntry(RepositoryEntryUpgrade repoEntry) {
    if (isDefaultGroupOk(repoEntry))
        return;
    Group group = groupDao.createGroup();
    // update owners
    processSecurityGroup(group, GroupRoles.owner.name(), repoEntry.getOwnerGroup());
    // update tutors
    processSecurityGroup(group, GroupRoles.coach.name(), repoEntry.getTutorGroup());
    // update participants
    processSecurityGroup(group, GroupRoles.participant.name(), repoEntry.getParticipantGroup());
    dbInstance.commit();
    RepositoryEntryUpgradeToGroupRelation relation = create(repoEntry, group, true);
    Set<RepositoryEntryUpgradeToGroupRelation> relations = new HashSet<>(2);
    relations.add(relation);
    repoEntry.setGroups(relations);
    dbInstance.commit();
}
Also used : Group(org.olat.basesecurity.Group) SecurityGroup(org.olat.basesecurity.SecurityGroup) RepositoryEntryUpgradeToGroupRelation(org.olat.upgrade.model.RepositoryEntryUpgradeToGroupRelation) HashSet(java.util.HashSet)

Example 4 with RepositoryEntryUpgradeToGroupRelation

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

the class OLATUpgrade_10_0_0 method create.

public RepositoryEntryUpgradeToGroupRelation create(RepositoryEntryUpgrade entry, Group group, boolean defaultRelation) {
    RepositoryEntryUpgradeToGroupRelation rel = new RepositoryEntryUpgradeToGroupRelation();
    rel.setCreationDate(new Date());
    rel.setDefaultGroup(defaultRelation);
    rel.setGroup(group);
    rel.setEntry(entry);
    dbInstance.getCurrentEntityManager().persist(rel);
    return rel;
}
Also used : RepositoryEntryUpgradeToGroupRelation(org.olat.upgrade.model.RepositoryEntryUpgradeToGroupRelation) Date(java.util.Date)

Example 5 with RepositoryEntryUpgradeToGroupRelation

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

the class OLATUpgrade_10_0_0 method processRelationToRepo.

private void processRelationToRepo(BusinessGroupUpgrade businessGroup) {
    try {
        List<BGResourceRelation> relationsToRepo = findRelations(businessGroup);
        if (relationsToRepo.size() > 0) {
            Group refGroup = businessGroup.getBaseGroup();
            for (BGResourceRelation relationToRepo : relationsToRepo) {
                RepositoryEntryUpgrade entry = lookupRepositoryEntry(relationToRepo.getResource());
                if (entry == null) {
                    continue;
                }
                boolean found = false;
                Set<RepositoryEntryUpgradeToGroupRelation> groupRelations = entry.getGroups();
                for (RepositoryEntryUpgradeToGroupRelation groupRelation : groupRelations) {
                    if (groupRelation.getGroup().equals(refGroup)) {
                        found = true;
                    }
                }
                if (!found) {
                    create(entry, refGroup, false);
                }
            }
        }
        dbInstance.commit();
    } catch (Exception e) {
        log.error("", e);
        throw e;
    }
}
Also used : Group(org.olat.basesecurity.Group) SecurityGroup(org.olat.basesecurity.SecurityGroup) RepositoryEntryUpgrade(org.olat.upgrade.model.RepositoryEntryUpgrade) RepositoryEntryUpgradeToGroupRelation(org.olat.upgrade.model.RepositoryEntryUpgradeToGroupRelation) BGResourceRelation(org.olat.upgrade.model.BGResourceRelation)

Aggregations

RepositoryEntryUpgradeToGroupRelation (org.olat.upgrade.model.RepositoryEntryUpgradeToGroupRelation)6 Group (org.olat.basesecurity.Group)4 SecurityGroup (org.olat.basesecurity.SecurityGroup)4 Date (java.util.Date)2 HashSet (java.util.HashSet)2 BGResourceRelation (org.olat.upgrade.model.BGResourceRelation)2 RepositoryEntryUpgrade (org.olat.upgrade.model.RepositoryEntryUpgrade)2