Extend Queries for e.g. CaseInstance

Hello everyone,
I would like to be able to filter for unassigned cases (cases without any identylink of type ASSIGNEE). I can relatively easily do that on the database by using a where not exists(select 1 from ACT_RU_IDENTITYLINK … ) clause. However I see no easy way how to hook that into flowable such that I can still use the CmmnRuntimeService and its configuration.
Am I missing something? What would be a reasonable way of writing such an extension? I expect this will not be the last time that I would like to query something outside of what the predefine mybatis queries support.
Would I have to open PRs in github for them? What if they are not very generally useful and rather specific for my usecase?

Of course I could read all cases and filter in memory but that sounds like a very unreasonable thing to do performance and resource wise.

Thanks in advance
Philippe

Hi,

use custom sql query.

Examples for tasks, but can be used in the same way for cases:

Regards

Martin

The best work around would be to set a case variable "“owner” when owner is assigned. You can then use something like:
cmmnRuntimeService.createCaseInstanceQuery()
.variableNotExists(“owner”)
.list();

Cheers,
Greg

Thanks for the suggestion @gdharley, that sounds like a reasonable workaround, I’ll try that (and will mark the question as solved if I get it working).
I’ll probably also open a PR to allow native queries for cases, I don’t see why that would not work for cases but does work for most other things… thanks for the pointer @martin.grofcik

Cheers
Philippe

Hey @cdm-phm,

For things like this it would indeed be best to open PRs. Not sure what you have in mind, but some things could be done in a more generic way that would cover different usecases, similar like the variable query options and / or similar to what we have for the task queries.
e.g.

CaseInstanceQuery unassigned();

CaseInstanceQuery assigned();

CaseInstanceQuery withoutIdentityLinkType(String identityLinkType);

CaseInstanceQuery withIdentityLinkType(String identityLinkType);

For something more specific we already have something like

CaseInstanceQuery involvedUser(String userId, String identityLinkType);
    
CaseInstanceQuery involvedGroup(String groupId, String identityLinkType);

Cheers,
Filip

Hi @filiphr,

the withoutIdentityLinkType() is actually exactly what I had implemented :slight_smile:
Still, seeing that pretty much anything besides Case supports a selectXByNativeQuery I’d say it makes sense to add that one as well. I’ll try to find time to open an issue and a PR.