cancel
Showing results for 
Search instead for 
Did you mean: 

taskService.createTaskQuery().or()

shiva_arunachal
Champ in-the-making
Champ in-the-making
Can you show the usage of
 or()
with an example since the javadoc seems to confuse me a bit.
The javadoc for
 or() 
method states the below:
All query clauses called will be added to a single or-statement. This or-statement will be included with the other already existing clauses in the query, joined by an 'and'. Calling endOr() will add all clauses to the regular query again. Calling or() after endOr() has been called will result in an exception.

5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
There are plenty examples in the source code in unit test.

But since I'm in such a good mood:

<code>
TaskQuery query = taskService.createTaskQuery().or().taskId(taskIds.get(0)).taskName("INVALID NAME").endOr();
</code>

shiva_arunachal
Champ in-the-making
Champ in-the-making
Thanks. It is clear now.. so it is basically like <code> (taskId(taskIds.get(0)) || taskName("INVALID NAME")) </code>.

jbarrez
Star Contributor
Star Contributor
Yup, that is correct

jonathan_amos
Champ in-the-making
Champ in-the-making
The syntax below does not work when i attempt to perform an or() search on 2 processvariables.

<java>
query = taskService.createTaskQuery().taskCandidateGroup(groupId).orderByExecutionId();  
query = query.or().processVariableValueLike("subjectIDRegCenter", (String) taskCriteriaSearchObject.getTaskSearchValue()).processVariableValueLike("subject2IDRegCenter", (String) taskCriteriaSearchObject.getTaskSearchValue()).endOr();                               
query = asc ? query.asc() : query.desc();  
return query.listPage(start, end);
</java>

Upon further inspection, i realize that queryVariableValues has a size of 1. I am unable to attach image from netbeans.

From the results returned, it seems to be performing an AND …not an OR.

So when value of subjectIDRegCenter and subject2IDRegCenter are the same, those results are the returned. But no results are returned when value of subjectIDRegCenter is different from subject2IDRegCenter. This defeats the purpose of the OR clause.

I would prefer not to use a nativequery. But if need be, i need some assistance/guidance on creating one.

jonathan_amos
Champ in-the-making
Champ in-the-making
I had to find some other way: I did this -

<java>
TaskQuery query = null;
TaskQuery query2 = null;
List<Task> tasks = new ArrayList<>();

query = taskService.createTaskQuery().taskCandidateGroup(groupId).orderByExecutionId();
query = query.processVariableValueEquals("subjectIDRegCenter", (String) taskCriteriaSearchObject.getTaskSearchValue());
query = asc ? query.asc() : query.desc();

query2 = taskService.createTaskQuery().taskCandidateGroup(groupId).orderByExecutionId();
query2 = query2.processVariableValueEquals("subject2IDRegCenter", (String) taskCriteriaSearchObject.getTaskSearchValue());
query2 = asc ? query2.asc() : query2.desc();

tasks = query.list();
tasks.addAll(query2.list());
return tasks;

</java>

The above works for me.
Using or() and concatenations performs AND queries.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.