Skip to content

Commit

Permalink
[JBPM-9195] Case traceability from a Task Instance (#1680)
Browse files Browse the repository at this point in the history
CorrelationKey and ProcessType added to UserTaskDescription.

Existing APIs(getTaskById, getTaskByWorkItem and getTaskByProcess) are
reused, since I believe is preferable to assume the performance cost of
an extra join rather than having to maintain a new API for every
attribute combination (specially when there is already a join because of
the introduction of subject attribute)
  • Loading branch information
fjtirado committed Jul 16, 2020
1 parent 2763845 commit d66923f
Show file tree
Hide file tree
Showing 55 changed files with 555 additions and 191 deletions.
Expand Up @@ -444,12 +444,13 @@
t.taskData.processInstanceId,
t.taskData.parentId,
t.taskData.deploymentId,
t.taskData.skipable )
t.taskData.skipable, plog.correlationKey, plog.processType)
from
TaskImpl t
inner join ProcessInstanceLog plog ON t.taskData.processInstanceId = plog.processInstanceId
join t.peopleAssignments.businessAdministrators businessAdministrators
where
t.taskData.processInstanceId in (select log.processInstanceId from ProcessInstanceLog log where log.correlationKey like :caseId) and
plog.correlationKey like :caseId and
t.archived = 0 and
( businessAdministrators.id = :userId or businessAdministrators.id in (:groupIds) ) and
t.taskData.status in (:status)
Expand Down Expand Up @@ -478,13 +479,14 @@
t.taskData.processInstanceId,
t.taskData.parentId,
t.taskData.deploymentId,
t.taskData.skipable )
t.taskData.skipable, plog.correlationKey, plog.processType)
from
TaskImpl t
inner join ProcessInstanceLog plog ON t.taskData.processInstanceId = plog.processInstanceId
join t.peopleAssignments.potentialOwners potentialOwners
left join t.peopleAssignments.excludedOwners as excludedOwners
where
t.taskData.processInstanceId in (select log.processInstanceId from ProcessInstanceLog log where log.correlationKey like :caseId) and
plog.correlationKey like :caseId and
t.archived = 0 and
(t.taskData.actualOwner.id = :userId or t.taskData.actualOwner is null) and
t.taskData.status in (:status) and
Expand Down Expand Up @@ -514,12 +516,13 @@
t.taskData.processInstanceId,
t.taskData.parentId,
t.taskData.deploymentId,
t.taskData.skipable )
t.taskData.skipable, plog.correlationKey, plog.processType)
from
TaskImpl t
inner join ProcessInstanceLog plog ON t.taskData.processInstanceId = plog.processInstanceId
join t.peopleAssignments.taskStakeholders taskStakeholders
where
t.taskData.processInstanceId in (select log.processInstanceId from ProcessInstanceLog log where log.correlationKey like :caseId) and
plog.correlationKey like :caseId and
t.archived = 0 and
t.taskData.status in (:status) and
( taskStakeholders.id = :userId or taskStakeholders.id in (:groupIds) )
Expand Down
Expand Up @@ -413,6 +413,8 @@
userId varchar(255),
OPTLOCK integer,
workItemId bigint,
correlationKey varchar(255),
processType integer,
primary key (id)
);

Expand Down
Expand Up @@ -413,6 +413,8 @@
userId varchar(255),
OPTLOCK integer,
workItemId bigint,
correlationKey varchar(255),
processType integer,
primary key (id)
);

Expand Down
Expand Up @@ -413,6 +413,8 @@
userId varchar(255),
OPTLOCK integer,
workItemId bigint,
correlationKey varchar(255),
processType integer,
primary key (id)
);

Expand Down
Expand Up @@ -413,6 +413,8 @@
userId varchar(255),
OPTLOCK integer,
workItemId bigint,
correlationKey varchar(255),
processType integer,
primary key (id)
);

Expand Down
Expand Up @@ -438,6 +438,8 @@
userId varchar(255),
OPTLOCK integer,
workItemId bigint,
correlationKey varchar(255),
processType integer,
primary key (id)
);

Expand Down
Expand Up @@ -441,6 +441,8 @@
userId varchar(255),
OPTLOCK integer,
workItemId bigint,
correlationKey varchar(255),
processType integer,
primary key (id)
);

Expand Down
Expand Up @@ -413,6 +413,8 @@
userId varchar2(255 char),
OPTLOCK number(10,0),
workItemId number(19,0),
correlationKey varchar(255),
processType number(1,0),
primary key (id)
);

Expand Down
Expand Up @@ -413,6 +413,8 @@
userId varchar(255),
OPTLOCK int4,
workItemId int8,
correlationKey varchar(255),
processType int2,
primary key (id)
);

Expand Down
Expand Up @@ -413,6 +413,8 @@
userId varchar(255),
OPTLOCK int,
workItemId numeric(19,0),
correlationKey varchar(255),
processType numeric(1,0),
primary key (id)
);

Expand Down
Expand Up @@ -413,6 +413,8 @@
userId varchar(255),
OPTLOCK int,
workItemId bigint,
correlationKey varchar(255),
processType smallint,
primary key (id)
);

