Search in sources :

Example 1 with AccessRights

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

the class PortfolioAssessmentDetailsController method loadModel.

private void loadModel(UserRequest ureq, Binder loadedBinder) {
    if (loadedBinder == null) {
        mainVC.contextPut("noMap", Boolean.TRUE);
    } else {
        Formatter formatter = Formatter.getInstance(getLocale());
        String templateTitle = loadedBinder.getTemplate().getTitle();
        mainVC.contextPut("templateTitle", templateTitle);
        String copyDate = "";
        if (loadedBinder.getCopyDate() != null) {
            copyDate = formatter.formatDateAndTime(loadedBinder.getCopyDate());
        }
        mainVC.contextPut("copyDate", copyDate);
        String returnDate = "";
        if (loadedBinder.getReturnDate() != null) {
            returnDate = formatter.formatDateAndTime(loadedBinder.getReturnDate());
        }
        mainVC.contextPut("returnDate", returnDate);
        List<AccessRights> rights = portfolioService.getAccessRights(loadedBinder, getIdentity());
        BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCourseCoach(loadedBinder, rights);
        BinderConfiguration config = BinderConfiguration.createConfig(loadedBinder);
        assessmentCtrl = new BinderAssessmentController(ureq, getWindowControl(), secCallback, loadedBinder, config);
        listenTo(assessmentCtrl);
        mainVC.put("assessment", assessmentCtrl.getInitialComponent());
    }
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) Formatter(org.olat.core.util.Formatter) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration)

Example 2 with AccessRights

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

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

Example 3 with AccessRights

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

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

Example 4 with AccessRights

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

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

Example 5 with AccessRights

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

the class PortfolioNotificationsHandler method createSubscriptionInfo.

@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher publisher = subscriber.getPublisher();
    Binder binder = binderDao.loadByKey(publisher.getResId());
    if (isInkoveValid(binder, compareDate, publisher)) {
        BinderSecurityCallback secCallback = null;
        Identity identity = subscriber.getIdentity();
        if (binderDao.isMember(binder, identity, PortfolioRoles.owner.name())) {
            secCallback = BinderSecurityCallbackFactory.getCallbackForOwnedBinder(binder);
        } else {
            List<AccessRights> rights = portfolioService.getAccessRights(binder, identity);
            if (rights.size() > 0) {
                secCallback = BinderSecurityCallbackFactory.getCallbackForCoach(binder, rights);
            }
        }
        if (secCallback != null) {
            si = new SubscriptionInfo(subscriber.getKey(), publisher.getType(), getTitleItemForBinder(binder), null);
            List<SubscriptionListItem> allItems = getAllItems(binder, secCallback, compareDate, locale);
            for (SubscriptionListItem item : allItems) {
                // only a type of icon
                SubscriptionListItem clonedItem = new SubscriptionListItem(item.getDescription(), item.getDescriptionTooltip(), item.getLink(), item.getBusinessPath(), item.getDate(), "o_ep_icon");
                si.addSubscriptionListItem(clonedItem);
            }
        }
    }
    if (si == null) {
        // no info, return empty
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
    return si;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) Binder(org.olat.modules.portfolio.Binder) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) Publisher(org.olat.core.commons.services.notifications.Publisher) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) 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