use of org.kie.api.task.model.Content in project jbpm by kiegroup.
the class LifeCycleBaseTest method testNewTaskWithLargeContent.
@Test
public void testNewTaskWithLargeContent() {
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet') ],businessAdministrators = [ new User('Administrator') ], }),";
str += "name = 'This is my task name' })";
String largeContent = "";
for (int i = 0; i < 1000; i++) {
largeContent += i + "xxxxxxxxx";
}
ContentData data = ContentMarshallerHelper.marshal(null, largeContent, null);
Task task = TaskFactory.evalTask(new StringReader(str));
taskService.addTask(task, data);
long taskId = task.getId();
// Task should be assigned to the single potential owner and state set to Reserved
Task task1 = taskService.getTaskById(taskId);
assertEquals(AccessType.Inline, ((InternalTaskData) task1.getTaskData()).getDocumentAccessType());
assertEquals("java.lang.String", task1.getTaskData().getDocumentType());
long contentId = task1.getTaskData().getDocumentContentId();
assertTrue(contentId != -1);
Content content = taskService.getContentById(contentId);
Object unmarshalledObject = ContentMarshallerHelper.unmarshall(content.getContent(), null);
assertEquals(largeContent, unmarshalledObject.toString());
xmlRoundTripContent(content);
}
use of org.kie.api.task.model.Content in project jbpm by kiegroup.
the class LifeCycleBaseTest method getTaskOutput.
protected Map<String, Object> getTaskOutput(Task task) {
long documentContentId = task.getTaskData().getOutputContentId();
if (documentContentId > 0) {
Content contentById = taskService.getContentById(documentContentId);
if (contentById == null) {
return new HashMap<String, Object>();
}
Object unmarshall = ContentMarshallerHelper.unmarshall(contentById.getContent(), null);
return (Map<String, Object>) unmarshall;
}
return new HashMap<String, Object>();
}
use of org.kie.api.task.model.Content in project jbpm by kiegroup.
the class TaskInstanceServiceImpl method setOutput.
public void setOutput(long taskId, String userId, Object outputContentData) {
Task task = persistenceContext.findTask(taskId);
ContentData contentData = ContentMarshallerHelper.marshal(task, outputContentData, environment);
Content content = TaskModelProvider.getFactory().newContent();
((InternalContent) content).setContent(contentData.getContent());
persistenceContext.persistContent(content);
persistenceContext.setOutputToTask(content, contentData, task);
}
use of org.kie.api.task.model.Content in project jbpm by kiegroup.
the class TaskInstanceServiceImpl method setFault.
public void setFault(long taskId, String userId, FaultData fault) {
Task task = persistenceContext.findTask(taskId);
Content content = TaskModelProvider.getFactory().newContent();
((InternalContent) content).setContent(fault.getContent());
persistenceContext.persistContent(content);
persistenceContext.setFaultToTask(content, fault, task);
}
use of org.kie.api.task.model.Content in project jbpm by kiegroup.
the class TaskInstanceServiceImpl method deleteOutput.
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);
}
Aggregations