Search in sources :

Example 6 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class UserSession method setIdentity.

/**
 * Sets the identity.
 *
 * @param identity The identity to set
 */
public void setIdentity(Identity identity) {
    identityEnvironment.setIdentity(identity);
    // fxdiff FXOLAT-231: event on GUI Preferences extern changes
    if (identity.getKey() != null) {
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(Preferences.class, identity.getKey());
        CoordinatorManager.getInstance().getCoordinator().getEventBus().deregisterFor(this, ores);
        CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, null, ores);
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable)

Example 7 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class MailListController method selectMail.

private void selectMail(UserRequest ureq, DBMail mail) {
    removeAsListenerAndDispose(mailCtr);
    boolean back = !StringHelper.containsNonWhitespace(mail.getMetaId()) || !outbox;
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(DBMail.class, mail.getKey());
    WindowControl bwControl = addToHistory(ureq, ores, null);
    mailCtr = new MailController(ureq, bwControl, mail, back, outbox);
    listenTo(mailCtr);
    mainVC.put(MAIN_CMP, mailCtr.getInitialComponent());
    if (mailManager.setRead(mail, Boolean.TRUE, getIdentity())) {
        reloadModel();
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) WindowControl(org.olat.core.gui.control.WindowControl)

Example 8 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class TreeHelper method findNodeByResourceableUserObject.

public static TreeNode findNodeByResourceableUserObject(OLATResourceable userObject, TreeNode node) {
    if (node.getUserObject() instanceof OLATResourceable && OresHelper.equals((OLATResourceable) node.getUserObject(), userObject)) {
        return node;
    }
    int childcnt = node.getChildCount();
    for (int i = 0; i < childcnt; i++) {
        TreeNode child = (TreeNode) node.getChildAt(i);
        TreeNode result = findNodeByUserObject(userObject, child);
        if (result != null)
            return result;
    }
    return null;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) TreeNode(org.olat.core.gui.components.tree.TreeNode)

Example 9 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class ModifyCourseEvent method clearCalenderSubscriptions.

/**
 * Checks all learning group calendars and the course calendar for publishers (of subscriptions)
 * and sets their state to "1" which indicates that the ressource is deleted.
 */
private static void clearCalenderSubscriptions(OLATResourceable res, ICourse course) {
    // set Publisher state to 1 (= ressource is deleted) for all calendars of the course
    CalendarManager calMan = CoreSpringFactory.getImpl(CalendarManager.class);
    CalendarNotificationManager notificationManager = CoreSpringFactory.getImpl(CalendarNotificationManager.class);
    NotificationsManager nfm = NotificationsManager.getInstance();
    if (course != null) {
        CourseGroupManager courseGroupManager = course.getCourseEnvironment().getCourseGroupManager();
        List<BusinessGroup> learningGroups = courseGroupManager.getAllBusinessGroups();
        // all learning and right group calendars
        for (BusinessGroup bg : learningGroups) {
            KalendarRenderWrapper calRenderWrapper = calMan.getGroupCalendar(bg);
            SubscriptionContext subsContext = notificationManager.getSubscriptionContext(calRenderWrapper);
            Publisher pub = nfm.getPublisher(subsContext);
            if (pub != null) {
                // int 0 is OK -> all other is not OK
                pub.setState(1);
            }
        }
    }
    // the course calendar
    try {
        /**
         * TODO:gs 2010-01-26
         * OLAT-4947: if we do not have an repo entry we get an exception here.
         * This is normal in the case of courseimport and click canceling.
         */
        KalendarRenderWrapper courseCalendar = calMan.getCalendarForDeletion(res);
        if (courseCalendar != null) {
            SubscriptionContext subContext = notificationManager.getSubscriptionContext(courseCalendar, res);
            OLATResourceable oresToDelete = OresHelper.createOLATResourceableInstance(subContext.getResName(), subContext.getResId());
            nfm.deletePublishersOf(oresToDelete);
        }
    } catch (AssertException e) {
    // if we have a broken course (e.g. canceled import or no repo entry somehow) skip calendar deletion...
    }
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) PersistingCourseGroupManager(org.olat.course.groupsandrights.PersistingCourseGroupManager) ImportToCalendarManager(org.olat.commons.calendar.manager.ImportToCalendarManager) CalendarManager(org.olat.commons.calendar.CalendarManager) CalendarNotificationManager(org.olat.commons.calendar.CalendarNotificationManager) AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) OLATResourceable(org.olat.core.id.OLATResourceable) NotificationsManager(org.olat.core.commons.services.notifications.NotificationsManager) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Publisher(org.olat.core.commons.services.notifications.Publisher) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 10 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class DisposedCourseRestartController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component,
 *      org.olat.core.gui.control.Event)
 */
