Search in sources :

Example 1 with BGResourceRelation

use of org.olat.upgrade.model.BGResourceRelation 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 2 with BGResourceRelation

use of org.olat.upgrade.model.BGResourceRelation 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

Group (org.olat.basesecurity.Group)2 SecurityGroup (org.olat.basesecurity.SecurityGroup)2 BGResourceRelation (org.olat.upgrade.model.BGResourceRelation)2 RepositoryEntryUpgrade (org.olat.upgrade.model.RepositoryEntryUpgrade)2 RepositoryEntryUpgradeToGroupRelation (org.olat.upgrade.model.RepositoryEntryUpgradeToGroupRelation)2