Search in sources :

Example 36 with InternalTaskData

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;
}
Also used : Task(org.kie.api.task.model.Task) ContentData(org.kie.internal.task.api.model.ContentData) HashMap(java.util.HashMap) Content(org.kie.api.task.model.Content) InternalContent(org.kie.internal.task.api.model.InternalContent) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) InternalContent(org.kie.internal.task.api.model.InternalContent) HashMap(java.util.HashMap) Map(java.util.Map) ContentMarshallerContext(org.kie.internal.task.api.ContentMarshallerContext)

Example 37 with InternalTaskData

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;
}
Also used : TaskInstanceView(org.jbpm.persistence.api.integration.model.TaskInstanceView) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData)

Example 38 with InternalTaskData

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;
}
Also used : TaskInstanceView(org.jbpm.persistence.api.integration.model.TaskInstanceView) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData)

Example 39 with InternalTaskData

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;
}
Also used : TaskInstanceView(org.jbpm.persistence.api.integration.model.TaskInstanceView) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData)

Example 40 with InternalTaskData

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;
}
Also used : TaskInstanceView(org.jbpm.persistence.api.integration.model.TaskInstanceView) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) Attachment(org.kie.api.task.model.Attachment)

Aggregations

InternalTaskData (org.kie.internal.task.api.model.InternalTaskData)45 InternalTask (org.kie.internal.task.api.model.InternalTask)23 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)22 Task (org.kie.api.task.model.Task)22 Test (org.junit.Test)21 User (org.kie.api.task.model.User)20 InternalPeopleAssignments (org.kie.internal.task.api.model.InternalPeopleAssignments)20 InternalContent (org.kie.internal.task.api.model.InternalContent)15 ContentData (org.kie.internal.task.api.model.ContentData)14 InternalOrganizationalEntity (org.kie.internal.task.api.model.InternalOrganizationalEntity)14 ArrayList (java.util.ArrayList)13 InputStreamReader (java.io.InputStreamReader)11 Reader (java.io.Reader)11 HashMap (java.util.HashMap)10 CountDownTaskEventListener (org.jbpm.services.task.util.CountDownTaskEventListener)10 Date (java.util.Date)7 StringReader (java.io.StringReader)6 WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)6 Content (org.kie.api.task.model.Content)6 Map (java.util.Map)5