use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory in project muikku by otavanopisto.
the class CommunicatorMessageCategoryDAO method findByName.
public CommunicatorMessageCategory findByName(String name) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<CommunicatorMessageCategory> criteria = criteriaBuilder.createQuery(CommunicatorMessageCategory.class);
Root<CommunicatorMessageCategory> root = criteria.from(CommunicatorMessageCategory.class);
criteria.select(root);
criteria.where(criteriaBuilder.equal(root.get(CommunicatorMessageCategory_.name), name));
return getSingleResult(entityManager.createQuery(criteria));
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory in project muikku by otavanopisto.
the class CommunicatorMessageCategoryDAO method create.
public CommunicatorMessageCategory create(String name) {
CommunicatorMessageCategory category = new CommunicatorMessageCategory();
category.setName(name);
getEntityManager().persist(category);
return category;
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory in project muikku by otavanopisto.
the class CommunicatorController method postMessage.
public CommunicatorMessage postMessage(UserEntity sender, String category, String subject, String content, List<UserEntity> recipients) {
CommunicatorMessageId communicatorMessageId = createMessageId();
// TODO Category not existing at this point would technically indicate an invalid state
CommunicatorMessageCategory categoryEntity = persistCategory(category);
return createMessage(communicatorMessageId, sender, recipients, null, null, null, categoryEntity, subject, content, null);
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory in project muikku by otavanopisto.
the class EvaluationRESTService method sendAssessmentNotification.
private void sendAssessmentNotification(WorkspaceEntity workspaceEntity, WorkspaceAssessment payload, UserEntity evaluator, UserEntity student, Workspace workspace, String grade) {
String workspaceUrl = String.format("%s/workspace/%s/materials", baseUrl, workspaceEntity.getUrlName());
Locale locale = userEntityController.getLocale(student);
CommunicatorMessageCategory category = communicatorController.persistCategory("assessments");
communicatorController.createMessage(communicatorController.createMessageId(), evaluator, Arrays.asList(student), null, null, null, category, localeController.getText(locale, "plugin.workspace.assessment.notificationTitle", new Object[] { workspace.getName(), grade }), localeController.getText(locale, "plugin.workspace.assessment.notificationContent", new Object[] { workspaceUrl, workspace.getName(), grade, payload.getVerbalAssessment() }), Collections.<Tag>emptySet());
}
use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory in project muikku by otavanopisto.
the class Evaluation2RESTService method sendAssessmentNotification.
private void sendAssessmentNotification(WorkspaceEntity workspaceEntity, WorkspaceAssessment workspaceAssessment, UserEntity evaluator, UserEntity student, Workspace workspace, String grade) {
String workspaceUrl = String.format("%s/workspace/%s/materials", baseUrl, workspaceEntity.getUrlName());
Locale locale = userEntityController.getLocale(student);
CommunicatorMessageCategory category = communicatorController.persistCategory("assessments");
CommunicatorMessage communicatorMessage = communicatorController.createMessage(communicatorController.createMessageId(), evaluator, Arrays.asList(student), null, null, null, category, localeController.getText(locale, "plugin.workspace.assessment.notificationTitle", new Object[] { workspace.getName(), grade }), localeController.getText(locale, "plugin.workspace.assessment.notificationContent", new Object[] { workspaceUrl, workspace.getName(), grade, workspaceAssessment.getVerbalAssessment() }), Collections.<Tag>emptySet());
communicatorMessageSentEvent.fire(new CommunicatorMessageSent(communicatorMessage.getId(), student.getId(), baseUrl));
}
Aggregations