星兰 蒋 [
https://community.jboss.org/people/jiang_hoo] created the discussion
"Re: How to properly use ContentMarshallerHelper for Human Task Output in
JBPM5.3?"
To view the discussion, visit:
https://community.jboss.org/message/779860#779860
--------------------------------------------------------------
Hi Thomas, I'm sorry i thought you were in Beijing.
In my case,in fact i want to get the vars's value when i get a task by userid. And
these values are passed when i start a processinstance.
i set & get values all in myself application. no using the jbpm console. Also no
using marshall and unmarshall.
*Set values when start process:*
Map<String,Object> params = new HashMap<String,Object>();
params.put("sales", c.getCreateby());
params.put("contractno", c.getContractno());
params.put("details", c.getDetails());
params.put("amount", c.getAmount());
params.put(role.getRole(), leader.getName());
params.put("accoptor", list.get(0).getName());
getSession().startProcess(definitionId, processVars);
*Get values when get a task by userid:*
List<TaskSummary> t = sTaskService.getTasksAssignedAsTaskInitiator(idRef,
"en-UK");
if(null != t && t.size() > 0){
for(TaskSummary ts : t){
Object obj = getTaskContentInput(ts);
Map<?, ?> map = (Map<?, ?>) obj;
for (Map.Entry<?, ?> entry : map.entrySet()) {
System.out.println(entry.getKey() + " = " + entry.getValue());
}
tasks.add(new TaskRef(ts.getId(), ts.getProcessInstanceId() + "",
ts.getProcessId(),
ts.getName(), ts.getCreatedBy().getId(), ts.getStatus() == Status.Suspended,
ts.getStatus() != Status.Suspended));
}
}
*And the getTaskContentInput method as blow:*
public Object getTaskContentInput(TaskSummary taskSum) {
BlockingGetTaskResponseHandler handlerT = new BlockingGetTaskResponseHandler();
client.getTask(taskSum.getId(), handlerT);
Task task2 = handlerT.getTask();
TaskData taskData = task2.getTaskData();
BlockingGetContentResponseHandler handlerC = new
BlockingGetContentResponseHandler();
client.getContent(taskData.getDocumentContentId(), handlerC);
Content content = handlerC.getContent();
ByteArrayInputStream bais = new ByteArrayInputStream(
content.getContent());
try {
ObjectInputStream is = new ObjectInputStream(bais);
Object obj = null;
while ((obj = is.readObject()) != null) {
System.out.println("OBJECT: " + obj);
return obj;
}
} catch (Exception e) {
System.err.print("There was an error reading task input...");
e.printStackTrace();
return null;
}
return null;
}
Is My way right or wrong? Would you pls give some advice?
Thanks and Best Regards!
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/779860#779860]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]