Search in sources :

Example 16 with DialogElement

use of org.olat.course.nodes.dialog.DialogElement in project OpenOLAT by OpenOLAT.

the class DialogElementsManagerTest method createDialogElement.

@Test
public void createDialogElement() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("session-1");
    String subIdent = UUID.randomUUID().toString();
    DialogElement element = dialogElementsManager.createDialogElement(entry, author, "task_d.txt", 234l, subIdent);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(element.getKey());
    Assert.assertNotNull(element.getForum());
    Assert.assertEquals(author, element.getAuthor());
    Assert.assertEquals("task_d.txt", element.getFilename());
    Assert.assertEquals(Long.valueOf(234l), element.getSize());
    Assert.assertEquals(subIdent, element.getSubIdent());
    Assert.assertEquals(entry, element.getEntry());
}
Also used : DialogElement(org.olat.course.nodes.dialog.DialogElement) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 17 with DialogElement

use of org.olat.course.nodes.dialog.DialogElement in project OpenOLAT by OpenOLAT.

the class DialogElementListEditController method loadModel.

protected void loadModel() {
    List<DialogElement> elements = dialogElementsManager.getDialogElements(entry, courseNode.getIdent());
    List<DialogElementRow> rows = new ArrayList<>(elements.size());
    for (DialogElement element : elements) {
        DialogElementRow row = new DialogElementRow(element, userPropertyHandlers, getLocale());
        VFSLeaf item = dialogElementsManager.getDialogLeaf(element);
        if (item != null) {
            DownloadLink downloadLink = uifactory.addDownloadLink("file_" + (++counter), row.getFilename(), null, item, flc);
            row.setDownloadLink(downloadLink);
        }
        rows.add(row);
    }
    tableModel.setObjects(rows);
    tableEl.reset(true, true, true);
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ArrayList(java.util.ArrayList) DialogElement(org.olat.course.nodes.dialog.DialogElement)

Example 18 with DialogElement

use of org.olat.course.nodes.dialog.DialogElement in project OpenOLAT by OpenOLAT.

the class DialogElementsEditController method doFinalizeUploadFile.

private void doFinalizeUploadFile(VFSLeaf file) {
    if (file == null)
        return;
    // everything when well so save the property
    DialogElement element = dialogElmsMgr.createDialogElement(entry, getIdentity(), file.getName(), file.getSize(), courseNode.getIdent());
    VFSContainer dialogContainer = dialogElmsMgr.getDialogContainer(element);
    VFSManager.copyContent(file.getParentContainer(), dialogContainer);
    // inform subscription manager about new element
    SubscriptionContext subsContext = CourseModule.createSubscriptionContext(courseEnv, courseNode);
    notificationsManager.markPublisherNews(subsContext, getIdentity(), true);
    ThreadLocalUserActivityLogger.log(CourseLoggingAction.DIALOG_ELEMENT_FILE_UPLOADED, getClass(), LoggingResourceable.wrapUploadFile(file.getName()));
    elementListCtrl.loadModel();
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) DialogElement(org.olat.course.nodes.dialog.DialogElement) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext)

Example 19 with DialogElement

use of org.olat.course.nodes.dialog.DialogElement in project OpenOLAT by OpenOLAT.

the class FileUploadNotificationHandler method createSubscriptionInfo.

/**
 * @see org.olat.core.commons.services.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.core.commons.services.notifications.Subscriber,
 *      java.util.Locale, java.util.Date)
 */
@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    Publisher p = subscriber.getPublisher();
    final Date latestNews = p.getLatestNewsDate();
    SubscriptionInfo si;
    // there could be news for me, investigate deeper
    try {
        if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
            RepositoryEntry re = repositoryManager.lookupRepositoryEntry(OresHelper.createOLATResourceableInstance(p.getResName(), p.getResId()), false);
            if (re == null) {
                if (!checkPublisher(subscriber.getPublisher())) {
                    return notificationsManager.getNoSubscriptionInfo();
                }
            } else if (re.getRepositoryEntryStatus().isClosed() || re.getRepositoryEntryStatus().isUnpublished()) {
                return notificationsManager.getNoSubscriptionInfo();
            }
            String displayname = re.getDisplayname();
            OLATResourceable ores = OresHelper.createOLATResourceableInstance("CourseModule", p.getResId());
            RepositoryEntry entry = repositoryManager.lookupRepositoryEntry(ores, false);
            List<DialogElement> dialogElements = dialogElementsMgr.getDialogElements(entry, p.getSubidentifier());
            final Translator translator = Util.createPackageTranslator(DialogCourseNodeRunController.class, locale);
            si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(translator.translate("notifications.header", new String[] { displayname }), CSSS_CLASS_UPLOAD_ICON), null);
            for (DialogElement element : dialogElements) {
                // do only show entries newer then the ones already seen
                if (element.getCreationDate().after(compareDate)) {
                    String filename = element.getFilename();
                    Identity author = element.getAuthor();
                    Date modDate = element.getCreationDate();
                    String[] params = new String[] { filename, NotificationHelper.getFormatedName(author) };
                    String desc = translator.translate("notifications.entry", params);
                    String businessPath = p.getBusinessPath() + "[Element:" + element.getKey() + "]";
                    String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
                    String cssClass = CSSHelper.createFiletypeIconCssClassFor(filename);
                    si.addSubscriptionListItem(new SubscriptionListItem(desc, urlToSend, businessPath, modDate, cssClass));
                }
            }
        } else {
            si = notificationsManager.getNoSubscriptionInfo();
        }
    } catch (Exception e) {
        log.error("Error creating file upload's notifications for subscriber: " + subscriber.getKey(), e);
        si = notificationsManager.getNoSubscriptionInfo();
    }
    return si;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) 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) Translator(org.olat.core.gui.translator.Translator) DialogElement(org.olat.course.nodes.dialog.DialogElement) Identity(org.olat.core.id.Identity)

Example 20 with DialogElement

use of org.olat.course.nodes.dialog.DialogElement in project OpenOLAT by OpenOLAT.

the class DialogCourseNodeRunController method activateByMessage.

private void activateByMessage(UserRequest ureq, List<ContextEntry> entries) {
    if (entries == null || entries.isEmpty())
        return;
    Long messageKey = entries.get(0).getOLATResourceable().getResourceableId();
    Message message = forumManager.getMessageById(messageKey);
    if (message == null)
        return;
    DialogElement element = dialogElmsMgr.getDialogElementByForum(message.getForum().getKey());
    if (!checkAccess(element)) {
        return;
    }
    dialogCtr = new DialogElementController(ureq, getWindowControl(), element, userCourseEnv, courseNode, nodeEvaluation);
    listenTo(dialogCtr);
    mainVC.put("forum", dialogCtr.getInitialComponent());
    // activate message
    dialogCtr.activate(ureq, entries, null);
}
Also used : Message(org.olat.modules.fo.Message) DialogElement(org.olat.course.nodes.dialog.DialogElement)

Aggregations

DialogElement (org.olat.course.nodes.dialog.DialogElement)36 RepositoryEntry (org.olat.repository.RepositoryEntry)14 Identity (org.olat.core.id.Identity)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)6 DialogElementsManager (org.olat.course.nodes.dialog.DialogElementsManager)6 Forum (org.olat.modules.fo.Forum)6 File (java.io.File)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)4 DownloadLink (org.olat.core.gui.components.form.flexible.elements.DownloadLink)4 Date (java.util.Date)2 Document (org.apache.lucene.document.Document)2 Publisher (org.olat.core.commons.services.notifications.Publisher)2 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2 TitleItem (org.olat.core.commons.services.notifications.model.TitleItem)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2