示例#1
0
  public List<Content> getAllContentByTaskId(long taskId) {
    Task task = persistenceContext.findTask(taskId);

    long inputContentId = task.getTaskData().getDocumentContentId();
    long outputContentId = task.getTaskData().getOutputContentId();
    long faultContentId = task.getTaskData().getFaultContentId();

    List<Content> allContent = new ArrayList<Content>();

    allContent.add(persistenceContext.findContent(inputContentId));
    allContent.add(persistenceContext.findContent(outputContentId));
    allContent.add(persistenceContext.findContent(faultContentId));

    return allContent;
  }
示例#2
0
  @SuppressWarnings("unchecked")
  private Map<String, Object> getVariables(
      TaskContext ctx, TaskPersistenceContext persistenceContext, Task task, TaskData taskData) {
    Map<String, Object> variables;
    Content content = persistenceContext.findContent(taskData.getDocumentContentId());

    if (content != null) {
      ContentMarshallerContext mContext = ctx.getTaskContentService().getMarshallerContext(task);
      Object objectFromBytes =
          ContentMarshallerHelper.unmarshall(
              content.getContent(), mContext.getEnvironment(), mContext.getClassloader());

      if (objectFromBytes instanceof Map) {
        variables = (Map<String, Object>) objectFromBytes;

      } else {

        variables = new HashMap<String, Object>();
        variables.put("content", objectFromBytes);
      }
    } else {
      variables = Collections.emptyMap();
    }
    return variables;
  }
示例#3
0
  @SuppressWarnings("unchecked")
  public long addOutputContent(long taskId, Map<String, Object> params) {
    Task task = persistenceContext.findTask(taskId);
    long outputContentId = task.getTaskData().getOutputContentId();
    Content outputContent = persistenceContext.findContent(outputContentId);

    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);

      ((InternalTaskData) task.getTaskData()).setOutput(content.getId(), outputContentData);
      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) {
        ((Map<String, Object>) unmarshalledObject).putAll(params);
      }
      ContentData outputContentData =
          ContentMarshallerHelper.marshal(task, unmarshalledObject, context.getEnvironment());
      ((InternalContent) outputContent).setContent(outputContentData.getContent());
      persistenceContext.persistContent(outputContent);
      contentId = outputContentId;
    }
    ((InternalTaskData) task.getTaskData()).setTaskOutputVariables(params);
    taskEventSupport.fireAfterTaskOutputVariablesChanged(task, context, params);

    return contentId;
  }
示例#4
0
 public Content getContentById(long contentId) {
   return persistenceContext.findContent(contentId);
 }
示例#5
0
 public void deleteDocumentContent(long taskId, long contentId) {
   Task task = persistenceContext.findTask(taskId);
   ((InternalTaskData) task.getTaskData()).setDocumentContentId(-1);
   Content content = persistenceContext.findContent(contentId);
   persistenceContext.removeContent(content);
 }