Search in sources :

Example 1 with TaskExecutorManager

use of org.olat.core.commons.services.taskexecutor.TaskExecutorManager in project OpenOLAT by OpenOLAT.

the class BulkAssessmentTask method sendFeedback.

private void sendFeedback(List<BulkAssessmentFeedback> feedbacks) {
    if (task == null) {
        log.error("Haven't a task to know creator and modifiers of the task", null);
        return;
    }
    Identity creator = task.getCreator();
    String language = creator.getUser().getPreferences().getLanguage();
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(language);
    Translator translator = Util.createPackageTranslator(BulkAssessmentOverviewController.class, locale, Util.createPackageTranslator(AssessmentManager.class, locale));
    MailManager mailManager = CoreSpringFactory.getImpl(MailManager.class);
    TaskExecutorManager taskManager = CoreSpringFactory.getImpl(TaskExecutorManager.class);
    String feedbackStr = renderFeedback(feedbacks, translator);
    MailBundle mail = new MailBundle();
    mail.setToId(creator);
    mail.setFrom(WebappHelper.getMailConfig("mailReplyTo"));
    List<Identity> modifiers = taskManager.getModifiers(task);
    if (modifiers.size() > 0) {
        ContactList cc = new ContactList("CC");
        cc.addAllIdentites(modifiers);
        mail.setContactList(cc);
    }
    String businessPath = "";
    ICourse course = CourseFactory.loadCourse(courseRes);
    CourseNode node = course.getRunStructure().getNode(courseNodeIdent);
    String courseTitle = course.getCourseTitle();
    String nodeTitle = node.getShortTitle();
    String numOfAssessedIds = Integer.toString(datas == null ? 0 : datas.getRowsSize());
    String date = Formatter.getInstance(locale).formatDateAndTime(new Date());
    mail.setContext(new MailContextImpl(courseRes, courseNodeIdent, businessPath));
    String subject = translator.translate("confirmation.mail.subject", new String[] { courseTitle, nodeTitle });
    String body = translator.translate("confirmation.mail.body", new String[] { courseTitle, nodeTitle, feedbackStr, numOfAssessedIds, date });
    mail.setContent(subject, body);
    mailManager.sendMessage(mail);
}
Also used : Locale(java.util.Locale) TaskExecutorManager(org.olat.core.commons.services.taskexecutor.TaskExecutorManager) MailContextImpl(org.olat.core.util.mail.MailContextImpl) AssessmentManager(org.olat.course.assessment.AssessmentManager) ICourse(org.olat.course.ICourse) ContactList(org.olat.core.util.mail.ContactList) Date(java.util.Date) Translator(org.olat.core.gui.translator.Translator) MailManager(org.olat.core.util.mail.MailManager) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) ProjectBrokerCourseNode(org.olat.course.nodes.ProjectBrokerCourseNode) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle)

Example 2 with TaskExecutorManager

use of org.olat.core.commons.services.taskexecutor.TaskExecutorManager in project openolat by klemens.

the class BulkAssessmentTask method sendFeedback.

