diff --git a/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/HistoryEventImpl.java b/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/HistoryEventImpl.java index c81fef71b..e07e6b471 100644 --- a/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/HistoryEventImpl.java +++ b/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/HistoryEventImpl.java @@ -5,7 +5,7 @@ import pro.taskana.spi.history.api.events.TaskanaHistoryEvent; /** This entity contains the most important information about a history event. */ public class HistoryEventImpl extends TaskanaHistoryEvent { - public HistoryEventImpl() { - super(); + public HistoryEventImpl(String userId) { + super(userId); } } diff --git a/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/HistoryQueryImpl.java b/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/HistoryQueryImpl.java index 316294995..e1ce3df1a 100644 --- a/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/HistoryQueryImpl.java +++ b/history/taskana-simplehistory-provider/src/main/java/pro/taskana/simplehistory/impl/HistoryQueryImpl.java @@ -596,7 +596,7 @@ public class HistoryQueryImpl implements HistoryQuery { @Override public HistoryEventImpl single() { LOGGER.debug("entry to list(), this = {}", this); - HistoryEventImpl result = new HistoryEventImpl(); + HistoryEventImpl result = null; try { taskanaHistoryEngine.openConnection(); this.maxRows = 1; diff --git a/history/taskana-simplehistory-provider/src/test/java/acceptance/AbstractAccTest.java b/history/taskana-simplehistory-provider/src/test/java/acceptance/AbstractAccTest.java index e92c1de7b..9cea78141 100644 --- a/history/taskana-simplehistory-provider/src/test/java/acceptance/AbstractAccTest.java +++ b/history/taskana-simplehistory-provider/src/test/java/acceptance/AbstractAccTest.java @@ -112,8 +112,9 @@ public class AbstractAccTest { String taskId, String type, String comment, - String previousWorkbasketId) { - HistoryEventImpl historyEvent = new HistoryEventImpl(); + String previousWorkbasketId, + String userid) { + HistoryEventImpl historyEvent = new HistoryEventImpl(userid); historyEvent.setWorkbasketKey(workbasketKey); historyEvent.setTaskId(taskId); historyEvent.setEventType(type); diff --git a/history/taskana-simplehistory-provider/src/test/java/configuration/TaskanaEngineConfigurationTest.java b/history/taskana-simplehistory-provider/src/test/java/configuration/TaskanaEngineConfigurationTest.java index f3be245ad..24dc7374a 100644 --- a/history/taskana-simplehistory-provider/src/test/java/configuration/TaskanaEngineConfigurationTest.java +++ b/history/taskana-simplehistory-provider/src/test/java/configuration/TaskanaEngineConfigurationTest.java @@ -37,7 +37,7 @@ public class TaskanaEngineConfigurationTest extends AbstractAccTest { getHistoryService() .create( AbstractAccTest.createHistoryEvent( - "wbKey1", "taskId1", "type1", "Some comment", "wbKey2")); + "wbKey1", "taskId1", "type1", "Some comment", "wbKey2","someUserId")); count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count(); assertEquals(1, count); } diff --git a/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/HistoryQueryImplTest.java b/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/HistoryQueryImplTest.java index e73acdc8f..c02f7f592 100644 --- a/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/HistoryQueryImplTest.java +++ b/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/HistoryQueryImplTest.java @@ -68,11 +68,10 @@ public class HistoryQueryImplTest { String userId, String comment, Instant created) { - HistoryEventImpl he = new HistoryEventImpl(); + HistoryEventImpl he = new HistoryEventImpl(userId); he.setTaskId(taskId); he.setWorkbasketKey(workbasketKey); he.setEventType(type); - he.setUserId(userId); he.setComment(comment); he.setCreated(created); return he; diff --git a/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImplTest.java b/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImplTest.java index 371723092..86812221c 100644 --- a/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImplTest.java +++ b/history/taskana-simplehistory-provider/src/test/java/pro/taskana/simplehistory/impl/SimpleHistoryServiceImplTest.java @@ -96,7 +96,8 @@ public class SimpleHistoryServiceImplTest { @Test public void testCreateEvent() throws SQLException { HistoryEventImpl expectedWb = - AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment", "wbKey2"); + AbstractAccTest.createHistoryEvent( + "wbKey1", "taskId1", "type1", "Some comment", "wbKey2", "someUserId"); doNothing().when(historyEventMapperMock).insert(expectedWb); cutSpy.create(expectedWb); @@ -110,7 +111,8 @@ public class SimpleHistoryServiceImplTest { public void testQueryEvent() throws SQLException { List returnList = new ArrayList<>(); returnList.add( - AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment", "wbKey2")); + AbstractAccTest.createHistoryEvent( + "wbKey1", "taskId1", "type1", "Some comment", "wbKey2", "someUserId")); doReturn(returnList).when(historyQueryMapperMock).queryHistoryEvent(any()); final List result = cutSpy.createHistoryQuery().taskIdIn("taskId1").list(); diff --git a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/TaskanaHistoryEvent.java b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/TaskanaHistoryEvent.java index abc63cf69..cf851a2f7 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/TaskanaHistoryEvent.java +++ b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/TaskanaHistoryEvent.java @@ -2,8 +2,6 @@ package pro.taskana.spi.history.api.events; import java.time.Instant; -import pro.taskana.common.internal.security.CurrentUserContext; - /** Super class for all specific events from the TASKANA engine. */ public class TaskanaHistoryEvent { @@ -34,8 +32,8 @@ public class TaskanaHistoryEvent { protected String oldData; protected String newData; - public TaskanaHistoryEvent() { - userId = CurrentUserContext.getUserid(); + public TaskanaHistoryEvent(String userId) { + this.userId = userId; } public long getId() { diff --git a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/ClaimCancelledEvent.java b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/ClaimCancelledEvent.java index 84005203a..4973221d9 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/ClaimCancelledEvent.java +++ b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/ClaimCancelledEvent.java @@ -5,8 +5,8 @@ import pro.taskana.task.api.Task; /** Event fired if a task is cancelled to be claimed. */ public class ClaimCancelledEvent extends TaskEvent { - public ClaimCancelledEvent(Task task) { - super(task); + public ClaimCancelledEvent(Task task, String userId) { + super(task, userId); eventType = "TASK_CLAIM_CANCELLED"; created = task.getModified(); } diff --git a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/ClaimedEvent.java b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/ClaimedEvent.java index c45b4a473..05872e825 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/ClaimedEvent.java +++ b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/ClaimedEvent.java @@ -5,8 +5,8 @@ import pro.taskana.task.api.Task; /** Event fired if a task is claimed. */ public class ClaimedEvent extends TaskEvent { - public ClaimedEvent(Task task) { - super(task); + public ClaimedEvent(Task task, String userId) { + super(task, userId); setEventType("TASK_CLAIMED"); created = task.getClaimed(); } diff --git a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/CompletedEvent.java b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/CompletedEvent.java index 7011b58fc..409cf0b71 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/CompletedEvent.java +++ b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/CompletedEvent.java @@ -6,14 +6,14 @@ import pro.taskana.task.api.TaskSummary; /** Event fired if a task is completed. */ public class CompletedEvent extends TaskEvent { - public CompletedEvent(Task completedTask) { - super(completedTask); + public CompletedEvent(Task completedTask, String userId) { + super(completedTask, userId); eventType = "TASK_COMPLETED"; created = completedTask.getCompleted(); } - public CompletedEvent(TaskSummary completedTask) { - super(completedTask); + public CompletedEvent(TaskSummary completedTask, String userId) { + super(completedTask, userId); eventType = "TASK_COMPLETED"; created = completedTask.getCompleted(); } diff --git a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/CreatedEvent.java b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/CreatedEvent.java index 54f9a6e80..80a80ce54 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/CreatedEvent.java +++ b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/CreatedEvent.java @@ -5,8 +5,8 @@ import pro.taskana.task.api.Task; /** Event fired if a task is created. */ public class CreatedEvent extends TaskEvent { - public CreatedEvent(Task task) { - super(task); + public CreatedEvent(Task task, String userId) { + super(task, userId); eventType = "TASK_CREATED"; created = task.getCreated(); } diff --git a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/TaskEvent.java b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/TaskEvent.java index fcf1d0b59..0257eed91 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/TaskEvent.java +++ b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/TaskEvent.java @@ -7,8 +7,8 @@ import pro.taskana.task.api.TaskSummary; /** Super class for all task related events. */ public class TaskEvent extends TaskanaHistoryEvent { - public TaskEvent(Task task) { - super(); + public TaskEvent(Task task, String userId) { + super(userId); taskId = task.getId(); businessProcessId = task.getBusinessProcessId(); parentBusinessProcessId = task.getParentBusinessProcessId(); @@ -31,8 +31,8 @@ public class TaskEvent extends TaskanaHistoryEvent { } } - public TaskEvent(TaskSummary task) { - super(); + public TaskEvent(TaskSummary task, String userId) { + super(userId); taskId = task.getId(); businessProcessId = task.getBusinessProcessId(); parentBusinessProcessId = task.getParentBusinessProcessId(); diff --git a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/TransferredEvent.java b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/TransferredEvent.java index 5319b90d1..0cd2fcd32 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/TransferredEvent.java +++ b/lib/taskana-core/src/main/java/pro/taskana/spi/history/api/events/task/TransferredEvent.java @@ -12,8 +12,8 @@ public class TransferredEvent extends TaskEvent { private static final Logger LOGGER = LoggerFactory.getLogger(TransferredEvent.class); public TransferredEvent( - Task task, WorkbasketSummary oldWorkbasket, WorkbasketSummary newWorkbasket) { - super(task); + Task task, WorkbasketSummary oldWorkbasket, WorkbasketSummary newWorkbasket, String userId) { + super(task, userId); eventType = "TASK_TRANSFERRED"; created = task.getModified(); this.oldValue = oldWorkbasket.getId(); diff --git a/lib/taskana-core/src/main/java/pro/taskana/task/internal/TaskServiceImpl.java b/lib/taskana-core/src/main/java/pro/taskana/task/internal/TaskServiceImpl.java index f57c5f001..7c3c2b8f8 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/task/internal/TaskServiceImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/task/internal/TaskServiceImpl.java @@ -212,7 +212,7 @@ public class TaskServiceImpl implements TaskService { this.taskMapper.insert(task); LOGGER.debug("Method createTask() created Task '{}'.", task.getId()); if (HistoryEventProducer.isHistoryEnabled()) { - historyEventProducer.createEvent(new CreatedEvent(task)); + historyEventProducer.createEvent(new CreatedEvent(task, CurrentUserContext.getUserid())); } } catch (PersistenceException e) { // Error messages: @@ -521,8 +521,7 @@ public class TaskServiceImpl implements TaskService { List changedTasks = new ArrayList<>(); if (!taskSummaries.isEmpty()) { - changedTasks = - taskSummaries.stream().map(TaskSummary::getId).collect(Collectors.toList()); + changedTasks = taskSummaries.stream().map(TaskSummary::getId).collect(Collectors.toList()); taskMapper.updateTasks(changedTasks, updated, fieldSelector); if (LOGGER.isDebugEnabled()) { LOGGER.debug( @@ -562,8 +561,7 @@ public class TaskServiceImpl implements TaskService { List changedTasks = new ArrayList<>(); if (!taskSummaries.isEmpty()) { - changedTasks = - taskSummaries.stream().map(TaskSummary::getId).collect(Collectors.toList()); + changedTasks = taskSummaries.stream().map(TaskSummary::getId).collect(Collectors.toList()); taskMapper.updateTasks(changedTasks, updatedTask, fieldSelector); if (LOGGER.isDebugEnabled()) { LOGGER.debug( @@ -781,7 +779,7 @@ public class TaskServiceImpl implements TaskService { taskMapper.update(task); LOGGER.debug("Task '{}' claimed by user '{}'.", taskId, userId); if (HistoryEventProducer.isHistoryEnabled()) { - historyEventProducer.createEvent(new ClaimedEvent(task)); + historyEventProducer.createEvent(new ClaimedEvent(task, CurrentUserContext.getUserid())); } } finally { taskanaEngine.returnConnection(); @@ -820,7 +818,8 @@ public class TaskServiceImpl implements TaskService { taskMapper.update(task); LOGGER.debug("Task '{}' unclaimed by user '{}'.", taskId, userId); if (HistoryEventProducer.isHistoryEnabled()) { - historyEventProducer.createEvent(new ClaimCancelledEvent(task)); + historyEventProducer.createEvent( + new ClaimCancelledEvent(task, CurrentUserContext.getUserid())); } } finally { taskanaEngine.returnConnection(); @@ -871,7 +870,7 @@ public class TaskServiceImpl implements TaskService { taskMapper.update(task); LOGGER.debug("Task '{}' completed by user '{}'.", taskId, userId); if (HistoryEventProducer.isHistoryEnabled()) { - historyEventProducer.createEvent(new CompletedEvent(task)); + historyEventProducer.createEvent(new CompletedEvent(task, CurrentUserContext.getUserid())); } } finally { taskanaEngine.returnConnection(); @@ -1001,9 +1000,7 @@ public class TaskServiceImpl implements TaskService { } private void standardSettings( - TaskImpl task, - Classification classification, - PrioDurationHolder prioDurationFromAttachments) + TaskImpl task, Classification classification, PrioDurationHolder prioDurationFromAttachments) throws InvalidArgumentException { LOGGER.debug("entry to standardSettings()"); final Instant now = Instant.now(); @@ -1581,9 +1578,7 @@ public class TaskServiceImpl implements TaskService { } private void updateClassificationRelatedProperties( - TaskImpl oldTaskImpl, - TaskImpl newTaskImpl, - PrioDurationHolder prioDurationFromAttachments) + TaskImpl oldTaskImpl, TaskImpl newTaskImpl, PrioDurationHolder prioDurationFromAttachments) throws ClassificationNotFoundException { LOGGER.debug("entry to updateClassificationRelatedProperties()"); // insert Classification specifications if Classification is given. @@ -1967,7 +1962,10 @@ public class TaskServiceImpl implements TaskService { } private void createTasksCompletedEvents(List taskSummaries) { - taskSummaries.forEach(task -> historyEventProducer.createEvent(new CompletedEvent(task))); + taskSummaries.forEach( + task -> + historyEventProducer.createEvent( + new CompletedEvent(task, CurrentUserContext.getUserid()))); } private static class PrioDurationHolder extends Pair { diff --git a/lib/taskana-core/src/main/java/pro/taskana/task/internal/TaskTransferrer.java b/lib/taskana-core/src/main/java/pro/taskana/task/internal/TaskTransferrer.java index 3ab6865b3..9309d3f67 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/task/internal/TaskTransferrer.java +++ b/lib/taskana-core/src/main/java/pro/taskana/task/internal/TaskTransferrer.java @@ -363,7 +363,8 @@ public class TaskTransferrer { private void createTaskTransferredEvent( Task task, WorkbasketSummary oldWorkbasketSummary, WorkbasketSummary newWorkbasketSummary) { historyEventProducer.createEvent( - new TransferredEvent(task, oldWorkbasketSummary, newWorkbasketSummary)); + new TransferredEvent( + task, oldWorkbasketSummary, newWorkbasketSummary, CurrentUserContext.getUserid())); } private void updateTasksToBeTransferred(