use of de.symeda.sormas.api.task.TaskContext in project SORMAS-Project by hzi-braunschweig.
the class TaskFacadeEjb method notifyAboutNewAssignee.
private void notifyAboutNewAssignee(Task task, User newAssignee, User oldAssignee) {
// oldAssignee == null => it means it's a new task, this notification should only be sent in case the assignee is changed
if (oldAssignee == null || Objects.equals(newAssignee, oldAssignee)) {
return;
}
try {
final TaskContext context = task.getTaskContext();
final AbstractDomainObject associatedEntity = context == TaskContext.CASE ? task.getCaze() : context == TaskContext.CONTACT ? task.getContact() : context == TaskContext.EVENT ? task.getEvent() : null;
Map<User, String> userMessages = new HashMap<>();
userMessages.put(oldAssignee, getTaskNotificationMessage(task, associatedEntity, MessageContents.CONTENT_TASK_GENERAL_UPDATED_ASSIGNEE_SOURCE, MessageContents.CONTENT_TASK_SPECIFIC_UPDATED_ASSIGNEE_SOURCE));
if (newAssignee != null) {
userMessages.put(newAssignee, getTaskNotificationMessage(task, associatedEntity, MessageContents.CONTENT_TASK_GENERAL_UPDATED_ASSIGNEE_TARGET, MessageContents.CONTENT_TASK_SPECIFIC_UPDATED_ASSIGNEE_TARGET));
}
notificationService.sendNotifications(NotificationType.TASK_UPDATED_ASSIGNEE, MessageSubject.TASK_UPDATED_ASSIGNEE, () -> userMessages);
} catch (NotificationDeliveryFailedException e) {
logger.error(String.format("EmailDeliveryFailedException when trying to notify a user about an updated task assignee."));
}
}
use of de.symeda.sormas.api.task.TaskContext in project SORMAS-Project by hzi-braunschweig.
the class TaskEditForm method updateByTaskContext.
private void updateByTaskContext() {
TaskContext taskContext = (TaskContext) getFieldGroup().getField(TaskDto.TASK_CONTEXT).getValue();
// Task types depending on task context
ComboBox taskType = (ComboBox) getFieldGroup().getField(TaskDto.TASK_TYPE);
FieldHelper.updateItems(taskType, TaskType.getTaskTypes(taskContext), FieldVisibilityCheckers.withDisease(disease), TaskType.class);
// context reference depending on task context
ComboBox caseField = (ComboBox) getFieldGroup().getField(TaskDto.CAZE);
ComboBox eventField = (ComboBox) getFieldGroup().getField(TaskDto.EVENT);
ComboBox contactField = (ComboBox) getFieldGroup().getField(TaskDto.CONTACT);
if (taskContext != null) {
switch(taskContext) {
case CASE:
FieldHelper.setFirstVisibleClearOthers(caseField, eventField, contactField);
FieldHelper.setFirstRequired(caseField, eventField, contactField);
break;
case EVENT:
FieldHelper.setFirstVisibleClearOthers(eventField, caseField, contactField);
FieldHelper.setFirstRequired(eventField, caseField, contactField);
break;
case CONTACT:
FieldHelper.setFirstVisibleClearOthers(contactField, caseField, eventField);
FieldHelper.setFirstRequired(contactField, caseField, eventField);
break;
case GENERAL:
FieldHelper.setFirstVisibleClearOthers(null, caseField, contactField, eventField);
FieldHelper.setFirstRequired(null, caseField, contactField, eventField);
break;
}
} else {
FieldHelper.setFirstVisibleClearOthers(null, caseField, eventField, contactField);
FieldHelper.setFirstRequired(null, caseField, eventField, contactField);
}
}
use of de.symeda.sormas.api.task.TaskContext in project SORMAS-Project by hzi-braunschweig.
the class TaskFacadeEjb method buildTaskUserMessages.
private Map<User, String> buildTaskUserMessages(List<Task> tasks, String generalMessageTag, String specificMessageTag) {
final Map<User, String> messages = new HashMap<>();
for (Task task : tasks) {
final TaskContext context = task.getTaskContext();
final AbstractDomainObject associatedEntity = context == TaskContext.CASE ? task.getCaze() : context == TaskContext.CONTACT ? task.getContact() : context == TaskContext.EVENT ? task.getEvent() : null;
String message = getTaskNotificationMessage(task, associatedEntity, generalMessageTag, specificMessageTag);
if (task.getAssigneeUser() != null) {
messages.put(task.getAssigneeUser(), message);
}
if (task.getObserverUsers() != null) {
String observerUserMessage = I18nProperties.getString(MessageContents.CONTENT_TASK_OBSERVER_INFORMATION) + "\n\n" + message;
for (User observerUser : task.getObserverUsers()) {
messages.put(observerUser, observerUserMessage);
}
}
}
return messages;
}
Aggregations