cancel
Showing results for 
Search instead for 
Did you mean: 

Recovery runtime task variables

rafaelduqueestr
Champ in-the-making
Champ in-the-making
First, the informations:

1- The table ACT_RU_TASK:


ID_, EXECUTION_ID_, PROC_ISNT_ID_, PROC_DEF_ID_, TASK_DEF_KEY_
35014, 35004, 35004, process:1:35003, checkCreate


2- The table ACT_RU_VARIABLE:


ID_, TYPE_, NAME_, EXECUTION_ID_, PROC_INST_ID_, TEXT_, TEXT2_
35006, string, nome, 35004, 35004, nome, <null>
35008, string, descricao, 35004, 35004, valor, <null>
35011, jpa-entity, param, 35004, 35004, domain.Param, 67


I need to get all variables with NAME_ = "param", but i couldn't do this with a single api call.
I had to call these methods:


…..
        List<Task> tasks = taskService.createTaskQuery().processDefinitionKey("process")
                .taskDefinitionKey("checkCreate")
                .list();

        Map<String, Object> variables = taskService.getVariables(tasks.get(0).getId());
……


I found this entry on stackoverflow: http://stackoverflow.com/questions/13881024/activiti-bpm-get-variables-within-task, but this was back in 2012.

Nowadays, is there a way to do this with one method call?
5 REPLIES 5

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

When you want to get all tasks where variable name/value is …. use:

  /**
   * Only select tasks which have a local task variable with the given name
   * set to the given value.
   */
  T taskVariableValueEquals(String variableName, Object variableValue);

Regards
Martin

rafaelduqueestr
Champ in-the-making
Champ in-the-making
Martin, hello, thanks for reply, but I don't want this.

I want to get all variables where variable name = "paramCreate" and process definition key = "processParam" and task definition key = "checkParam".

The variable "paramCreate" is a jpa-entity, I need to display a grid with all "params" with current task = "checkParam" for all managers. The "checkParam" is a user task for managers group.

rafaelduqueestr
Champ in-the-making
Champ in-the-making
I'm trying to use activiti query api, I'm avoiding to custom native queries.
I need to to this query:

<code>
select P.PARA_NM_PARAMETRO, P.PARA_VL_PARAMETRO
from PARAMETRO P, ACT_RU_VARIABLE V, ACT_RU_TASK T, ACT_RU_IDENTITYLINK I
where P.PARA_CD_PARAMETRO = V.TEXT2_ AND
      V.PROC_INST_ID_ = T.PROC_INST_ID_ AND
      T.TASK_DEF_KEY_ = 'avaliarInclusaoParametro' AND
      T.ID_ = I.TASK_ID_ AND
      I.TYPE_ = 'candidate' AND
      I.GROUP_ID_ = 'gerente'
</code>

The following code to this, but go N+1 times in database:

<java>
        List<Task> tarefasSobAvaliacao = taskService.createTaskQuery().processDefinitionKey("processParametro")
                .taskDefinitionKey("avaliarInclusaoParametro")
                .taskCandidateGroup("gerente")
                .list();
        List<Parametro> parametros = new ArrayList<>();
        for (Task tarefa : tarefasSobAvaliacao) {
            Map<String, Object> parametroMap = taskService.getVariables(tarefa.getId(), Lists.newArrayList("parametroCriado"));
            parametros.add((Parametro) parametroMap.get("parametroCriado"));
        }
</java>

Is there possible to to this using activiti query api?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Use query API or native queries
http://www.activiti.org/userguide/#queryAPI

Regards
Martin

rafaelduqueestr
Champ in-the-making
Champ in-the-making
Hi Martin,
I'm new with workflow frameworks and I don't know if is a good idea to combine domain tables and activiti tables in the same query.
What do you think?
I want to list tasks for the candidate groups in a grid, but the best information to present for the user is a domain data, but the fields of the domain data isn't in the activiti tables, in the activiti table has only a jpa entity. So I need to recovery datas from this jpa entity doing join queries … Is it a best solution, to combine domain tables with activiti tables doing native queries?