use of org.olat.basesecurity.Invitation in project OpenOLAT by OpenOLAT.
the class EPPolicyManager method getMapPolicies.
/**
* Return a list of wrapper containing the read policies of the map
* @param map
*/
public List<EPMapPolicy> getMapPolicies(PortfolioStructureMapRef mapRef) {
EPMapShort map = dbInstance.getCurrentEntityManager().find(EPMapShort.class, mapRef.getKey());
List<EPMapPolicy> policies = new ArrayList<EPMapPolicy>();
Set<EPStructureElementToGroupRelation> relations = map.getGroups();
for (EPStructureElementToGroupRelation relation : relations) {
if (relation.isDefaultGroup()) {
continue;
}
EPMapPolicy policy = getEquivalentWrapper(relation, policies);
if (policy == null) {
policy = new EPMapPolicy();
policy.setTo(relation.getValidTo());
policy.setFrom(relation.getValidFrom());
policies.add(policy);
}
String role = relation.getRole();
if (role.startsWith(EPMapPolicy.Type.user.name())) {
List<Identity> identities = groupDao.getMembers(relation.getGroup(), GroupRoles.participant.name());
policy.addRelation(relation);
policy.setType(EPMapPolicy.Type.user);
policy.addIdentities(identities);
} else if (role.startsWith(EPMapPolicy.Type.group.name())) {
policy.addRelation(relation);
BusinessGroup group = businessGroupDao.findBusinessGroup(relation.getGroup());
policy.addGroup(group);
policy.setType(EPMapPolicy.Type.group);
} else if (role.startsWith(EPMapPolicy.Type.invitation.name())) {
policy.addRelation(relation);
Invitation invitation = invitationDao.findInvitation(relation.getGroup());
policy.setInvitation(invitation);
policy.setType(EPMapPolicy.Type.invitation);
} else if (role.startsWith(EPMapPolicy.Type.allusers.name())) {
policy.addRelation(relation);
policy.setType(EPMapPolicy.Type.allusers);
}
}
return policies;
}
use of org.olat.basesecurity.Invitation in project openolat by klemens.
the class BinderDAO method getBinderAccesRights.
public List<AccessRights> getBinderAccesRights(Page page) {
if (page == null) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("select binder.key, section.key, page.key, membership.role, ident, invitation from pfpage as page").append(" inner join page.section as section").append(" inner join section.binder as binder").append(" inner join binder.baseGroup as baseGroup").append(" inner join baseGroup.members as membership").append(" inner join membership.identity as ident").append(" inner join fetch ident.user as identUser").append(" left join binvitation as invitation on (invitation.baseGroup.key=binder.baseGroup.key and identUser.email=invitation.mail)").append(" where page.key=:pageKey");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("pageKey", page.getKey());
List<Object[]> objects = query.getResultList();
List<AccessRights> rightList = new ArrayList<>(objects.size());
for (Object[] object : objects) {
Long binderKey = (Long) object[0];
Long sectionKey = (Long) object[1];
Long pageKey = (Long) object[2];
String role = (String) object[3];
Identity member = (Identity) object[4];
Invitation invitation = (Invitation) object[5];
AccessRights rights = new AccessRights();
rights.setRole(PortfolioRoles.valueOf(role));
rights.setBinderKey(binderKey);
rights.setSectionKey(sectionKey);
rights.setPageKey(pageKey);
rights.setIdentity(member);
rights.setInvitation(invitation);
rightList.add(rights);
}
return rightList;
}
use of org.olat.basesecurity.Invitation in project openolat by klemens.
the class BinderDAO method getBinderAccesRights.
public List<AccessRights> getBinderAccesRights(BinderRef binder, IdentityRef identity) {
if (binder == null) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("select membership.role, ident, invitation from pfbinder as binder").append(" inner join binder.baseGroup as baseGroup").append(" inner join baseGroup.members as membership");
if (identity != null) {
sb.append(" on (membership.identity.key =:identityKey)");
}
sb.append(" inner join membership.identity as ident").append(" inner join fetch ident.user as identUser").append(" left join binvitation as invitation on (invitation.baseGroup.key=baseGroup.key and identUser.email=invitation.mail)").append(" where binder.key=:binderKey");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey());
if (identity != null) {
query.setParameter("identityKey", identity.getKey());
}
List<Object[]> objects = query.getResultList();
List<AccessRights> rightList = new ArrayList<>(objects.size());
for (Object[] object : objects) {
String role = (String) object[0];
Identity member = (Identity) object[1];
Invitation invitation = (Invitation) object[2];
AccessRights rights = new AccessRights();
rights.setRole(PortfolioRoles.valueOf(role));
rights.setBinderKey(binder.getKey());
rights.setIdentity(member);
rights.setInvitation(invitation);
rightList.add(rights);
}
return rightList;
}
use of org.olat.basesecurity.Invitation in project openolat by klemens.
the class BinderDAO method getSectionAccesRights.
public List<AccessRights> getSectionAccesRights(Page page) {
if (page == null) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("select binder.key, section.key, page.key, membership.role, ident, invitation from pfpage as page").append(" inner join page.section as section").append(" inner join section.binder as binder").append(" inner join section.baseGroup as baseGroup").append(" inner join baseGroup.members as membership").append(" inner join membership.identity as ident").append(" inner join fetch ident.user as identUser").append(" left join binvitation as invitation on (invitation.baseGroup.key=binder.baseGroup.key and identUser.email=invitation.mail)").append(" where page.key=:pageKey");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("pageKey", page.getKey());
List<Object[]> objects = query.getResultList();
List<AccessRights> rightList = new ArrayList<>(objects.size());
for (Object[] object : objects) {
Long binderKey = (Long) object[0];
Long sectionKey = (Long) object[1];
Long pageKey = (Long) object[2];
String role = (String) object[3];
Identity member = (Identity) object[4];
Invitation invitation = (Invitation) object[5];
AccessRights rights = new AccessRights();
rights.setRole(PortfolioRoles.valueOf(role));
rights.setBinderKey(binderKey);
rights.setSectionKey(sectionKey);
rights.setPageKey(pageKey);
rights.setIdentity(member);
rights.setInvitation(invitation);
rightList.add(rights);
}
return rightList;
}
use of org.olat.basesecurity.Invitation in project openolat by klemens.
the class BinderDAO method getPageAccesRights.
public List<AccessRights> getPageAccesRights(BinderRef binder, IdentityRef identity) {
if (binder == null) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("select section.key, page.key, membership.role, ident, invitation from pfbinder as binder").append(" inner join binder.sections as section").append(" inner join section.pages as page").append(" inner join page.baseGroup as baseGroup").append(" inner join baseGroup.members as membership");
if (identity != null) {
sb.append(" on (membership.identity.key=:identityKey)");
}
sb.append(" inner join membership.identity as ident").append(" inner join fetch ident.user as identUser").append(" left join binvitation as invitation on (invitation.baseGroup.key=binder.baseGroup.key and identUser.email=invitation.mail)").append(" where binder.key=:binderKey");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey());
if (identity != null) {
query.setParameter("identityKey", identity.getKey());
}
List<Object[]> objects = query.getResultList();
List<AccessRights> rightList = new ArrayList<>(objects.size());
for (Object[] object : objects) {
Long sectionKey = (Long) object[0];
Long pageKey = (Long) object[1];
String role = (String) object[2];
Identity member = (Identity) object[3];
Invitation invitation = (Invitation) object[4];
AccessRights rights = new AccessRights();
rights.setRole(PortfolioRoles.valueOf(role));
rights.setBinderKey(binder.getKey());
rights.setSectionKey(sectionKey);
rights.setPageKey(pageKey);
rights.setIdentity(member);
rights.setInvitation(invitation);
rightList.add(rights);
}
return rightList;
}
Aggregations