use of de.symeda.sormas.backend.common.AbstractDomainObject in project SORMAS-Project by hzi-braunschweig.
the class ChangeDateUuidComparatorTest method createAbstractDomainObject.
@NotNull
private AbstractDomainObject createAbstractDomainObject(Timestamp testTimestamp, String uuid) {
AbstractDomainObject testObject = new AbstractDomainObject() {
};
testObject.setChangeDate(testTimestamp);
testObject.setUuid(uuid);
return testObject;
}
use of de.symeda.sormas.backend.common.AbstractDomainObject in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasShareInfoService method getUuidsWithPendingOwnershipHandOver.
private <ADO extends AbstractDomainObject> List<String> getUuidsWithPendingOwnershipHandOver(String associatedObjectField, List<ADO> associatedObjects) {
final CriteriaBuilder cb = em.getCriteriaBuilder();
final CriteriaQuery<String> query = cb.createQuery(String.class);
Root<SormasToSormasShareInfo> root = query.from(SormasToSormasShareInfo.class);
Join<SormasToSormasShareInfo, AbstractDomainObject> associatedObjectJoin = root.join(associatedObjectField, JoinType.LEFT);
query.select(associatedObjectJoin.get(AbstractDomainObject.UUID));
query.where(associatedObjectJoin.in(associatedObjects), cb.and(getOwnershipHandedOverFilter(query, cb, root, ShareRequestStatus.PENDING)));
return em.createQuery(query).getResultList();
}
use of de.symeda.sormas.backend.common.AbstractDomainObject 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.backend.common.AbstractDomainObject 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;
}
use of de.symeda.sormas.backend.common.AbstractDomainObject in project SORMAS-Project by hzi-braunschweig.
the class ChangeDateUuidComparatorTest method testSortChangeDateUuid.
@Test
public void testSortChangeDateUuid() {
Timestamp testTimestamp1 = new Timestamp(TEST_TIME);
Timestamp testTimestamp2 = new Timestamp(TEST_TIME + 1);
Timestamp testTimestamp3 = new Timestamp(TEST_TIME + 2);
Timestamp testTimestamp4 = new Timestamp(TEST_TIME + 2);
testTimestamp4.setNanos(testTimestamp4.getNanos() + 15);
Timestamp testTimestamp5 = new Timestamp(TEST_TIME + 2);
testTimestamp5.setNanos(testTimestamp5.getNanos() + 1500);
Timestamp testTimestamp6 = new Timestamp(TEST_TIME + 2);
testTimestamp5.setNanos(testTimestamp6.getNanos() + 999999);
Timestamp testTimestamp7 = new Timestamp(TEST_TIME + 3);
String uuid1 = "AAAAAA-AAAAAA-AAAAAA-AAAAAG";
String uuid2 = "AAAAAA-AAAAAA-AAAAAA-AAAAAF";
String uuid3 = "AAAAAA-ACAAAA-AAAAAA-AAAAAE";
String uuid4 = "AAAAAA-ABAAAA-AAAAAA-AAAAAD";
String uuid5 = "AAAAAA-AZAAAA-AAAAAA-AAAAAC";
String uuid6 = "AAAAAA-AAAAAA-AAAAAA-AAAAAB";
String uuid7 = "AAAAAA-AAAAAA-AAAAAA-AAAAAA";
ArrayList<AbstractDomainObject> ados = new ArrayList<>();
ados.add(createAbstractDomainObject(testTimestamp7, uuid7));
ados.add(createAbstractDomainObject(testTimestamp6, uuid6));
ados.add(createAbstractDomainObject(testTimestamp5, uuid5));
ados.add(createAbstractDomainObject(testTimestamp4, uuid4));
ados.add(createAbstractDomainObject(testTimestamp3, uuid3));
ados.add(createAbstractDomainObject(testTimestamp2, uuid2));
ados.add(createAbstractDomainObject(testTimestamp1, uuid1));
List<AbstractDomainObject> sortedAdos = ados.stream().sorted(new ChangeDateUuidComparator<>()).collect(Collectors.toList());
assertEquals(uuid1, sortedAdos.get(0).getUuid());
assertEquals(uuid2, sortedAdos.get(1).getUuid());
assertEquals(uuid6, sortedAdos.get(2).getUuid());
assertEquals(uuid4, sortedAdos.get(3).getUuid());
assertEquals(uuid3, sortedAdos.get(4).getUuid());
assertEquals(uuid5, sortedAdos.get(5).getUuid());
assertEquals(uuid7, sortedAdos.get(6).getUuid());
}
Aggregations