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();
}
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;
}
}
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();
}
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;
}
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;
}
}
Aggregations