use of org.olat.basesecurity.Invitation in project openolat by klemens.
the class BinderDAO method getPageAccesRights.
public List<AccessRights> getPageAccesRights(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 page.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 getSectionAccesRights.
public List<AccessRights> getSectionAccesRights(BinderRef binder, IdentityRef identity) {
if (binder == null) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("select section.key, membership.role, ident, invitation from pfbinder as binder").append(" inner join binder.sections as section").append(" inner join section.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];
String role = (String) object[1];
Identity member = (Identity) object[2];
Invitation invitation = (Invitation) object[3];
AccessRights rights = new AccessRights();
rights.setRole(PortfolioRoles.valueOf(role));
rights.setBinderKey(binder.getKey());
rights.setSectionKey(sectionKey);
rights.setIdentity(member);
rights.setInvitation(invitation);
rightList.add(rights);
}
return rightList;
}
use of org.olat.basesecurity.Invitation in project openolat by klemens.
the class ConfirmClosePageController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
List<String> names = new ArrayList<>(rights.size());
for (AccessRights right : rights) {
String fullName = null;
if (right.getInvitation() != null) {
Invitation invitation = right.getInvitation();
fullName = userManager.getUserDisplayName(invitation.getFirstName(), invitation.getLastName());
} else if (getIdentity().equals(right.getIdentity()) || owners.contains(right.getIdentity())) {
continue;
} else if (right.getIdentity() != null) {
fullName = userManager.getUserDisplayName(right.getIdentity());
}
if (fullName != null) {
names.add(StringHelper.escapeHtml(fullName));
}
}
layoutCont.contextPut("names", names);
}
uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
uifactory.addFormSubmitButton("close.page", formLayout);
}
use of org.olat.basesecurity.Invitation in project openolat by klemens.
the class InvitationDAOTest method findInvitation_token.
@Test
public void findInvitation_token() {
Invitation invitation = invitationDao.createAndPersistInvitation();
Assert.assertNotNull(invitation);
dbInstance.commitAndCloseSession();
Invitation reloadedInvitation = invitationDao.findInvitation(invitation.getToken());
Assert.assertNotNull(reloadedInvitation);
Assert.assertNotNull(reloadedInvitation.getKey());
Assert.assertNotNull(reloadedInvitation.getBaseGroup());
Assert.assertEquals(invitation, reloadedInvitation);
Assert.assertEquals(invitation.getToken(), reloadedInvitation.getToken());
}
use of org.olat.basesecurity.Invitation in project openolat by klemens.
the class InvitationDAOTest method createIdentityFrom_invitation.
@Test
public void createIdentityFrom_invitation() {
Invitation invitation = invitationDao.createAndPersistInvitation();
String uuid = UUID.randomUUID().toString().replace("-", "");
invitation = invitationDao.update(invitation, "Clara", uuid, uuid + "@frentix.com");
dbInstance.commit();
// create the identity of the invitee
Identity invitee = invitationDao.createIdentityFrom(invitation, Locale.ENGLISH);
Assert.assertNotNull(invitee);
Assert.assertNotNull(invitee.getKey());
dbInstance.commitAndCloseSession();
// reload and check
Identity reloadIdentity = securityManager.loadIdentityByKey(invitee.getKey());
Assert.assertNotNull(reloadIdentity);
Assert.assertNotNull(reloadIdentity.getUser());
Assert.assertEquals(invitee.getKey(), reloadIdentity.getKey());
Assert.assertEquals("Clara", reloadIdentity.getUser().getFirstName());
Assert.assertEquals(uuid, reloadIdentity.getUser().getLastName());
Assert.assertEquals(uuid + "@frentix.com", reloadIdentity.getUser().getEmail());
}
Aggregations