@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == restartLink) {
        OLATResourceable ores = OLATResourceManager.getInstance().findResourceable(courseRepositoryEntry.getOlatResource().getResourceableId(), courseRepositoryEntry.getOlatResource().getResourceableTypeName());
        if (ores == null) {
            // course was deleted!
            MessageController msgController = MessageUIFactory.createInfoMessage(ureq, getWindowControl(), translate("course.deleted.title"), translate("course.deleted.text"));
            panel.setContent(msgController.getInitialComponent());
        } else {
            OLATResourceable reOres = OresHelper.clone(courseRepositoryEntry);
            DTabs dtabs = getWindowControl().getWindowBackOffice().getWindow().getDTabs();
            if (dtabs != null) {
                DTab dt = dtabs.getDTab(reOres);
                if (dt != null) {
                    dtabs.removeDTab(ureq, dt);
                }
            }
            List<ContextEntry> entries = null;
            List<HistoryPoint> stacks = ureq.getUserSession().getHistoryStack();
            for (int i = stacks.size(); i-- > 0; ) {
                HistoryPoint point = stacks.get(i);
                if (point != null && point.getEntries() != null && point.getEntries().size() > 0) {
                    ContextEntry entry = point.getEntries().get(0);
                    if (reOres.equals(entry.getOLATResourceable())) {
                        entries = point.getEntries();
                        break;
                    }
                }
            }
            WindowControl bwControl;
            if (entries == null) {
                bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(getWindowControl(), reOres);
            } else {
                BusinessControl bc = BusinessControlFactory.getInstance().createFromContextEntries(entries);
                bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
            }
            NewControllerFactory.getInstance().launch(ureq, bwControl);
            dispose();
        }
    }
}
Also used : DTab(org.olat.core.gui.control.generic.dtabs.DTab) MessageController(org.olat.core.gui.control.generic.messages.MessageController) OLATResourceable(org.olat.core.id.OLATResourceable) DTabs(org.olat.core.gui.control.generic.dtabs.DTabs) BusinessControl(org.olat.core.id.context.BusinessControl) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) HistoryPoint(org.olat.core.id.context.HistoryPoint) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Aggregations

OLATResourceable (org.olat.core.id.OLATResourceable)924 WindowControl (org.olat.core.gui.control.WindowControl)304 Test (org.junit.Test)158 Identity (org.olat.core.id.Identity)154 RepositoryEntry (org.olat.repository.RepositoryEntry)130 ContextEntry (org.olat.core.id.context.ContextEntry)82 ArrayList (java.util.ArrayList)68 OLATResource (org.olat.resource.OLATResource)60 Controller (org.olat.core.gui.control.Controller)48 Date (java.util.Date)46 AssertException (org.olat.core.logging.AssertException)32 StateSite (org.olat.core.id.context.StateSite)30 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)30 ICourse (org.olat.course.ICourse)30 CourseNode (org.olat.course.nodes.CourseNode)28 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)28 BusinessControl (org.olat.core.id.context.BusinessControl)24 BusinessGroup (org.olat.group.BusinessGroup)24 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)22 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)22