Search in sources :

Example 1 with CommunicatorMessageCategory

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));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) CommunicatorMessageCategory(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory) EntityManager(javax.persistence.EntityManager)

Example 2 with CommunicatorMessageCategory

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;
}
Also used : CommunicatorMessageCategory(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory)

Example 3 with CommunicatorMessageCategory

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);
}
Also used : CommunicatorMessageCategory(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory) CommunicatorMessageId(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId)

Example 4 with CommunicatorMessageCategory

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());
}
Also used : Locale(java.util.Locale) CommunicatorMessageCategory(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory)

Example 5 with CommunicatorMessageCategory

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));
}
Also used : Locale(java.util.Locale) CommunicatorMessageCategory(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory) CommunicatorMessage(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage) CommunicatorMessageSent(fi.otavanopisto.muikku.plugins.communicator.events.CommunicatorMessageSent)

Aggregations

CommunicatorMessageCategory (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageCategory)9 CommunicatorMessageId (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId)4 Tag (fi.otavanopisto.muikku.model.base.Tag)3 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)3 UserGroupEntity (fi.otavanopisto.muikku.model.users.UserGroupEntity)3 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)3 CommunicatorMessage (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage)3 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)3 ArrayList (java.util.ArrayList)3 Locale (java.util.Locale)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 EntityTag (javax.ws.rs.core.EntityTag)2 UserGroupUserEntity (fi.otavanopisto.muikku.model.users.UserGroupUserEntity)1 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)1 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)1 CommunicatorMessageSent (fi.otavanopisto.muikku.plugins.communicator.events.CommunicatorMessageSent)1 Workspace (fi.otavanopisto.muikku.schooldata.entity.Workspace)1 HashMap (java.util.HashMap)1 EntityManager (javax.persistence.EntityManager)1