use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.
the class TaskTransactionInterceptor method createContext.
@Override
public RequestContext createContext() {
final TaskPersistenceContext persistenceContext = tpm.getPersistenceContext();
persistenceContext.joinTransaction();
return new TransactionContext(persistenceContext);
}
use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.
the class BAMTaskEventListener method updateTask.
protected BAMTaskSummaryImpl updateTask(TaskEvent event, Status newStatus, BAMTaskWorker worker) {
BAMTaskSummaryImpl result = null;
Task ti = event.getTask();
TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext) event.getTaskContext()).getPersistenceContext());
try {
if (ti == null) {
logger.error("The task instance does not exist.");
return result;
}
Status status = newStatus != null ? newStatus : ti.getTaskData().getStatus();
result = persistenceContext.queryStringWithParametersInTransaction("select bts from BAMTaskSummaryImpl bts where bts.taskId=:taskId", true, persistenceContext.addParametersToMap("taskId", ti.getId()), BAMTaskSummaryImpl.class);
if (result == null) {
logger.warn("Unable find bam task entry for task id {} '{}', skipping bam task update", ti.getId(), ti.getName());
return null;
}
result.setStatus(status.toString());
if (ti.getTaskData().getActualOwner() != null) {
result.setUserId(ti.getTaskData().getActualOwner().getId());
}
if (worker != null)
worker.updateTask(result, ti);
persistenceContext.merge(result);
return result;
} finally {
cleanup(persistenceContext);
}
}
use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.
the class JPATaskLifeCycleEventListener method assignmentsUpadted.
protected void assignmentsUpadted(TaskEvent event, AssignmentType type, List<OrganizationalEntity> entities, String messageSufix) {
if (entities == null || entities.isEmpty()) {
return;
}
String userId = event.getTaskContext().getUserId();
Task task = event.getTask();
TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext) event.getTaskContext()).getPersistenceContext());
StringBuilder message = new StringBuilder();
switch(type) {
case POT_OWNER:
message.append("Potential owners [");
break;
case EXCL_OWNER:
message.append("Excluded owners [");
break;
case ADMIN:
message.append("Business administrators [");
break;
default:
break;
}
String entitiesAsString = entities.stream().map(oe -> oe.getId()).collect(Collectors.joining(","));
message.append(entitiesAsString);
message.append(messageSufix);
persistenceContext.persist(new TaskEventImpl(task.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.UPDATED, task.getTaskData().getProcessInstanceId(), task.getTaskData().getWorkItemId(), userId, message.toString()));
}
use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.
the class JPATaskLifeCycleEventListener method afterTaskReassignedEvent.
@Override
public void afterTaskReassignedEvent(TaskEvent event) {
String userId = event.getTaskContext().getUserId();
Task ti = event.getTask();
TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext) event.getTaskContext()).getPersistenceContext());
try {
persistenceContext.persist(new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.DELEGATED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId));
AuditTaskImpl auditTaskImpl = getAuditTask(event, persistenceContext, ti);
if (auditTaskImpl == null) {
logger.warn("Unable find audit task entry for task id {} '{}', skipping audit task update", ti.getId(), ti.getName());
return;
}
auditTaskImpl.setDescription(ti.getDescription());
auditTaskImpl.setName(ti.getName());
auditTaskImpl.setActivationTime(ti.getTaskData().getActivationTime());
auditTaskImpl.setPriority(ti.getPriority());
auditTaskImpl.setDueDate(ti.getTaskData().getExpirationTime());
auditTaskImpl.setStatus(ti.getTaskData().getStatus().name());
auditTaskImpl.setActualOwner(getActualOwner(ti));
auditTaskImpl.setLastModificationDate(event.getEventDate());
persistenceContext.merge(auditTaskImpl);
} finally {
cleanup(persistenceContext);
}
}
use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.
the class JPATaskLifeCycleEventListener method afterTaskForwardedEvent.
@Override
public void afterTaskForwardedEvent(TaskEvent event) {
String userId = event.getTaskContext().getUserId();
Task ti = event.getTask();
TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext) event.getTaskContext()).getPersistenceContext());
try {
StringBuilder message = new StringBuilder();
String entitiesAsString = (ti.getPeopleAssignments().getPotentialOwners()).stream().map(oe -> oe.getId()).collect(Collectors.joining(","));
message.append("Forward to [" + entitiesAsString + "]");
persistenceContext.persist(new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.FORWARDED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId, message.toString()));
AuditTaskImpl auditTaskImpl = getAuditTask(event, persistenceContext, ti);
if (auditTaskImpl == null) {
logger.warn("Unable find audit task entry for task id {} '{}', skipping audit task update", ti.getId(), ti.getName());
return;
}
auditTaskImpl.setDescription(ti.getDescription());
auditTaskImpl.setName(ti.getName());
auditTaskImpl.setActivationTime(ti.getTaskData().getActivationTime());
auditTaskImpl.setPriority(ti.getPriority());
auditTaskImpl.setDueDate(ti.getTaskData().getExpirationTime());
auditTaskImpl.setStatus(ti.getTaskData().getStatus().name());
auditTaskImpl.setActualOwner(getActualOwner(ti));
auditTaskImpl.setLastModificationDate(event.getEventDate());
persistenceContext.merge(auditTaskImpl);
} finally {
cleanup(persistenceContext);
}
}
Aggregations