cancel
Showing results for 
Search instead for 
Did you mean: 

uniquely identifying user task form process instances

rhiremat
Champ in-the-making
Champ in-the-making
Hello fellow activitiers,

I have following questions, appreciate your help on these..

Question 1 : Is the Business Key unique among all process instances running/completed/suspended, etc?

Question 2 : I am making a following query :
Execution execution = processEngine.getRuntimeService().createExecutionQuery().processInstanceBusinessKey(
                myObject.getBusinessKey(), true).activityId(myObject.getActivityId ()).singleResult();

Here, myObject is a custom class with methods getBusinessKey and getActivityId returning the respective Business Key and user task id.

activityId that is returned by getActivityId is that of a “current” “active” “user task” form the process whose “business key” is returned form the getBusinessKey. If the “user task” represented by this ActivityId is not the current active task in the process, this should return NULL. Is this valid understanding?

Question 3 : Among all running process instances a given user tasks’s ID returned by tasks.getId() would always be the same, is this the current understanding? Does this mean, this is actually a task design db id?

Question 4 : If #3 understanding is correct, the only way by which we can uniquely identify a process is by making a query to the process and then querying the user task id, is this the current understanding? Are there any other means to do it?


-Raj
1 REPLY 1

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Raj,

Question 1 : Is the Business Key unique among all process instances running/completed/suspended, etc?


/**
   * Starts a new process instance in the latest version of the process
   * definition with the given key.
   *
   * A business key can be provided to associate the process instance with a
   * certain identifier that has a clear business meaning. For example in an
   * order process, the business key could be an order id. This business key can
   * then be used to easily look up that process instance , see
   * {@link ProcessInstanceQuery#processInstanceBusinessKey(String)}. Providing
   * such a business key is definitely a best practice.
   *
   * Note that a business key MUST be unique for the given process definition.
   * Process instance from different process definition are allowed to have the
   * same business key.
   *
   * The combination of processdefinitionKey-businessKey must be unique.
   *
   * @param processDefinitionKey
   *          key of process definition, cannot be null.
   * @param businessKey
   *          a key that uniquely identifies the process instance in the context
   *          or the given process definition.
   * @throws ActivitiObjectNotFoundException
   *           when no process definition is deployed with the given key.
   */
  ProcessInstance startProcessInstanceByKey(String processDefinitionKey, String businessKey);
but this behavior has changed in 5.15
http://forums.activiti.org/content/activiti-didnt-check-uniqueness-businesskey


Question 2 : I am making a following query :


  /**
   * Executes the query and returns the resulting entity or null if no
   * entity matches the query criteria.
   * @throws ActivitiException when the query results in more than one
   * entities.
   */
  U singleResult();


Question 3 : Among all running process instances a given user tasks’s ID returned by tasks.getId() would always be the same, is this the current understanding? Does this mean, this is actually a task design db id?
task.getId() - returns unique id of the task. (Unique means only one in the process engine.)


  /** DB id of the task. */
String getId();

Regards
Martin