[midPoint] help with the midpoint query language in a java search

martin.spanik at evolveum.com martin.spanik at evolveum.com
Wed Jul 10 09:34:28 CEST 2024


Hello Steven,

You can build the query easier now with midPoint Query Language.

Your use-case can be resolved by this code (just define query string and build it using midpoint.queryFor(Class, String) method) :
                                    import com.evolveum.midpoint.xml.ns._public.common.common_3.*

                                    String queryStr = " roleMembershipRef matches (oid = "eb5f4f58-9bb7-46df-a669-e9423c99e436" and targetType = OrgType and relation = manager)"
                                    def query = midpoint.queryFor(UserType.class, queryStr)
                                    def result = midpoint.searchObjects(query)


You can find more examples for using MQL in scripts at: https://docs.evolveum.com/midpoint/reference/support-4.8/concepts/query/midpoint-query-language/query-language-in-groovy/


Best Regards,
Martin Spanik 
Senior Identity Engineer

-----Original Message-----
From: midPoint <midpoint-bounces at lists.evolveum.com> On Behalf Of Ashwill, Steven L via midPoint
Sent: utorok 9. júla 2024 20:56
To: midpoint at lists.evolveum.com
Cc: Ashwill, Steven L <sashwill at uillinois.edu>
Subject: [midPoint] help with the midpoint query language in a java search

Hello,
I have an advanced query that I use on the User page(see below) but I also need to find the same people in a java method.  Would anyone be able to give me an example? I have a sample below where I have performed another search.

This is the advance query I would like to use in JAVA:

roleMembershipRef matches (oid = "eb5f4f58-9bb7-46df-a669-e9423c99e436" and targetType = OrgType and relation = manager)

This is a simple example of a user search I've set up for another case:
ObjectFilter filter = QueryBuilder.queryFor(UserType.class, prismContext)
	.item(UserType.F_EMPLOYEE_NUMBER).eq(user.getEmployeeNumber())
	.buildFilter();
ObjectQuery query = ObjectQueryImpl.createObjectQuery(filter);
try {
	SearchResultList<PrismObject<UserType>> objects = this.modelService.searchObjects(UserType.class, query,(Collection) null, task, result);

Basically, I don't know how to build the filter.  Any help would be appreciated.

Thanks,

STEVEN L ASHWILL
Software Engineer Coordinator
Administrative Information Technology Services University of Illinois at Urbana-Champaign
50 Gerty Drive | M/C 673
Champaign, IL 61820
217.265.6337 | sashwill at uillinois.edu
www.aits.uillinois.edu
 


Under the Illinois Freedom of Information Act any written communication to or from university employees regarding university business is a public record and may be subject to public disclosure. 


_______________________________________________
midPoint mailing list
midPoint at lists.evolveum.com
https://lists.evolveum.com/mailman/listinfo/midpoint



More information about the midPoint mailing list