Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Utility method to complete a task with results

  • Loading branch information...
commit 281d2b67507643b28a84eb44867c6db414841125 1 parent fc5b7a0
@krisv krisv authored
View
5 jbpm-human-task/src/main/java/org/jbpm/task/TaskService.java
@@ -16,7 +16,8 @@
package org.jbpm.task;
import java.util.List;
-import org.drools.runtime.process.WorkItemManager;
+import java.util.Map;
+
import org.jbpm.eventmessaging.EventKey;
import org.jbpm.eventmessaging.EventResponseHandler;
import org.jbpm.task.query.TaskSummary;
@@ -43,6 +44,8 @@
void complete(long taskId, String userId, ContentData outputData);
+ void completeWithResults(long taskId, String userId, Object results);
+
boolean connect();
boolean connect(String address, int port);
View
24 jbpm-human-task/src/main/java/org/jbpm/task/service/AsyncTaskServiceWrapper.java
@@ -15,11 +15,15 @@
*/
package org.jbpm.task.service;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
import java.util.List;
import org.jbpm.eventmessaging.EventKey;
import org.jbpm.eventmessaging.EventResponseHandler;
import org.jbpm.process.workitem.wsht.BlockingAddTaskResponseHandler;
+import org.jbpm.task.AccessType;
import org.jbpm.task.AsyncTaskService;
import org.jbpm.task.Attachment;
import org.jbpm.task.Comment;
@@ -161,6 +165,26 @@ public void complete(long taskId, String userId, ContentData outputData) {
}
}
+
+ public void completeWithResults(long taskId, String userId, Object results) {
+ ContentData contentData = null;
+ if (results != null) {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream out;
+ try {
+ out = new ObjectOutputStream(bos);
+ out.writeObject(results);
+ out.close();
+ contentData = new ContentData();
+ contentData.setContent(bos.toByteArray());
+ contentData.setAccessType(AccessType.Inline);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ complete(taskId, userId, contentData);
+ }
+
public boolean connect() {
return taskService.connect();
}
View
24 jbpm-human-task/src/main/java/org/jbpm/task/service/local/LocalTaskService.java
@@ -15,12 +15,16 @@
*/
package org.jbpm.task.service.local;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
import java.util.List;
import org.jbpm.eventmessaging.EventKey;
import org.jbpm.eventmessaging.EventResponseHandler;
import org.jbpm.eventmessaging.EventTriggerTransport;
import org.jbpm.eventmessaging.Payload;
+import org.jbpm.task.AccessType;
import org.jbpm.task.Attachment;
import org.jbpm.task.Comment;
import org.jbpm.task.Content;
@@ -73,6 +77,26 @@ public void complete(long taskId, String userId, ContentData outputData) {
taskServiceSession.taskOperation(Operation.Complete, taskId, userId, null, outputData, null);
}
+
+ public void completeWithResults(long taskId, String userId, Object results) {
+ ContentData contentData = null;
+ if (results != null) {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream out;
+ try {
+ out = new ObjectOutputStream(bos);
+ out.writeObject(results);
+ out.close();
+ contentData = new ContentData();
+ contentData.setContent(bos.toByteArray());
+ contentData.setAccessType(AccessType.Inline);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ complete(taskId, userId, contentData);
+ }
+
public boolean connect() {
//do nothing
return true;
Please sign in to comment.
Something went wrong with that request. Please try again.