Search in sources :

Example 21 with Invitation

use of org.olat.basesecurity.Invitation in project openolat by klemens.

the class InvitationDAOTest method findInvitation_group.

@Test
public void findInvitation_group() {
    Invitation invitation = invitationDao.createAndPersistInvitation();
    Group baseGroup = invitation.getBaseGroup();
    Assert.assertNotNull(invitation);
    dbInstance.commitAndCloseSession();
    Invitation reloadedInvitation = invitationDao.findInvitation(baseGroup);
    Assert.assertNotNull(reloadedInvitation);
    Assert.assertNotNull(reloadedInvitation.getKey());
    Assert.assertEquals(baseGroup, reloadedInvitation.getBaseGroup());
    Assert.assertEquals(invitation, reloadedInvitation);
    Assert.assertEquals(invitation.getToken(), reloadedInvitation.getToken());
}
Also used : Group(org.olat.basesecurity.Group) Invitation(org.olat.basesecurity.Invitation) Test(org.junit.Test)

Example 22 with Invitation

use of org.olat.basesecurity.Invitation in project openolat by klemens.

the class InvitationDAOTest method loadOrCreateIdentityAndPersistInvitation.

@Test
public void loadOrCreateIdentityAndPersistInvitation() {
    Invitation invitation = invitationDao.createAndPersistInvitation();
    String uuid = UUID.randomUUID().toString().replace("-", "");
    invitation = invitationDao.update(invitation, "Flora", uuid, uuid + "@frentix.com");
    Group group = groupDao.createGroup();
    dbInstance.commit();
    // use the create part of the method
    Identity identity = invitationDao.loadOrCreateIdentityAndPersistInvitation(invitation, group, Locale.ENGLISH);
    Assert.assertNotNull(identity);
    Assert.assertNotNull(identity.getKey());
    dbInstance.commitAndCloseSession();
    // reload and check
    Identity reloadIdentity = securityManager.loadIdentityByKey(identity.getKey());
    Assert.assertNotNull(reloadIdentity);
    Assert.assertNotNull(reloadIdentity.getUser());
    Assert.assertEquals(identity.getKey(), reloadIdentity.getKey());
    Assert.assertEquals("Flora", reloadIdentity.getUser().getFirstName());
    Assert.assertEquals(uuid, reloadIdentity.getUser().getLastName());
    Assert.assertEquals(uuid + "@frentix.com", reloadIdentity.getUser().getEmail());
}
Also used : Group(org.olat.basesecurity.Group) Invitation(org.olat.basesecurity.Invitation) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 23 with Invitation

use of org.olat.basesecurity.Invitation in project openolat by klemens.

the class InvitationDAOTest method createAndPersistInvitation.

@Test
public void createAndPersistInvitation() {
    Invitation invitation = invitationDao.createAndPersistInvitation();
    Assert.assertNotNull(invitation);
    dbInstance.commit();
    Assert.assertNotNull(invitation);
    Assert.assertNotNull(invitation.getKey());
    Assert.assertNotNull(invitation.getBaseGroup());
    Assert.assertNotNull(invitation.getToken());
}
Also used : Invitation(org.olat.basesecurity.Invitation) Test(org.junit.Test)

Example 24 with Invitation

use of org.olat.basesecurity.Invitation in project openolat by klemens.

the class EPPolicyManager method applyPolicy.

private List<EPStructureElementToGroupRelation> applyPolicy(EPMapPolicy policy, PortfolioStructureMap map) {
    List<EPStructureElementToGroupRelation> savedPolicies = new ArrayList<EPStructureElementToGroupRelation>();
    switch(policy.getType()) {
        case user:
            savedPolicies.add(applyPolicyToUsers(policy, map));
            break;
        case group:
            for (BusinessGroup group : policy.getGroups()) {
                savedPolicies.add(applyPolicyToGroup(group.getBaseGroup(), policy, map));
            }
            break;
        case invitation:
            Invitation invitation = policy.getInvitation();
            EPStructureElementToGroupRelation invitationPolicy = applyPolicyToInvitation(invitation, policy, map);
            savedPolicies.add(invitationPolicy);
            break;
        case allusers:
            EPStructureElementToGroupRelation allUsersPolicy = applyPolicyToAllUsers(policy, map);
            savedPolicies.add(allUsersPolicy);
            break;
    }
    return savedPolicies;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) Invitation(org.olat.basesecurity.Invitation) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)

Example 25 with Invitation

use of org.olat.basesecurity.Invitation in project openolat by klemens.

the class InvitationDAO method deleteInvitation.

/**
 * Delete an invitation
 * @param invitation
 */
public void deleteInvitation(Invitation invitation) {
    if (invitation == null || invitation.getKey() == null)
        return;
    Invitation refInvitation = dbInstance.getCurrentEntityManager().getReference(InvitationImpl.class, invitation.getKey());
    dbInstance.getCurrentEntityManager().remove(refInvitation);
}
Also used : Invitation(org.olat.basesecurity.Invitation)

Aggregations

Invitation (org.olat.basesecurity.Invitation)48 Identity (org.olat.core.id.Identity)26 ArrayList (java.util.ArrayList)24 Test (org.junit.Test)22 AccessRights (org.olat.modules.portfolio.model.AccessRights)14 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)8 BusinessGroup (org.olat.group.BusinessGroup)6 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)6 Group (org.olat.basesecurity.Group)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 EPStructureElementToGroupRelation (org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)4 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)4 Calendar (java.util.Calendar)2 Date (java.util.Date)2 SecurityGroup (org.olat.basesecurity.SecurityGroup)2 DateChooser (org.olat.core.gui.components.form.flexible.elements.DateChooser)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)2 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)2