use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class TaskContentServiceImpl method addOutputContent.
@SuppressWarnings("unchecked")
public long addOutputContent(long taskId, Map<String, Object> params) {
Task task = persistenceContext.findTask(taskId);
loadTaskVariables(task);
long outputContentId = task.getTaskData().getOutputContentId();
Content outputContent = persistenceContext.findContent(outputContentId);
Map<String, Object> initialContent = new HashMap<>();
long contentId = -1;
if (outputContent == null) {
ContentMarshallerContext context = getMarshallerContext(task);
ContentData outputContentData = ContentMarshallerHelper.marshal(task, params, context.getEnvironment());
Content content = TaskModelProvider.getFactory().newContent();
((InternalContent) content).setContent(outputContentData.getContent());
persistenceContext.persistContent(content);
persistenceContext.setOutputToTask(content, outputContentData, task);
contentId = content.getId();
} else {
// I need to merge it if it already exist
ContentMarshallerContext context = getMarshallerContext(task);
Object unmarshalledObject = ContentMarshallerHelper.unmarshall(outputContent.getContent(), context.getEnvironment(), context.getClassloader());
if (unmarshalledObject != null && unmarshalledObject instanceof Map) {
// set initial content before updating with this params
initialContent.putAll((Map<String, Object>) unmarshalledObject);
((Map<String, Object>) unmarshalledObject).putAll(params);
}
ContentData outputContentData = ContentMarshallerHelper.marshal(task, unmarshalledObject, context.getEnvironment());
((InternalContent) outputContent).setContent(outputContentData.getContent());
persistenceContext.persistContent(outputContent);
contentId = outputContentId;
}
taskEventSupport.fireBeforeTaskOutputVariablesChanged(task, context, initialContent);
((InternalTaskData) task.getTaskData()).setTaskOutputVariables(params);
taskEventSupport.fireAfterTaskOutputVariablesChanged(task, context, params);
persistenceContext.updateTask(task);
return contentId;
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class JPATaskPersistenceContext method removeCommentFromTask.
@Override
public Comment removeCommentFromTask(Comment comment, Task task) {
((InternalTaskData) task.getTaskData()).removeComment(comment.getId());
EventManagerProvider.getInstance().get().update(new TaskInstanceView(task));
return comment;
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class JPATaskPersistenceContext method addCommentToTask.
@Override
public Comment addCommentToTask(Comment comment, Task task) {
((InternalTaskData) task.getTaskData()).addComment(comment);
EventManagerProvider.getInstance().get().update(new TaskInstanceView(task));
return comment;
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class JPATaskPersistenceContext method addAttachmentToTask.
@Override
public Attachment addAttachmentToTask(Attachment attachment, Task task) {
((InternalTaskData) task.getTaskData()).addAttachment(attachment);
EventManagerProvider.getInstance().get().update(new TaskInstanceView(task));
return attachment;
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class JPATaskPersistenceContext method removeAttachmentFromTask.
@Override
public Attachment removeAttachmentFromTask(Task task, long attachmentId) {
Attachment removed = ((InternalTaskData) task.getTaskData()).removeAttachment(attachmentId);
EventManagerProvider.getInstance().get().update(new TaskInstanceView(task));
return removed;
}
Aggregations