Expand Down
Expand Up @@ -448,9 +448,11 @@
processInstanceId numeric(19,0) null,
taskId numeric(19,0) null,
type varchar(255) null,
userId varchar(255) null,
userId varchar(255) null,
OPTLOCK int null,
workItemId numeric(19,0) null,
correlationKey varchar(255),
processType numeric(1,0),
primary key (id)
) lock datarows
go
Expand Down
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType integer;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType number(1,0);
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType number(1,0);
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType int2;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType int2;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType numeric(1,0);
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType numeric(1,0);
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType smallint;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType smallint;
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType numeric(1,0);
@@ -0,0 +1,2 @@
ALTER TABLE TaskEvent ADD COLUMN correlationKey varchar(255);
ALTER TABLE TaskEvent ADD COLUMN processType numeric(1,0);
Expand Up @@ -70,6 +70,10 @@ public class TaskEventImpl implements TaskEvent, Serializable {

private String message;

private String correlationKey;

private Integer processType;

@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date logTime;

Expand Down Expand Up @@ -148,6 +152,26 @@ public String getMessage() {
return message;
}

@Override
public String getCorrelationKey() {
return correlationKey;
}

@Override
public Integer getProcessType() {
return processType;
}

@Override
public void setCorrelationKey(String correlationKey) {
this.correlationKey = correlationKey;
}

@Override
public void setProcessType(Integer processType) {
this.processType = processType;
}

public void setMessage(String message) {
this.message = message;
}
Expand Down
5 changes: 5 additions & 0 deletions jbpm-human-task/jbpm-human-task-core/pom.xml
Expand Up @@ -156,6 +156,11 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-audit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
Expand Down
Expand Up @@ -27,11 +27,9 @@
<class>org.jbpm.services.task.impl.model.TaskImpl</class>
<class>org.jbpm.services.task.impl.model.TaskDataImpl</class>
<class>org.jbpm.services.task.impl.model.UserImpl</class>

<!--BAM for task service
<class>org.jbpm.services.task.impl.model.BAMTaskSummaryImpl</class>-->


<class>org.jbpm.process.audit.ProcessInstanceLog</class>

<properties>
<property name="hibernate.dialect" value="${maven.hibernate.dialect}" />
<property name="hibernate.default_schema" value="${maven.jdbc.schema}"/>
Expand Down
Expand Up @@ -23,7 +23,6 @@

import org.kie.api.task.model.Status;
import org.kie.api.task.model.User;
import org.kie.internal.task.api.TaskModelFactory;
import org.kie.internal.task.api.TaskModelProvider;
import org.kie.internal.task.api.model.InternalTaskSummary;
import org.kie.internal.task.api.model.SubTasksStrategy;
Expand Down Expand Up @@ -52,6 +51,8 @@ public class TaskSummaryImpl implements InternalTaskSummary {
private SubTasksStrategy subTaskStrategy;
private long parentId;
private boolean quickTaskSummary;
private String correlationKey;
private Integer processType;

// JPQL does not accept collections in constructor arguments
// In short, this means that this field will never be filled
Expand Down Expand Up @@ -150,6 +151,28 @@ public TaskSummaryImpl(long id,

this.quickTaskSummary = false;
}

/*
* Construct a QuickTaskSummary
*/
public TaskSummaryImpl(long id,
String name,
String subject,
String description,
Status status,
int priority,
String actualOwner,
String createdBy,
Date createdOn,
Date activationTime,
Date expirationTime,
String processId,
long processInstanceId,
long parentId,
String deploymentId,
boolean skipable) {
this(id,name,subject,description,status,priority,actualOwner,createdBy,createdOn,activationTime,expirationTime,processId,processInstanceId,parentId,deploymentId,skipable,null,null);
}

/*
* Construct a QuickTaskSummary
Expand All @@ -169,7 +192,9 @@ public TaskSummaryImpl(long id,
long processInstanceId,
long parentId,
String deploymentId,
boolean skipable) {
boolean skipable,
String correlationKey,
Integer processType) {
this.id = id;
this.processInstanceId = processInstanceId;
this.name = name;
Expand All @@ -189,6 +214,8 @@ public TaskSummaryImpl(long id,
this.parentId = parentId;
this.deploymentId = deploymentId;
this.skipable = skipable;
this.correlationKey = correlationKey;
this.processType = processType;
this.quickTaskSummary = true;
}

Expand Down Expand Up @@ -687,9 +714,19 @@ public String getDeploymentId() {
return deploymentId;
}

@Override
public String getCorrelationKey() {
return correlationKey;
}

@Override
public Integer getProcessType() {
return processType;
}

@Override
public String toString() {
return "TaskSummaryImpl{" + "id=" + id + ", name=" + name + ", subject=" + subject + ", description=" + description + ", statusId=" + statusId + ", priority=" + priority + ", skipable=" + skipable + ", actualOwnerId=" + actualOwnerId + ", createdById=" + createdById + ", createdOn=" + createdOn + ", activationTime=" + activationTime + ", expirationTime=" + expirationTime + ", processInstanceId=" + processInstanceId + ", processId=" + processId + ", processSessionId=" + processSessionId + ", deploymentId=" + deploymentId + ", parentId=" + parentId + ", potentialOwners=" + potentialOwners + ", quickTaskSummary=" + quickTaskSummary + '}';
return "TaskSummaryImpl{" + "id=" + id + ", name=" + name + ", subject=" + subject + ", description=" + description + ", statusId=" + statusId + ", priority=" + priority + ", skipable=" + skipable + ", actualOwnerId=" + actualOwnerId + ", createdById=" + createdById + ", createdOn=" + createdOn + ", activationTime=" + activationTime + ", expirationTime=" + expirationTime + ", processInstanceId=" + processInstanceId + ", processId=" + processId + ", processSessionId=" + processSessionId + ", deploymentId=" + deploymentId + ", parentId=" + parentId + ", potentialOwners=" + potentialOwners + ", quickTaskSummary=" + quickTaskSummary +", correlationKey="+correlationKey+",processType="+processType+'}';
}


Expand Down

0 comments on commit d66923f

Please sign in to comment.