TSK-734: Made allowedKeys a static class member
This commit is contained in:
parent
b480f0532f
commit
4bfb55cc20
|
@ -33,6 +33,17 @@ public final class HistoryEventProducer {
|
|||
return getInstance(null).isEnabled();
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void createEvent(TaskanaHistoryEvent event) {
|
||||
LOGGER.debug("Sending event to history service providers: {}", event);
|
||||
serviceLoader.forEach(historyProvider -> {
|
||||
historyProvider.create(event);
|
||||
});
|
||||
}
|
||||
|
||||
private HistoryEventProducer(TaskanaEngineConfiguration taskanaEngineConfiguration) {
|
||||
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
|
||||
serviceLoader = ServiceLoader.load(TaskanaHistory.class);
|
||||
|
@ -47,15 +58,4 @@ public final class HistoryEventProducer {
|
|||
LOGGER.info("No history provider found. Running without history.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void createEvent(TaskanaHistoryEvent event) {
|
||||
LOGGER.debug("Sending event to history service providers: {}", event);
|
||||
serviceLoader.forEach(historyProvider -> {
|
||||
historyProvider.create(event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package pro.taskana.history.api;
|
||||
|
||||
import pro.taskana.Task;
|
||||
|
||||
/**
|
||||
* Event fired if a task is completed.
|
||||
*/
|
||||
public class TaskCompletionEvent extends TaskHistoryEvent {
|
||||
|
||||
public TaskCompletionEvent(Task completedTask) {
|
||||
super(completedTask);
|
||||
type = "TASK_COMPLETED";
|
||||
created = completedTask.getCompleted();
|
||||
}
|
||||
|
||||
}
|
|
@ -10,21 +10,58 @@ import pro.taskana.security.CurrentUserContext;
|
|||
public class TaskanaHistoryEvent {
|
||||
|
||||
protected long id;
|
||||
protected String businessProcessId;
|
||||
protected String parentBusinessProcessId;
|
||||
protected String taskId;
|
||||
protected String type;
|
||||
protected String userId;
|
||||
protected Instant created;
|
||||
protected String userId;
|
||||
protected String domain;
|
||||
protected String workbasketKey;
|
||||
protected String porCompany;
|
||||
protected String porSystem;
|
||||
protected String porInstance;
|
||||
protected String porType;
|
||||
protected String porValue;
|
||||
protected String taskClassificationKey;
|
||||
protected String taskClassificationCategory;
|
||||
protected String attachmentClassificationKey;
|
||||
protected String comment;
|
||||
protected String oldValue;
|
||||
protected String newValue;
|
||||
protected String custom1;
|
||||
protected String custom2;
|
||||
protected String custom3;
|
||||
protected String custom4;
|
||||
protected String oldData;
|
||||
protected String newData;
|
||||
|
||||
public TaskanaHistoryEvent() {
|
||||
userId = CurrentUserContext.getUserid();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
public String getBusinessProcessId() {
|
||||
return businessProcessId;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
public void setBusinessProcessId(String businessProcessId) {
|
||||
this.businessProcessId = businessProcessId;
|
||||
}
|
||||
|
||||
public String getParentBusinessProcessId() {
|
||||
return parentBusinessProcessId;
|
||||
}
|
||||
|
||||
public void setParentBusinessProcessId(String parentBusinessProcessId) {
|
||||
this.parentBusinessProcessId = parentBusinessProcessId;
|
||||
}
|
||||
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
|
@ -35,6 +72,14 @@ public class TaskanaHistoryEvent {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public Instant getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Instant created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
@ -43,12 +88,84 @@ public class TaskanaHistoryEvent {
|
|||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Instant getCreated() {
|
||||
return created;
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setCreated(Instant created) {
|
||||
this.created = created;
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public String getWorkbasketKey() {
|
||||
return workbasketKey;
|
||||
}
|
||||
|
||||
public void setWorkbasketKey(String workbasketKey) {
|
||||
this.workbasketKey = workbasketKey;
|
||||
}
|
||||
|
||||
public String getPorCompany() {
|
||||
return porCompany;
|
||||
}
|
||||
|
||||
public void setPorCompany(String porCompany) {
|
||||
this.porCompany = porCompany;
|
||||
}
|
||||
|
||||
public String getPorSystem() {
|
||||
return porSystem;
|
||||
}
|
||||
|
||||
public void setPorSystem(String porSystem) {
|
||||
this.porSystem = porSystem;
|
||||
}
|
||||
|
||||
public String getPorInstance() {
|
||||
return porInstance;
|
||||
}
|
||||
|
||||
public void setPorInstance(String porInstance) {
|
||||
this.porInstance = porInstance;
|
||||
}
|
||||
|
||||
public String getPorType() {
|
||||
return porType;
|
||||
}
|
||||
|
||||
public void setPorType(String porType) {
|
||||
this.porType = porType;
|
||||
}
|
||||
|
||||
public String getPorValue() {
|
||||
return porValue;
|
||||
}
|
||||
|
||||
public void setPorValue(String porValue) {
|
||||
this.porValue = porValue;
|
||||
}
|
||||
|
||||
public String getTaskClassificationKey() {
|
||||
return taskClassificationKey;
|
||||
}
|
||||
|
||||
public void setTaskClassificationKey(String taskClassificationKey) {
|
||||
this.taskClassificationKey = taskClassificationKey;
|
||||
}
|
||||
|
||||
public String getTaskClassificationCategory() {
|
||||
return taskClassificationCategory;
|
||||
}
|
||||
|
||||
public void setTaskClassificationCategory(String taskClassificationCategory) {
|
||||
this.taskClassificationCategory = taskClassificationCategory;
|
||||
}
|
||||
|
||||
public String getAttachmentClassificationKey() {
|
||||
return attachmentClassificationKey;
|
||||
}
|
||||
|
||||
public void setAttachmentClassificationKey(String attachmentClassificationKey) {
|
||||
this.attachmentClassificationKey = attachmentClassificationKey;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
|
@ -59,4 +176,67 @@ public class TaskanaHistoryEvent {
|
|||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getOldValue() {
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
public void setOldValue(String oldValue) {
|
||||
this.oldValue = oldValue;
|
||||
}
|
||||
|
||||
public String getNewValue() {
|
||||
return newValue;
|
||||
}
|
||||
|
||||
public void setNewValue(String newValue) {
|
||||
this.newValue = newValue;
|
||||
}
|
||||
|
||||
public String getCustom1() {
|
||||
return custom1;
|
||||
}
|
||||
|
||||
public void setCustom1(String custom1) {
|
||||
this.custom1 = custom1;
|
||||
}
|
||||
|
||||
public String getCustom2() {
|
||||
return custom2;
|
||||
}
|
||||
|
||||
public void setCustom2(String custom2) {
|
||||
this.custom2 = custom2;
|
||||
}
|
||||
|
||||
public String getCustom3() {
|
||||
return custom3;
|
||||
}
|
||||
|
||||
public void setCustom3(String custom3) {
|
||||
this.custom3 = custom3;
|
||||
}
|
||||
|
||||
public String getCustom4() {
|
||||
return custom4;
|
||||
}
|
||||
|
||||
public void setCustom4(String custom4) {
|
||||
this.custom4 = custom4;
|
||||
}
|
||||
|
||||
public String getOldData() {
|
||||
return oldData;
|
||||
}
|
||||
|
||||
public void setOldData(String oldData) {
|
||||
this.oldData = oldData;
|
||||
}
|
||||
|
||||
public String getNewData() {
|
||||
return newData;
|
||||
}
|
||||
|
||||
public void setNewData(String newData) {
|
||||
this.newData = newData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package pro.taskana.history.events.task;
|
||||
|
||||
import pro.taskana.Task;
|
||||
|
||||
/**
|
||||
* Event fired if a task is cancelled to be claimed.
|
||||
*/
|
||||
public class ClaimCancelledEvent extends TaskEvent {
|
||||
|
||||
public ClaimCancelledEvent(Task task) {
|
||||
super(task);
|
||||
type = "TASK_CLAIM_CANCELLED";
|
||||
created = task.getModified();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package pro.taskana.history.events.task;
|
||||
|
||||
import pro.taskana.Task;
|
||||
/**
|
||||
* Event fired if a task is claimed.
|
||||
*/
|
||||
public class ClaimedEvent extends TaskEvent {
|
||||
|
||||
public ClaimedEvent(Task task) {
|
||||
super(task);
|
||||
setType("TASK_CLAIMED");
|
||||
created = task.getClaimed();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package pro.taskana.history.events.task;
|
||||
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskSummary;
|
||||
|
||||
/**
|
||||
* Event fired if a task is completed.
|
||||
*/
|
||||
public class CompletedEvent extends TaskEvent {
|
||||
|
||||
public CompletedEvent(Task completedTask) {
|
||||
super(completedTask);
|
||||
type = "TASK_COMPLETED";
|
||||
created = completedTask.getCompleted();
|
||||
}
|
||||
|
||||
public CompletedEvent(TaskSummary completedTask) {
|
||||
super(completedTask);
|
||||
type = "TASK_COMPLETED";
|
||||
created = completedTask.getCompleted();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package pro.taskana.history.events.task;
|
||||
|
||||
import pro.taskana.Task;
|
||||
/**
|
||||
* Event fired if a task is created.
|
||||
*/
|
||||
public class CreatedEvent extends TaskEvent {
|
||||
|
||||
public CreatedEvent(Task task) {
|
||||
super(task);
|
||||
type = "TASK_CREATED";
|
||||
created = task.getCreated();
|
||||
}
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
package pro.taskana.history.api;
|
||||
package pro.taskana.history.events.task;
|
||||
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskSummary;
|
||||
import pro.taskana.history.api.TaskanaHistoryEvent;
|
||||
|
||||
/**
|
||||
* Super class for all task related events.
|
||||
*/
|
||||
public class TaskHistoryEvent extends TaskanaHistoryEvent {
|
||||
public class TaskEvent extends TaskanaHistoryEvent {
|
||||
|
||||
protected String taskId;
|
||||
protected String businessProcessId;
|
||||
|
@ -21,7 +23,7 @@ public class TaskHistoryEvent extends TaskanaHistoryEvent {
|
|||
protected String porType;
|
||||
protected String porValue;
|
||||
|
||||
public TaskHistoryEvent(Task task) {
|
||||
public TaskEvent(Task task) {
|
||||
super();
|
||||
taskId = task.getId();
|
||||
businessProcessId = task.getBusinessProcessId();
|
||||
|
@ -29,7 +31,9 @@ public class TaskHistoryEvent extends TaskanaHistoryEvent {
|
|||
domain = task.getDomain();
|
||||
workbasketKey = task.getWorkbasketKey();
|
||||
taskClassificationCategory = task.getClassificationCategory();
|
||||
taskClassificationKey = task.getClassificationSummary().getKey();
|
||||
if (task.getClassificationSummary() != null) {
|
||||
taskClassificationKey = task.getClassificationSummary().getKey();
|
||||
}
|
||||
if (!task.getAttachments().isEmpty()) {
|
||||
attachmentClassificationKey = task.getAttachments().get(0).getClassificationSummary().getKey();
|
||||
}
|
||||
|
@ -42,6 +46,31 @@ public class TaskHistoryEvent extends TaskanaHistoryEvent {
|
|||
}
|
||||
}
|
||||
|
||||
public TaskEvent(TaskSummary task) {
|
||||
super();
|
||||
taskId = task.getTaskId();
|
||||
businessProcessId = task.getBusinessProcessId();
|
||||
parentBusinessProcessId = task.getParentBusinessProcessId();
|
||||
domain = task.getDomain();
|
||||
if (task.getWorkbasketSummary() != null) {
|
||||
workbasketKey = task.getWorkbasketSummary().getKey();
|
||||
}
|
||||
if (task.getClassificationSummary() != null) {
|
||||
taskClassificationKey = task.getClassificationSummary().getKey();
|
||||
taskClassificationCategory = task.getClassificationSummary().getCategory();
|
||||
}
|
||||
if (!task.getAttachmentSummaries().isEmpty()) {
|
||||
attachmentClassificationKey = task.getAttachmentSummaries().get(0).getClassificationSummary().getKey();
|
||||
}
|
||||
if (task.getPrimaryObjRef() != null) {
|
||||
porCompany = task.getPrimaryObjRef().getCompany();
|
||||
porSystem = task.getPrimaryObjRef().getSystem();
|
||||
porInstance = task.getPrimaryObjRef().getSystemInstance();
|
||||
porType = task.getPrimaryObjRef().getType();
|
||||
porValue = task.getPrimaryObjRef().getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package pro.taskana.history.events.task;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
|
||||
/**
|
||||
* Event fired if a task is transferred.
|
||||
*/
|
||||
public class TransferredEvent extends TaskEvent {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TransferredEvent.class);
|
||||
|
||||
public TransferredEvent(Task task, WorkbasketSummary oldWorkbasket, WorkbasketSummary newWorkbasket) {
|
||||
super(task);
|
||||
type = "TASK_TRANSFERRED";
|
||||
created = task.getModified();
|
||||
this.oldValue = oldWorkbasket.getId();
|
||||
this.newValue = newWorkbasket.getId();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -11,7 +11,7 @@ import pro.taskana.impl.TaskanaEngineImpl;
|
|||
/**
|
||||
* Acceptance test for historyEventProducer class.
|
||||
*/
|
||||
public class HistoryEventProducerTest extends AbstractAccTest {
|
||||
public class TaskEventProducerTest extends AbstractAccTest {
|
||||
|
||||
@Test
|
||||
public void testHistoryEventProducerIsNotEnabled() {
|
Loading…
Reference in New Issue