Task - Start - Assign - Execute latest version...

1
0
-1

Hi there,

Bonita Studio 6.3.3, Java 1.7.0.67, Windows 8.1

as previously stated relatively new to Java and its convoluted way of doing things (and never really understanding javadoc documentation (just not enough examples))...I love COBOL, VBA and Assembler...and PL/S if you've ever heard of it...

Anyway following the various examples I'm very slowly getting to the point of success, but having an issue with starting tasks....

1) What is the difference between startProcess and executeFlowNode which both execute a process?

2) When assigning a task to specific individual which is best to use startProcess or executeFlowNode?

3) I've managed to hard code my groovy as follows:

  1. String task = "ABC"
  2. String processVersion = "1.0"
  3.  
  4. processId = processAPI.getProcessDefinitionId(task, processVersion);
  5. processAPI.startProcess(processId);

But I want the latest version of the process, not the hardcoded version.

getProcessDefinition requires a long, which comes from getProcessDefinitionId(process, processVersion)

But there's the problem I haven't got the latest ProcessVersion...I obviously don't understand something...how do I get the latest version of the process so I can get the right processID...

4: I'm following get-possible-users-task-and-execute-task-user

and have a couple of questions:

  1. final ProcessInstance processInstance = getProcessAPI().startProcess(processDefinition.getId());
  2. final HumanTaskInstance userTask = waitForUserTask("step1", processInstance);

4.1 Start the process, and wait for it to initialize (I think). Where it says "step1", this is the first task in the pool, but how do we specify wait for the pool as this is where the first form is? Do I just specify the pool name?

4.2 In the example there is activityID, where does this come from as it's not referenced elsewhere in the code...

  1. // Execute task for first user in list
  2. processAPI.assignUserTask(activityId, possibleUsers.get(0).getId());
  3. processAPI.executeFlowNode(possibleUsers.get(0).getId(), activityId)

Sorry for my lack of learning, I'm trying though.

thanks and regards Seán

1 answer

1
0
-1
This one is the BEST answer!

Hi, 1) starProcess create a new instance of a process definition using it's id and executeFlowNode execute a flow node (e.g. a user task) the is in a stable state (e.g. the user task is "pending"). For executeFlowNode you give the id of the task not the id of the process

2) use executeFlowNode as explained in 1) 3) you can use processAPI.getProcessDeploymentInfos that return all process definitions. With that you can search for all process having the name you want and then select the one with the biggest version. 4.1) here we wait for the user task "step1" of the process instance to be ready. The pool IS the processInstance. 4.2) there is a mistake here, activityId =userTask.getId()

Comments

Submitted by Sean McP on Tue, 09/23/2014 - 05:59

Many thanks Baptiste,

that explains a lot and also identifies a problem for me. I keep getting process and task mixed up, yes even now, anyway...

I have two processes, process1 with initiator Actor, and process2 with initiator Actor and Employee Actor.

Process1 is Pool1 Form, Step1 form and Step2 form. Process2 is Pool2 Form, Step3 form and Step4 form.

In process1 I have an application task where (depending on other criteria) a Checkbox List is shown of potential executors of process2. The initiator selects which of the people in the Checkbox List are to be chosen to execute process2.

process2 also has a pool application form, this is necessary because of the requirement for a confirmation message (which we do not want). There seems no way around it.

I've looked at the Actor Filter, but still not clear on what it does. From my reading the way it works is it takes in criteria, we process the criteria and then return a list of selected users. The system then takes this list of users and assigns the process to them all...is this correct?

The way I'm thinking this could work is, your thoughts appreciated,

  1. process1 - application - user selects USR1, USR3 and USR9
  2. process1 - Submit - Action - save selection to list
  3. process1 - sendMessage with list of selected users starting process2

  4. process2 - pool starts and has Actor Filter AF1

  5. process2 - AF1 reads selected user list
  6. process2 - AF1 returns selected users to process and assigns 3 processes, one to each user...

But process2 does not have Actor Filters...

So what do I do have you any thoughts, comments/suggestions?

Many thanks and best regards Seán

Submitted by Sean McP on Tue, 09/23/2014 - 17:02

Hi Baptiste,

thanks again, but is there anything more efficient than this?

3) you can use processAPI.getProcessDeploymentInfos that return all process definitions. With that you can search for all process having the name you want and then select the one with the biggest version.

This is the code I have...

  1. String process = "ABCDEFG";
  2. String latestVersion = "";
  3. Integer finishedTasks = 0;
  4.  
  5. List<ProcessDeploymentInfo> shortProcessSet;
  6. List<ProcessDeploymentInfo> processSet = processAPI.getProcessDeploymentInfos(0, 10, ProcessDeploymentInfoCriterion.NAME_ASC);
  7.  
  8. for ( p in processSet) {
  9. if(p.getName().toString().equals(process)){
  10. shortProcessSet.add(p);
  11. finishedTasks = process.compareTo(p.getName().toString());
  12. if (finishedTask < 0){
  13. }
  14. }
  15. double topValue = "0.0";
  16. for (p1 in shortProcessSet){
  17. if (Double.parseDouble(p1.getVersion() > topValue){
  18. topValue = Double.parseDouble(p1.getVersion());
  19. }
  20. }
  21. latestVersion = Double.toString(topValue);

I have more than 1,000 (one thousand) processes at version 1.0 and I can't execute this every-time I need to get an actor...this would just get to be a bigger problem every-time I generate v1.1, v1.2, v2.0 etc.

Many thanks and best regards Seán

Notifications