Search in sources :

Example 1 with TaskVariableImpl

use of org.jbpm.services.task.audit.impl.model.TaskVariableImpl in project jbpm by kiegroup.

the class PersonTaskVariablesIndexer method index.

@Override
public List<TaskVariable> index(String name, Object variable) {
    Person person = (Person) variable;
    List<TaskVariable> indexed = new ArrayList<TaskVariable>();
    TaskVariableImpl personNameVar = new TaskVariableImpl();
    personNameVar.setName("person.name");
    personNameVar.setValue(person.getName());
    indexed.add(personNameVar);
    TaskVariableImpl personAgeVar = new TaskVariableImpl();
    personAgeVar.setName("person.age");
    personAgeVar.setValue(person.getAge() + "");
    indexed.add(personAgeVar);
    return indexed;
}
Also used : TaskVariableImpl(org.jbpm.services.task.audit.impl.model.TaskVariableImpl) TaskVariable(org.kie.internal.task.api.TaskVariable) ArrayList(java.util.ArrayList) Person(org.jbpm.services.task.audit.service.objects.Person)

Example 2 with TaskVariableImpl

use of org.jbpm.services.task.audit.impl.model.TaskVariableImpl in project jbpm by kiegroup.

the class StringTaskVariableIndexer method index.

@Override
public List<TaskVariable> index(String name, Object variable) {
    List<TaskVariable> indexed = new ArrayList<TaskVariable>();
    TaskVariableImpl taskVariable = new TaskVariableImpl();
    taskVariable.setName(name);
    taskVariable.setValue(variable.toString());
    indexed.add(taskVariable);
    return indexed;
}
Also used : TaskVariableImpl(org.jbpm.services.task.audit.impl.model.TaskVariableImpl) TaskVariable(org.kie.internal.task.api.TaskVariable) ArrayList(java.util.ArrayList)

Example 3 with TaskVariableImpl

use of org.jbpm.services.task.audit.impl.model.TaskVariableImpl in project jbpm by kiegroup.

the class TaskAuditQueryModificationService method createPredicate.

/*
     * (non-Javadoc)
     * @see org.jbpm.query.jpa.service.QueryModificationService#createPredicate(org.jbpm.query.jpa.data.QueryCriteria, javax.persistence.criteria.CriteriaQuery, javax.persistence.criteria.CriteriaBuilder)
     */
public <R> Predicate createPredicate(QueryCriteria criteria, CriteriaQuery<R> query, CriteriaBuilder builder) {
    // subquery and root
    Root<TaskImpl> taskRoot = getRoot(query, TaskImpl.class);
    Subquery<Long> subQuery = query.subquery(Long.class);
    Root<TaskVariableImpl> taskVarRoot = subQuery.from(TaskVariableImpl.class);
    subQuery.select(taskVarRoot.get(TaskVariableImpl_.taskId));
    // task variable predicate (in subquery)
    Predicate taskVariablePredicate = null;
    String listId = criteria.getListId();
    if (TASK_VARIABLE_COMBINED_ID.equals(listId)) {
        List<QueryCriteria> taskVarSubCriteriaList = criteria.getCriteria();
        int size = taskVarSubCriteriaList.size();
        Predicate[] taskVarSubPredicates = new Predicate[size];
        for (int i = 0; i < size; ++i) {
            taskVarSubPredicates[i] = createSingleTaskVariableCriteriaPredicate(builder, taskVarRoot, taskVarSubCriteriaList.get(i));
        }
        taskVariablePredicate = builder.and(taskVarSubPredicates);
    } else {
        taskVariablePredicate = createSingleTaskVariableCriteriaPredicate(builder, taskVarRoot, criteria);
    }
    // add predicate to subquery
    subQuery.where(taskVariablePredicate);
    // create predicate for actual query that references subquery
    return taskRoot.get(TaskImpl_.id).in(subQuery);
}
Also used : TaskVariableImpl(org.jbpm.services.task.audit.impl.model.TaskVariableImpl) TaskImpl(org.jbpm.services.task.impl.model.TaskImpl) QueryCriteria(org.jbpm.query.jpa.data.QueryCriteria) Predicate(javax.persistence.criteria.Predicate)

Aggregations

TaskVariableImpl (org.jbpm.services.task.audit.impl.model.TaskVariableImpl)3 ArrayList (java.util.ArrayList)2 TaskVariable (org.kie.internal.task.api.TaskVariable)2 Predicate (javax.persistence.criteria.Predicate)1 QueryCriteria (org.jbpm.query.jpa.data.QueryCriteria)1 Person (org.jbpm.services.task.audit.service.objects.Person)1 TaskImpl (org.jbpm.services.task.impl.model.TaskImpl)1