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());
}
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);
}
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();
}
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;
}
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);
}
Aggregations