Search in sources :

Example 6 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

the class PortfolioServiceTest method binderAndSectionAndPageAccessRights.

@Test
public void binderAndSectionAndPageAccessRights() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-3");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-4");
    Identity reviewer = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-5");
    String title = "My published binder";
    String summary = "My live";
    Binder binder = portfolioService.createNewBinder(title, summary, null, owner);
    dbInstance.commit();
    portfolioService.appendNewSection("Section", "Coached section", null, null, binder);
    dbInstance.commit();
    List<Section> sections = portfolioService.getSections(binder);
    Section section = sections.get(0);
    portfolioService.appendNewPage(owner, "Reviewed page", "", null, null, section);
    portfolioService.addAccessRights(section, coach, PortfolioRoles.coach);
    dbInstance.commit();
    List<Page> pages = portfolioService.getPages(section);
    Page page = pages.get(0);
    portfolioService.addAccessRights(page, reviewer, PortfolioRoles.reviewer);
    // load right
    List<AccessRights> rights = portfolioService.getAccessRights(binder);
    Assert.assertNotNull(rights);
    Assert.assertEquals(4, rights.size());
    boolean foundOwner = false;
    boolean foundCoach = false;
    boolean foundReviewer = false;
    for (AccessRights right : rights) {
        if (PortfolioRoles.owner.equals(right.getRole()) && owner.equals(right.getIdentity())) {
            foundOwner = true;
        } else if (PortfolioRoles.coach.equals(right.getRole()) && coach.equals(right.getIdentity())) {
            foundCoach = true;
        } else if (PortfolioRoles.reviewer.equals(right.getRole()) && reviewer.equals(right.getIdentity())) {
            foundReviewer = true;
        }
    }
    Assert.assertTrue(foundOwner);
    Assert.assertTrue(foundCoach);
    Assert.assertTrue(foundReviewer);
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 7 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

the class PortfolioResultDetailsController method doOpenMap.

private void doOpenMap(UserRequest ureq, Binder binder) {
    if (stackPanel instanceof TooledStackedPanel) {
        binder = portfolioService.getBinderByKey(binder.getKey());
        portfolioService.updateBinderUserInformations(binder, getIdentity());
        List<AccessRights> rights = portfolioService.getAccessRights(binder, getIdentity());
        BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCourseCoach(binder, rights);
        BinderConfiguration config = BinderConfiguration.createConfig(binder);
        BinderController binderCtrl = new BinderController(ureq, getWindowControl(), (TooledStackedPanel) stackPanel, secCallback, binder, config);
        String displayName = StringHelper.escapeHtml(binder.getTitle());
        stackPanel.pushController(displayName, binderCtrl);
        binderCtrl.activate(ureq, null, null);
    }
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) BinderController(org.olat.modules.portfolio.ui.BinderController) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration)

Example 8 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.

the class SharedBindersController method doSelectBinder.

private BinderController doSelectBinder(UserRequest ureq, SharedItemRow row) {
    Binder binder = portfolioService.getBinderByKey(row.getBinderKey());
    if (binder == null) {
        showWarning("warning.portfolio.not.found");
        return null;
    } else {
        removeAsListenerAndDispose(binderCtrl);
        portfolioService.updateBinderUserInformations(binder, getIdentity());
        row.setRecentLaunch(new Date());
        OLATResourceable binderOres = OresHelper.createOLATResourceableInstance("Binder", binder.getKey());
        WindowControl swControl = addToHistory(ureq, binderOres, null);
        List<AccessRights> rights = portfolioService.getAccessRights(binder, getIdentity());
        BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCoach(binder, rights);
        BinderConfiguration config = BinderConfiguration.createConfig(binder);
        binderCtrl = new BinderController(ureq, swControl, stackPanel, secCallback, binder, config);
        String displayName = StringHelper.escapeHtml(binder.getTitle());
        stackPanel.pushController(displayName, binderCtrl);
        return binderCtrl;
    }
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) Binder(org.olat.modules.portfolio.Binder) OLATResourceable(org.olat.core.id.OLATResourceable) BinderController(org.olat.modules.portfolio.ui.BinderController) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) WindowControl(org.olat.core.gui.control.WindowControl) Date(java.util.Date) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration)

Example 9 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.

the class PortfolioResultDetailsController method doOpenMap.

private void doOpenMap(UserRequest ureq, Binder binder) {
    if (stackPanel instanceof TooledStackedPanel) {
        binder = portfolioService.getBinderByKey(binder.getKey());
        portfolioService.updateBinderUserInformations(binder, getIdentity());
        List<AccessRights> rights = portfolioService.getAccessRights(binder, getIdentity());
        BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCourseCoach(binder, rights);
        BinderConfiguration config = BinderConfiguration.createConfig(binder);
        BinderController binderCtrl = new BinderController(ureq, getWindowControl(), (TooledStackedPanel) stackPanel, secCallback, binder, config);
        String displayName = StringHelper.escapeHtml(binder.getTitle());
        stackPanel.pushController(displayName, binderCtrl);
        binderCtrl.activate(ureq, null, null);
    }
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) BinderController(org.olat.modules.portfolio.ui.BinderController) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration)

Example 10 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights 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;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) ArrayList(java.util.ArrayList) Invitation(org.olat.basesecurity.Invitation) Identity(org.olat.core.id.Identity)

Aggregations

AccessRights (org.olat.modules.portfolio.model.AccessRights)38 Identity (org.olat.core.id.Identity)24 ArrayList (java.util.ArrayList)16 Invitation (org.olat.basesecurity.Invitation)14 Binder (org.olat.modules.portfolio.Binder)12 Page (org.olat.modules.portfolio.Page)12 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)10 Test (org.junit.Test)6 Controller (org.olat.core.gui.control.Controller)6 BinderConfiguration (org.olat.modules.portfolio.BinderConfiguration)6 Section (org.olat.modules.portfolio.Section)6 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)6 WindowControl (org.olat.core.gui.control.WindowControl)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 EvaluationFormController (org.olat.modules.forms.ui.EvaluationFormController)4 PortfolioService (org.olat.modules.portfolio.PortfolioService)4 BinderController (org.olat.modules.portfolio.ui.BinderController)4 MultiEvaluationFormController (org.olat.modules.portfolio.ui.MultiEvaluationFormController)4 PortfolioHomeController (org.olat.modules.portfolio.ui.PortfolioHomeController)4 Date (java.util.Date)2