[midPoint] Groovy Expression - ObjectQuery - Midpoint 4.0+

Loïc Schamber lschamber at positivethinking.tech
Fri Oct 30 15:35:00 CET 2020


Hi everybody,

Today I needed to retrieve the list of all approver for a role in a groovy Script ( For a policy rule  constraint), sadly I struggle to achieve my goal.
I already have my RoleType object and all I need to do is to find all approver for it.

I looked thought the Javadoc do find a way to retrieve this information. There is no method on RoleType objects, nor in the MidpointFunction interface. So I wated to use “midpoint.searchObjects<https://www.evolveum.com/downloads/midpoint/4.1/midpoint-api-4.1-javadoc/com/evolveum/midpoint/model/api/expr/MidpointFunctions.html#searchObjects(java.lang.Class,com.evolveum.midpoint.prism.query.ObjectQuery)>​(Class<https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html?is-external=true><T> type, ObjectQuery<https://www.evolveum.com/downloads/midpoint/4.1/midpoint-api-4.1-javadoc/com/evolveum/midpoint/prism/query/ObjectQuery.html> query)” method but I don’t understand how to create the ObjectQuery.

I looked on the documentation / Mailing list archive:

  *   https://wiki.evolveum.com/display/midPoint/Query+API#QueryAPI-Filterclassification
  *   https://lists.evolveum.com/pipermail/midpoint/2015-March/000938.html
  *   https://lists.evolveum.com/pipermail/midpoint/2018-October/005030.html
But I fear they may not be accurate anymore.

According to the Documentation there is two way to create ObjectQuery objects:

·         Traditional Java API : ObjectQuery.createObjectQuery(AllFilter.createAll());

·         Fluent Java API: QueryBuilder.queryFor(UserType.class,midpoint.getPrismContext()).item(UserType.F_ROLE_MEMBERSHIP_REF).ref("xxxxxxxx-0000-0000-0000-xxxxxxxxxxxx").build();


However I cannot find QueryBuilder or ObjectQuery classes in the 4.0+ documentation. It seems that they were located in the packages “com.evolveum.midpoint.prism.query” and “com.evolveum.midpoint.prism.query.builder” until 4.0.
In 4.0 there interfaces that replaces theses classes. I searched for a prism.query.impl packages, with no success either.

Can you explain me how we should use the searchObjects method in 4.0+?
Moreover I am not sure how to specify “approver” relationship with the JAVA API, so any advice would be appreciated.

Thanks a lot,

Best regards.



[logo]<https://www.positivethinking.tech/>

Loïc Schamber  | IT Consultant
lschamber at positivethinking.tech<mailto:lschamber at positivethinking.tech>
Tel. +41 22 721 07 77<tel:+41%2022%20721%2007%2077>  | Direct. +41 22 555 27 69<tel:+41%2022%20555%2027%2069>


[LinkedIn]<https://www.linkedin.com/company/the-positive-thinking-company/>  [Instagram] <https://www.instagram.com/positivethinkingcompany/>   [Vimeo] <https://twitter.com/PTC_Tech>   [Vimeo] <https://youtube.com/channel/UCfaImWa6r0IoZoUYLhbiF7w>
Chemin du Pré-Fleuri 5 – CH 1228 Plan-les-Ouates
________________________________
Help save paper, do you really need to print this email?
The content of this email and any attachments are confidential and are intended solely for the person and/or company to whom they are addressed. The information may also be legally privileged. No employee or agent is authorized to conclude any binding agreement on behalf of Positive Thinking Company with another party by email without express written confirmation. If you have received this email in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by return E-mail and delete this message, its attachments and all copies from your system. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions. Thank you for your cooperation.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20201030/d4a0ca25/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 7735 bytes
Desc: image001.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20201030/d4a0ca25/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 2337 bytes
Desc: image002.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20201030/d4a0ca25/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 2756 bytes
Desc: image003.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20201030/d4a0ca25/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 2358 bytes
Desc: image004.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20201030/d4a0ca25/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 2669 bytes
Desc: image005.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20201030/d4a0ca25/attachment-0009.png>


More information about the midPoint mailing list