Search in sources :

Example 21 with OLATResourceable

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

the class CertificateAndEfficiencyStatementController method doOpenGroup.

private void doOpenGroup(UserRequest ureq) {
    if (businessGroup != null) {
        List<ContextEntry> ces = new ArrayList<ContextEntry>(1);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance("BusinessGroup", businessGroup.getKey());
        ces.add(BusinessControlFactory.getInstance().createContextEntry(ores));
        BusinessControl bc = BusinessControlFactory.getInstance().createFromContextEntries(ces);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
        NewControllerFactory.getInstance().launch(ureq, bwControl);
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) BusinessControl(org.olat.core.id.context.BusinessControl) ArrayList(java.util.ArrayList) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 22 with OLATResourceable

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

the class DENManager method createKalendarEventLinks.

private void createKalendarEventLinks(ICourse course, DENCourseNode courseNode, KalendarEvent event) {
    List<KalendarEventLink> kalendarEventLinks = event.getKalendarEventLinks();
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
    OLATResourceable oresNode = OresHelper.createOLATResourceableInstance("CourseNode", Long.valueOf(courseNode.getIdent()));
    List<ContextEntry> ces = new ArrayList<ContextEntry>();
    ces.add(BusinessControlFactory.getInstance().createContextEntry(re));
    ces.add(BusinessControlFactory.getInstance().createContextEntry(oresNode));
    String extLink = BusinessControlFactory.getInstance().getAsURIString(ces, false);
    String iconCssClass = CourseNodeFactory.getInstance().getCourseNodeConfiguration(courseNode.getType()).getIconCSSClass();
    KalendarEventLink link = new KalendarEventLink("COURSE", courseNode.getIdent(), courseNode.getShortTitle(), extLink, iconCssClass);
    kalendarEventLinks.clear();
    kalendarEventLinks.add(link);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink) RepositoryEntry(org.olat.repository.RepositoryEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 23 with OLATResourceable

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

the class LockController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            LockEntry lockToRelease = locksTableModel.getObject(te.getRowId());
            dialogController = activateYesNoDialog(ureq, null, translate("lock.release.sure"), dialogController);
            dialogController.setUserObject(lockToRelease);
        }
    } else if (source == dialogController) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            LockEntry lockToRelease = (LockEntry) dialogController.getUserObject();
            MultiUserEvent mue = new LockRemovedEvent(lockToRelease);
            OLATResourceable lockEntryOres = OresHelper.createOLATResourceableInstance(LockEntry.class, 0l);
            CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(mue, lockEntryOres);
            CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLockEntry(lockToRelease);
            lockToRelease = null;
            resetTableModel();
        }
    }
}
Also used : LockRemovedEvent(org.olat.core.util.coordinate.LockRemovedEvent) TableEvent(org.olat.core.gui.components.table.TableEvent) LockEntry(org.olat.core.util.coordinate.LockEntry) OLATResourceable(org.olat.core.id.OLATResourceable) MultiUserEvent(org.olat.core.util.event.MultiUserEvent)

Example 24 with OLATResourceable

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

the class AdminSite method createController.

@Override
protected MainLayoutController createController(UserRequest ureq, WindowControl wControl, SiteConfiguration config) {
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(AdminSite.class, 0l);
    ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, ores, new StateSite(this), wControl, true);
    return new SystemAdminMainController(ureq, bwControl);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) StateSite(org.olat.core.id.context.StateSite) SystemAdminMainController(org.olat.admin.SystemAdminMainController) WindowControl(org.olat.core.gui.control.WindowControl)

Example 25 with OLATResourceable

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

the class CalendarNotificationHandler method createSubscriptionInfo.

