public Content getContentById(long contentId) { return persistenceContext.findContent(contentId); }
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; }
@Override public Content getContentByIdForUser( long contentId, String userId ) { long taskId = persistenceContext.findTaskIdByContentId(contentId); // check permissions this.lifeCycleManager.taskOperation(Operation.View, taskId, userId, null, null, toGroups(null)); return this.persistenceContext.findContent(contentId); }
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); }
public void deleteAttachment(long taskId, long attachmentId) { Task task = persistenceContext.findTask(taskId); Attachment attachment = persistenceContext.removeAttachmentFromTask(task, attachmentId); Content content = persistenceContext.findContent(attachment.getAttachmentContentId()); persistenceContext.removeContent(content); }
@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; }
public int removeTasks(List<TaskSummary> tasks) { int removedTasks = 0; for (TaskSummary sum : tasks) { long taskId = sum.getId(); // Only remove archived tasks Task task = persistenceContext.findTask(taskId); if (task != null) { Content content = persistenceContext.findContent(task.getTaskData().getDocumentContentId()); Content outputContent = persistenceContext.findContent(task.getTaskData().getOutputContentId()); if (((InternalTask) task).isArchived()) { persistenceContext.remove(task); if (content != null) { persistenceContext.remove(content); } if (outputContent != null) { persistenceContext.remove(outputContent); } removedTasks++; } else { logger.warn(" The Task cannot be removed if it wasn't archived first !!"); } } } return removedTasks; }
public void deleteFault(long taskId, String userId) { Task task = persistenceContext.findTask(taskId); long contentId = task.getTaskData().getFaultContentId(); Content content = persistenceContext.findContent(contentId); FaultData data = TaskModelProvider.getFactory().newFaultData(); persistenceContext.removeContent(content); persistenceContext.setFaultToTask(null, data, task); }
public void deleteOutput(long taskId, String userId) { Task task = persistenceContext.findTask(taskId); long contentId = task.getTaskData().getOutputContentId(); Content content = persistenceContext.findContent(contentId); Map<String, Object> initialContent = new HashMap<>(); ContentMarshallerContext context = TaskContentRegistry.get().getMarshallerContext(task); Object unmarshalledObject = ContentMarshallerHelper.unmarshall(content.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); } taskEventSupport.fireBeforeTaskOutputVariablesChanged(task, this.context, initialContent); ContentData data = TaskModelProvider.getFactory().newContentData(); persistenceContext.removeContent(content); persistenceContext.setOutputToTask(null, data, task); taskEventSupport.fireAfterTaskOutputVariablesChanged(task, this.context, null); }
@Override public Map<String, Object> getContentMapForUser( Long taskId, String userId ) { // check permissions this.lifeCycleManager.taskOperation(Operation.View, taskId, userId, null, null, toGroups(null)); Task task = this.persistenceContext.findTask(taskId); if( task.getTaskData() != null && task.getTaskData().getOutputContentId() != null ) { Content content = this.persistenceContext.findContent(task.getTaskData().getOutputContentId()); ContentMarshallerContext mContext = TaskContentRegistry.get().getMarshallerContext(task); Object outputContent = ContentMarshallerHelper.unmarshall(content.getContent(), mContext.getEnvironment(), mContext.getClassloader()); if( outputContent instanceof Map ) { return (Map<String, Object>) outputContent; } else { throw new IllegalStateException("Output content for task " + taskId + " is not a Map<String, Object>!"); } } return null; }
Content content = persistenceContext.findContent(taskData.getDocumentContentId());
loadTaskVariables(task); long outputContentId = task.getTaskData().getOutputContentId(); Content outputContent = persistenceContext.findContent(outputContentId);