private void sendFeedback(List<BulkAssessmentFeedback> feedbacks) {
    if (task == null) {
        log.error("Haven't a task to know creator and modifiers of the task", null);
        return;
    }
    Identity creator = task.getCreator();
    String language = creator.getUser().getPreferences().getLanguage();
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(language);
    Translator translator = Util.createPackageTranslator(BulkAssessmentOverviewController.class, locale, Util.createPackageTranslator(AssessmentManager.class, locale));
    MailManager mailManager = CoreSpringFactory.getImpl(MailManager.class);
    TaskExecutorManager taskManager = CoreSpringFactory.getImpl(TaskExecutorManager.class);
    String feedbackStr = renderFeedback(feedbacks, translator);
    MailBundle mail = new MailBundle();
    mail.setToId(creator);
    mail.setFrom(WebappHelper.getMailConfig("mailReplyTo"));
    List<Identity> modifiers = taskManager.getModifiers(task);
    if (modifiers.size() > 0) {
        ContactList cc = new ContactList("CC");
        cc.addAllIdentites(modifiers);
        mail.setContactList(cc);
    }
    String businessPath = "";
    ICourse course = CourseFactory.loadCourse(courseRes);
    CourseNode node = course.getRunStructure().getNode(courseNodeIdent);
    String courseTitle = course.getCourseTitle();
    String nodeTitle = node.getShortTitle();
    String numOfAssessedIds = Integer.toString(datas == null ? 0 : datas.getRowsSize());
    String date = Formatter.getInstance(locale).formatDateAndTime(new Date());
    mail.setContext(new MailContextImpl(courseRes, courseNodeIdent, businessPath));
    String subject = translator.translate("confirmation.mail.subject", new String[] { courseTitle, nodeTitle });
    String body = translator.translate("confirmation.mail.body", new String[] { courseTitle, nodeTitle, feedbackStr, numOfAssessedIds, date });
    mail.setContent(subject, body);
    mailManager.sendMessage(mail);
}
Also used : Locale(java.util.Locale) TaskExecutorManager(org.olat.core.commons.services.taskexecutor.TaskExecutorManager) MailContextImpl(org.olat.core.util.mail.MailContextImpl) AssessmentManager(org.olat.course.assessment.AssessmentManager) ICourse(org.olat.course.ICourse) ContactList(org.olat.core.util.mail.ContactList) Date(java.util.Date) Translator(org.olat.core.gui.translator.Translator) MailManager(org.olat.core.util.mail.MailManager) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) ProjectBrokerCourseNode(org.olat.course.nodes.ProjectBrokerCourseNode) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle)

Example 3 with TaskExecutorManager

use of org.olat.core.commons.services.taskexecutor.TaskExecutorManager in project OpenOLAT by OpenOLAT.

the class OpenOLATServlet method preWarm.

private void preWarm() {
    TaskExecutorManager executor = CoreSpringFactory.getImpl(TaskExecutorManager.class);
    Map<String, PreWarm> preWarms = CoreSpringFactory.getBeansOfType(PreWarm.class);
    for (PreWarm preWarm : preWarms.values()) {
        executor.execute(preWarm);
    }
}
Also used : TaskExecutorManager(org.olat.core.commons.services.taskexecutor.TaskExecutorManager) PreWarm(org.olat.core.configuration.PreWarm)

Example 4 with TaskExecutorManager

use of org.olat.core.commons.services.taskexecutor.TaskExecutorManager in project openolat by klemens.

the class OpenOLATServlet method preWarm.

private void preWarm() {
    TaskExecutorManager executor = CoreSpringFactory.getImpl(TaskExecutorManager.class);
    Map<String, PreWarm> preWarms = CoreSpringFactory.getBeansOfType(PreWarm.class);
    for (PreWarm preWarm : preWarms.values()) {
        executor.execute(preWarm);
    }
}
Also used : TaskExecutorManager(org.olat.core.commons.services.taskexecutor.TaskExecutorManager) PreWarm(org.olat.core.configuration.PreWarm)

Aggregations

TaskExecutorManager (org.olat.core.commons.services.taskexecutor.TaskExecutorManager)4 Date (java.util.Date)2 Locale (java.util.Locale)2 PreWarm (org.olat.core.configuration.PreWarm)2 Translator (org.olat.core.gui.translator.Translator)2 Identity (org.olat.core.id.Identity)2 ContactList (org.olat.core.util.mail.ContactList)2 MailBundle (org.olat.core.util.mail.MailBundle)2 MailContextImpl (org.olat.core.util.mail.MailContextImpl)2 MailManager (org.olat.core.util.mail.MailManager)2 ICourse (org.olat.course.ICourse)2 AssessmentManager (org.olat.course.assessment.AssessmentManager)2 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)2 CourseNode (org.olat.course.nodes.CourseNode)2 GTACourseNode (org.olat.course.nodes.GTACourseNode)2 MSCourseNode (org.olat.course.nodes.MSCourseNode)2 ProjectBrokerCourseNode (org.olat.course.nodes.ProjectBrokerCourseNode)2 TACourseNode (org.olat.course.nodes.TACourseNode)2