@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    Date latestNews = p.getLatestNewsDate();
    // can't be loaded when already deleted
    if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
        Long id = p.getResId();
        String type = p.getSubidentifier();
        try {
            Translator translator = Util.createPackageTranslator(CalendarModule.class, locale);
            String calType = null;
            String title = null;
            if (type.equals(CalendarController.ACTION_CALENDAR_COURSE)) {
                RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(OresHelper.createOLATResourceableInstance("CourseModule", id), false);
                if (re.getRepositoryEntryStatus().isClosed() || re.getRepositoryEntryStatus().isUnpublished()) {
                    return NotificationsManager.getInstance().getNoSubscriptionInfo();
                }
                String displayName = re.getDisplayname();
                calType = CalendarManager.TYPE_COURSE;
                title = translator.translate("cal.notifications.header.course", new String[] { displayName });
            } else if (type.equals(CalendarController.ACTION_CALENDAR_GROUP)) {
                BusinessGroup group = businessGroupDao.load(id);
                calType = CalendarManager.TYPE_GROUP;
                if (group == null) {
                    return notificationsManager.getNoSubscriptionInfo();
                }
                title = translator.translate("cal.notifications.header.group", new String[] { group.getName() });
            }
            if (calType != null) {
                Formatter form = Formatter.getInstance(locale);
                si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(title, CSS_CLASS_CALENDAR_ICON), null);
                String bPath;
                if (StringHelper.containsNonWhitespace(p.getBusinessPath())) {
                    bPath = p.getBusinessPath();
                } else if ("CalendarManager.course".equals(p.getResName())) {
                    try {
                        OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.getCourseTypeName(), p.getResId());
                        RepositoryEntry re = repositoryManager.lookupRepositoryEntry(ores, true);
                        // Fallback
                        bPath = "[RepositoryEntry:" + re.getKey() + "]";
                    } catch (Exception e) {
                        log.error("Error processing calendar notifications of publisher:" + p.getKey(), e);
                        return notificationsManager.getNoSubscriptionInfo();
                    }
                } else {
                    // cannot make link without business path
                    return notificationsManager.getNoSubscriptionInfo();
                }
                Kalendar cal = calendarManager.getCalendar(calType, id.toString());
                Collection<KalendarEvent> calEvents = cal.getEvents();
                for (KalendarEvent kalendarEvent : calEvents) {
                    if (showEvent(compareDate, kalendarEvent)) {
                        log.debug("found a KalendarEvent: " + kalendarEvent.getSubject() + " with time: " + kalendarEvent.getBegin() + " modified before: " + compareDate.toString(), null);
                        // found a modified event in this calendar
                        Date modDate = null;
                        if (kalendarEvent.getLastModified() > 0) {
                            modDate = new Date(kalendarEvent.getLastModified());
                        } else if (kalendarEvent.getCreated() > 0) {
                            modDate = new Date(kalendarEvent.getCreated());
                        } else if (kalendarEvent.getBegin() != null) {
                            modDate = kalendarEvent.getBegin();
                        }
                        String subject = kalendarEvent.getSubject();
                        String author = kalendarEvent.getCreatedBy();
                        if (author == null)
                            author = "";
                        String location = "";
                        if (StringHelper.containsNonWhitespace(kalendarEvent.getLocation())) {
                            location = kalendarEvent.getLocation() == null ? "" : translator.translate("cal.notifications.location", new String[] { kalendarEvent.getLocation() });
                        }
                        String dateStr;
                        if (kalendarEvent.isAllDayEvent()) {
                            dateStr = form.formatDate(kalendarEvent.getBegin());
                        } else {
                            dateStr = form.formatDate(kalendarEvent.getBegin()) + " - " + form.formatDate(kalendarEvent.getEnd());
                        }
                        String desc = translator.translate("cal.notifications.entry", new String[] { subject, dateStr, location, author });
                        String businessPath = bPath + "[path=" + kalendarEvent.getID() + ":0]";
                        String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
                        SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, modDate, CSS_CLASS_CALENDAR_ICON);
                        si.addSubscriptionListItem(subListItem);
                    }
                }
            }
        } catch (Exception e) {
            log.error("Unexpected exception", e);
            checkPublisher(p);
            si = notificationsManager.getNoSubscriptionInfo();
        }
    } else {
        si = notificationsManager.getNoSubscriptionInfo();
    }
    return si;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) OLATResourceable(org.olat.core.id.OLATResourceable) Formatter(org.olat.core.util.Formatter) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) Publisher(org.olat.core.commons.services.notifications.Publisher) RepositoryEntry(org.olat.repository.RepositoryEntry) TitleItem(org.olat.core.commons.services.notifications.model.TitleItem) Date(java.util.Date) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Kalendar(org.olat.commons.calendar.model.Kalendar) Translator(org.olat.core.gui.translator.Translator)

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