use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_10_0_0 method processInvitation.
private void processInvitation(InvitationUpgrade invitation) {
if (invitation.getBaseGroup() == null) {
Group invitationGroup = groupDao.createGroup();
invitation.setBaseGroup(invitationGroup);
dbInstance.getCurrentEntityManager().merge(invitation);
}
}
use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class BGRightManagerImpl method findBGRights.
@Override
public List<BGRights> findBGRights(List<Group> baseGroups, OLATResource resource) {
List<Grant> grants = groupDao.getGrants(baseGroups, resource);
List<BGRights> rights = new ArrayList<>();
Map<BGRights, BGRights> rightsMap = new HashMap<>();
for (Grant grant : grants) {
String right = grant.getPermission();
if (right.indexOf(BG_RIGHT_PREFIX) == 0 && grant.getResource().equals(resource)) {
BGRightsRole role = null;
if (GroupRoles.participant.name().equals(grant.getRole())) {
role = BGRightsRole.participant;
} else if (GroupRoles.coach.name().equals(grant.getRole())) {
role = BGRightsRole.tutor;
}
BGRights wrapper = new BGRightsImpl(grant.getGroup(), role);
wrapper = rightsMap.computeIfAbsent(wrapper, w -> w);
wrapper.getRights().add(right);
rights.add(wrapper);
}
}
return rights;
}
use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.
the class BusinessGroupRelationDAO method addRole.
public void addRole(Identity identity, BusinessGroup businessGroup, String role) {
Group group = null;
try {
group = businessGroup.getBaseGroup();
if (group == null) {
group = getGroup(businessGroup);
}
} catch (Exception e) {
log.warn("", e);
group = getGroup(businessGroup);
}
groupDao.addMembershipOneWay(group, identity, role);
}
use of org.olat.basesecurity.Group in project openolat by klemens.
the class CheckboxManagerImpl method getAssessmentDatas.
@Override
public List<AssessmentData> getAssessmentDatas(OLATResourceable ores, String resSubPath, RepositoryEntry re, List<BusinessGroup> businessGroups) {
StringBuilder sb = new StringBuilder();
sb.append("select check from clcheck check").append(" inner join fetch check.checkbox box").append(" inner join fetch check.identity ident").append(" inner join fetch ident.user identUser").append(" where box.resName=:resName and box.resId=:resId");
if (StringHelper.containsNonWhitespace(resSubPath)) {
sb.append(" and box.resSubPath=:resSubPath");
}
boolean hasBusinessGroups = businessGroups != null && businessGroups.size() > 0;
if (hasBusinessGroups) {
sb.append(" and ");
if (re != null) {
sb.append(" ( ");
}
sb.append(" check.identity.key in ( select membership.identity.key from bgroupmember membership ").append(" where membership.group in (:baseGroups) and membership.role='").append(GroupRole.participant).append("'").append(" )");
}
if (re != null) {
if (hasBusinessGroups) {
sb.append(" or ");
} else {
sb.append(" and ");
}
sb.append(" check.identity.key in ( select membership.identity.key from repoentrytogroup as rel, bgroup as reBaseGroup, bgroupmember membership ").append(" where rel.entry.key=:repoKey and rel.group=reBaseGroup and membership.group=reBaseGroup and membership.role='").append(GroupRole.participant).append("'").append(" )");
if (hasBusinessGroups) {
sb.append(" ) ");
}
}
TypedQuery<DBCheck> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), DBCheck.class).setParameter("resName", ores.getResourceableTypeName()).setParameter("resId", ores.getResourceableId());
if (StringHelper.containsNonWhitespace(resSubPath)) {
query.setParameter("resSubPath", resSubPath);
}
if (hasBusinessGroups) {
List<Group> groups = new ArrayList<>(businessGroups.size());
for (BusinessGroup businessGroup : businessGroups) {
groups.add(businessGroup.getBaseGroup());
}
query.setParameter("baseGroups", groups);
}
if (re != null) {
query.setParameter("repoKey", re.getKey());
}
List<DBCheck> checks = query.getResultList();
Map<Long, AssessmentData> identToBox = new HashMap<Long, AssessmentData>();
for (DBCheck check : checks) {
AssessmentData data = identToBox.get(check.getIdentity().getKey());
if (data == null) {
data = new AssessmentData(check.getIdentity());
identToBox.put(check.getIdentity().getKey(), data);
}
data.getChecks().add(check);
}
return new ArrayList<AssessmentData>(identToBox.values());
}
use of org.olat.basesecurity.Group in project openolat by klemens.
the class BinderDAO method deleteBinder.
public int deleteBinder(BinderRef binderRef) {
int rows = userInformationsDAO.deleteBinderUserInfos(binderRef);
BinderImpl binder = (BinderImpl) loadByKey(binderRef.getKey());
List<Section> sections = new ArrayList<>(binder.getSections());
for (Section section : sections) {
List<Page> pages = new ArrayList<>(section.getPages());
section.getPages().clear();
section = dbInstance.getCurrentEntityManager().merge(section);
for (Page page : pages) {
if (page != null) {
rows += pageDao.deletePage(page);
rows += pageUserInfosDao.delete(page);
}
}
rows += assessmentSectionDao.deleteAssessmentSections(section);
Group baseGroup = section.getBaseGroup();
rows += groupDao.removeMemberships(baseGroup);
dbInstance.getCurrentEntityManager().remove(section);
dbInstance.getCurrentEntityManager().remove(baseGroup);
rows += 2;
}
binder.getSections().clear();
Group baseGroup = binder.getBaseGroup();
rows += groupDao.removeMemberships(baseGroup);
dbInstance.getCurrentEntityManager().remove(binder);
dbInstance.getCurrentEntityManager().remove(baseGroup);
return rows + 2;
}
Aggregations