So, long time waiting for reply,
I hope that is not a bad thing. any reply from any one in this forum moderators will be gracefully appreciated
The reason why you have to wait this long is probably because no one (probably including me) has a clue of what you really mean... But I am gonna try anyway.
If you want to use (a reference to) your car as a process variable in the process instance: yes you can. Or if you want to externalize the state info of your car into individual process variables of the process instance: yes you can.
It is all up to you.
I am very happy for your reply.
And I am sorry for you did not understand me. but I'll try to make it clear.
I want to create instance of this Process Definition. Then make the token to start at node #3 (which is do some maintenance to car) instead of start state without calling signal() method many time to go to node #3.
1. I want to create a Car process when admin login to add new car to the system.
2. Then after a time system manager login to rent this car.
3. after a period the manager login again to check that the car is return but need some maintenance.
I have seen your example that available with jBPM source, in this example there is something like this, but my case differs from that example, in my project I need to persiste Car POJO data with it's current state, the POJO data contains many attributes that are not supported using your instance variable that persisted in database in jbpm_variableinstance table such as Java Vector, Set, ArrayList, ...etc. Any way, variables and attributes of Car POJO will be persisted in Car Table, so we want not to persiste the token of process instance, and when manager login again retrieves the Car data and creates instance of Car Process Difinition and set the created token current node to node #3 (which is the state of the retrieved car) without make many signals to make token reachs this node.
By another mean, I want to make a synchronization between my POJO state and the created token state, because our project has offline booking module that can not persisted till my application connect to internet.
This is Urgent for us, it will make big difference in our project developing.
I still don't understand very well what you mean, but here we go again:
- To move the token around in your processdefinition you have to signal the token. If you have nodes where the process execution does not have to wait, use generic nodes instead of task nodes or states.
- To store the state of business objects like your car, you can use your normal way of doing things and use the id field of your car as a process variable in your process.
Sorry for late about reply but I am busy in my work to login and reply, any way I have found the answer what I am looking for but I can not explain it now; when I finish my tasks and get some time I will expose what I have experienced, I promise. I am appreciating your reply
here I am, back again
I hope that reply help any one who need this.
this is a pice of code that get car POJO from database, assuming that the car state now in state #2 which is "2.rent a car from warehouse."
//read definition XML file ProcessDefinition carProcessDefinition=ProcessDefinition.parseXmlResource(processDefFileName); //create new process instance from this definition ProcessInstance carProcessInstance=carProcessDefinition.createProcessInstance(); //get my car object from database Car car=carService.getCarById(carId); //get a state object in this process instance using the POJO object state //carState attribute in the car POJO is string that represent the node name //in the process definition. Node currentNode=(Node)carProcessDefinition.getNode(car.getCarState()); //now this will set the active (current) node of the process definition to equivalent //state of my CarPOJO class carProcessInstance.getRootToken().setNode(currentNode); //now we will signal to the next state which is doSomeMaintenance carProcessInstance.signal("doSomeMaintenance");
Thanks a lot,