use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.
the class GetTasksForProcessCommand method execute.
@Override
public List<TaskSummary> execute(Context context) {
TaskContext ctx = (TaskContext) context;
TaskPersistenceContext persistenceContext = ctx.getPersistenceContext();
List<TaskSummary> tasks = (List<TaskSummary>) persistenceContext.queryWithParametersInTransaction("TasksByStatusByProcessId", persistenceContext.addParametersToMap("processInstanceId", processInstanceId, "status", statuses), ClassUtil.<List<TaskSummary>>castClass(List.class));
return tasks;
}
use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.
the class CleanUpCommand method execute.
@Override
public Void execute(Context context) {
TaskPersistenceContext persistenceContext = ((TaskContext) context).getPersistenceContext();
persistenceContext.executeUpdateString("delete from NodeInstanceLog nid");
persistenceContext.executeUpdateString("delete from ProcessInstanceLog pid");
persistenceContext.executeUpdateString("delete from VariableInstanceLog vsd");
persistenceContext.executeUpdateString("delete from AuditTaskImpl vsd");
return null;
}
use of org.kie.internal.task.api.TaskPersistenceContext in project jbpm by kiegroup.
the class AddTaskInputsCommand method execute.
@SuppressWarnings("unchecked")
@Override
public Void execute(Context cntxt) {
TaskContext context = (TaskContext) cntxt;
TaskEventSupport taskEventSupport = context.getTaskEventSupport();
TaskPersistenceContext persistenceContext = context.getPersistenceContext();
Task task = persistenceContext.findTask(taskId);
// security check
if (!isBusinessAdmin(userId, task.getPeopleAssignments().getBusinessAdministrators(), context)) {
throw new PermissionDeniedException("User " + userId + " is not business admin of task " + taskId);
}
long inputContentId = task.getTaskData().getDocumentContentId();
Content outputContent = persistenceContext.findContent(inputContentId);
Map<String, Object> initialContent = new HashMap<String, Object>();
Map<String, Object> mergedContent = values;
if (outputContent == null) {
ContentMarshallerContext mcontext = context.getTaskContentService().getMarshallerContext(task);
ContentData outputContentData = ContentMarshallerHelper.marshal(task, values, mcontext.getEnvironment());
Content content = TaskModelProvider.getFactory().newContent();
((InternalContent) content).setContent(outputContentData.getContent());
persistenceContext.persistContent(content);
((InternalTaskData) task.getTaskData()).setOutput(content.getId(), outputContentData);
} else {
ContentMarshallerContext mcontext = context.getTaskContentService().getMarshallerContext(task);
Object unmarshalledObject = ContentMarshallerHelper.unmarshall(outputContent.getContent(), mcontext.getEnvironment(), mcontext.getClassloader());
if (unmarshalledObject != null && unmarshalledObject instanceof Map) {
// set initial content with data from storage before being altered by this values
initialContent.putAll((Map<String, Object>) unmarshalledObject);
((Map<String, Object>) unmarshalledObject).putAll(values);
mergedContent = ((Map<String, Object>) unmarshalledObject);
}
ContentData outputContentData = ContentMarshallerHelper.marshal(task, unmarshalledObject, mcontext.getEnvironment());
((InternalContent) outputContent).setContent(outputContentData.getContent());
persistenceContext.persistContent(outputContent);
}
taskEventSupport.fireBeforeTaskInputVariablesChanged(task, context, initialContent);
((InternalTaskData) task.getTaskData()).setTaskInputVariables(mergedContent);
taskEventSupport.fireAfterTaskInputVariablesChanged(task, context, mergedContent);
return null;
}
Aggregations