-
1. Re: CustormWorkItemEditor + ObjectDataType("MyDomainClass"): Always getting String instead of MyDomainClass in WorkItem
calca Jan 31, 2012 6:03 AM (in response to sebb)Hi Sebb,
how are you passing the parameter to the node in your bpmn file?
Demian
-
2. Re: CustormWorkItemEditor + ObjectDataType("MyDomainClass"): Always getting String instead of MyDomainClass in WorkItem
sebb Jan 31, 2012 6:30 AM (in response to calca)Hi Demian,
I use my ServiceTask with my CustomWorkItemEditor to pass the parameters to the node (reduced to one parameter for this code example):
public class MyDialog extends EditBeanDialog implements WorkEditor{
Text myText;
public MyDialog(Shell parentShell) {
super (parentShell, "title");
setBlockOnOpen(true);
}
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);
Work work = (Work) getValue();
Label label = new Label(composite, SWT.NONE);
label.setText("labelOne:");
GridDataFactory.fillDefaults().applyTo(label);
myText = new Text(composite, SWT.NONE);
//get current value from node
MyDomainClass mdc = (MyDomainClass) work.getParameter("myParameter");
if(mdc != null){
Value value = mdc.getValue();
myText.setText(value == null ? "" : value.toString());
} else {
myText.setText("");
}
GridDataFactory.fillDefaults().applyTo(myText);
}
protected Object updateValue(Object value) {
Work work = new WorkImpl();
work.setName(((Work) value).getName());
MyDomainClass mdc = new MyDomainClass();
mdc.setValue(myText.getText());
work.setParameter("myParameter", mdc);
work.setParameterDefinitions(((Work) value).getParameterDefinitions());
return work;
}
public Work getWork() {
return (Work) getValue();
}
public void setWork(Work work) {
setValue(work);
}
public void setWorkDefinition(WorkDefinition workDefinition) {
}
public boolean show() {
int result = open();
return result == OK;
}
}
WorkItemDefinition (reduced to one parameter for this code example):
[
[
"name" : "MyServiceTask",
"parameters" : [
"myParameter" : new ObjectDataType("my.package.MyDomainClass"),
],
"displayName" : "do fancy stuff",
"customEditor" : "my.package.MyDialog"
],
]
-
3. Re: CustormWorkItemEditor + ObjectDataType("MyDomainClass"): Always getting String instead of MyDomainClass in WorkItem
sebb Jan 31, 2012 9:40 AM (in response to sebb)I just figured, that the problem does not start in the WorkItemHandler:
See the code part with the comment: "//get current value from node"?
There it happens also while editing my process. If I press OK to save my ServiceTask I cant open it again, because I dont get myDomainClassInstance, but a String object with the toString() representation of myDomainClassInstance...
protected Control createDialogArea(Composite parent) {
[...]
//get current value from node
MyDomainClass mdc = (MyDomainClass) work.getParameter("myParameter");
[...]
This code results to a ClassCastException because work.getParameter("myParameter") returns the above mentioned String.
edit:
Ok, I maybe found the problem. Since everything that is edited in my custom editor is pasted into the bpmn xml, I will never be able to get an object back from the process definition. As far as I can see I have to override the toString() method and create a parseable string that I can use to recreate the object I passed to the node.
edit2:
Now I am parsing my objects into json and save the json string in the bpmn file. Seems to work so far. But is this really the way to handle all parameters that are not Strings?
Any opinions on this?
-
4. Re: CustormWorkItemEditor + ObjectDataType("MyDomainClass"): Always getting String instead of MyDomainClass in WorkItem
sebb Feb 2, 2012 3:09 AM (in response to sebb)So this is the right way of handling domain objects in jbpm?
-
5. Re: CustormWorkItemEditor + ObjectDataType("MyDomainClass"): Always getting String instead of MyDomainClass in WorkItem
annah Mar 23, 2012 7:28 AM (in response to sebb)Hi!
I have the exact same problem. I'm trying to pass an object of my custom class as a workItem parameter. Is this really the way to handle ObjectDataType parameters?