use of org.olat.commons.info.InfoMessage in project openolat by klemens.
the class InfoMessageFrontendManagerImpl method removeInfoMessagesAndSubscriptionContext.
@Override
public void removeInfoMessagesAndSubscriptionContext(BusinessGroup group) {
List<InfoMessage> messages = infoMessageManager.loadInfoMessageByResource(group, InfoMessageFrontendManager.businessGroupResSubPath, null, null, null, 0, 0);
List<String> pathToDelete = new ArrayList<>();
for (InfoMessage im : messages) {
infoMessageManager.deleteInfoMessage(im);
if (StringHelper.containsNonWhitespace(im.getAttachmentPath())) {
pathToDelete.add(im.getAttachmentPath());
}
}
String resName = group.getResourceableTypeName();
Long resId = group.getResourceableId();
SubscriptionContext subscriptionContext = new SubscriptionContext(resName, resId, "");
infoSubscriptionManager.deleteSubscriptionContext(subscriptionContext);
deleteAttachments(pathToDelete);
}
use of org.olat.commons.info.InfoMessage in project OpenOLAT by OpenOLAT.
the class GroupInfoIndexer method doIndexInfos.
private void doIndexInfos(SearchResourceContext parentResourceContext, BusinessGroup businessGroup, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
List<InfoMessage> messages = infoMessageManager.loadInfoMessageByResource(businessGroup, InfoMessageFrontendManager.businessGroupResSubPath, null, null, null, 0, -1);
for (InfoMessage message : messages) {
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
OLATResourceable ores = OresHelper.createOLATResourceableInstance(InfoMessage.class, message.getKey());
searchResourceContext.setBusinessControlFor(ores);
Document document = InfoMessageDocument.createDocument(searchResourceContext, message);
indexWriter.addDocument(document);
}
}
use of org.olat.commons.info.InfoMessage in project OpenOLAT by OpenOLAT.
the class InfoCourseNodeIndexer method doIndexInfos.
private void doIndexInfos(SearchResourceContext parentResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
List<InfoMessage> messages = infoMessageManager.loadInfoMessageByResource(course, courseNode.getIdent(), null, null, null, 0, -1);
for (InfoMessage message : messages) {
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
OLATResourceable ores = OresHelper.createOLATResourceableInstance(InfoMessage.class, message.getKey());
searchResourceContext.setBusinessControlFor(ores);
Document document = InfoMessageDocument.createDocument(searchResourceContext, message);
indexWriter.addDocument(document);
}
}
use of org.olat.commons.info.InfoMessage in project OpenOLAT by OpenOLAT.
the class InfoMessageNotificationHandler 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.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
try {
final Long resId = subscriber.getPublisher().getResId();
final String resName = subscriber.getPublisher().getResName();
String resSubPath = subscriber.getPublisher().getSubidentifier();
String displayName, notificationtitle;
if ("BusinessGroup".equals(resName)) {
BusinessGroupService groupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup group = groupService.loadBusinessGroup(resId);
displayName = group.getName();
notificationtitle = "notification.title.group";
} else {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(OresHelper.createOLATResourceableInstance(resName, resId), false);
if (re.getRepositoryEntryStatus().isClosed() || re.getRepositoryEntryStatus().isUnpublished()) {
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
displayName = re.getDisplayname();
notificationtitle = "notification.title";
}
Translator translator = Util.createPackageTranslator(this.getClass(), locale);
String title = translator.translate(notificationtitle, new String[] { displayName });
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(title, CSS_CLASS_ICON), null);
OLATResourceable ores = OresHelper.createOLATResourceableInstance(resName, resId);
List<InfoMessage> infos = infoMessageManager.loadInfoMessageByResource(ores, resSubPath, null, compareDate, null, 0, 0);
for (InfoMessage info : infos) {
Identity ident = info.getAuthor();
String desc = translator.translate("notifications.entry", new String[] { info.getTitle(), NotificationHelper.getFormatedName(ident) });
String tooltip = info.getMessage();
String infoBusinessPath = info.getBusinessPath() + "[InfoMessage:" + info.getKey() + "]";
String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(infoBusinessPath);
Date dateInfo = info.getModificationDate() == null ? info.getCreationDate() : info.getModificationDate();
SubscriptionListItem subListItem = new SubscriptionListItem(desc, tooltip, urlToSend, infoBusinessPath, dateInfo, CSS_CLASS_ICON);
si.addSubscriptionListItem(subListItem);
}
} catch (Exception e) {
log.error("Unexpected exception", e);
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
} else {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
}
use of org.olat.commons.info.InfoMessage in project OpenOLAT by OpenOLAT.
the class InfoMessageManagerImpl method loadInfoMessageByResource.
@Override
public List<InfoMessage> loadInfoMessageByResource(OLATResourceable ores, String subPath, String businessPath, Date after, Date before, int firstResult, int maxResults) {
DBQuery query = queryInfoMessageByResource(ores, subPath, businessPath, after, before, false);
if (firstResult >= 0) {
query.setFirstResult(firstResult);
}
if (maxResults > 0) {
query.setMaxResults(maxResults);
}
@SuppressWarnings("unchecked") List<InfoMessage> msgs = query.list();
return msgs;
}
Aggregations