import com.evolveum.midpoint.xml.ns._public.common.common_3.*
def query = midpoint.queryFor(UserType.class, "name startsWith 'a'")
Query Playground and Query Converter
This page shows you how you can experiment with midPoint Query Language (MQL) directly in midPoint, in Query playground, and how you can convert your XML queries to MQL in Query converter.
Query Playground
To experiment with a query:
-
Log into midPoint GUI as an administrator and select Query playground at the bottom of the main menu on the left.
-
In Query playground, select the Object type from which the query will be selecting. When searching in GUI, the object type is defined by the currently opened view. In Query playground, you need to define it manually.
Check Distinct if you only want to return unique objects, i.e. midPoint will eliminate duplicates and display each object only once. -
Type your query into the text area, or use a predefined query by selecting it in the Or use an example drop-down menu.
-
Click Translate to SQL query to preview the SQL query and parameters, or click Translate and execute to run the query directly.
Container value queries are not supported in Query playground. |
The distinct option is often essential to get the correct count of objects when searching in the Generic repository.
This is caused by the SQL Contrary to the Generic repository, the newer Native repository does not have these problems as it always uses the SQL |
Fluent API Script Translation
Query playground has a feature that translates queries from fluent API scripts. This enables you to debug the Groovy code for an expression directly in the GUI before using it:
-
Check Translate from Query API script, the expression text area will appear.
-
Enter the code as an expression, for example:
You can use older XML-like query definitions as well:
import com.evolveum.midpoint.xml.ns._public.common.common_3.* prismContext.queryFor(FocusType.class) .item(FocusType.F_NAME).startsWith("a").build()
-
Select the Object type like you would for any other query. In our example, we are using the type from the
queryFor(…)
call, i.e.FocusType
. -
In the Language drop-down menu, select the language in which the script is written (XML/JSON/YAML).
-
Press Translate and execute. This executes the query in the expression and also shows the query in the selected language.
Using expressions requires proper imports.
Depending on the complexity of the script, you may need additional imports from packages like com.evolveum.midpoint.schema
, com.evolveum.midpoint.prism.query
, or others.
|
Query Converter
Midpoint can help you convert your old-fashioned XML queries to MQL in Query converter which is available in a tab next to the Query playground tab.
To convert an XML query:
-
Select the Object type from which the query will be selecting.
-
Paste your full original query, i.e. starting with the
<query>
element, into the XML Query text area. Make sure you remove namespaces from XML elements, or define them in the<query>
element. -
Press Convert query.
<query>
<filter>
<substring>
<path>emailAddress</path>
<value>gmail.com</value>
<anchorEnd>true</anchorEnd>
</substring>
</filter>
</query>
<query xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3">
<q:filter>
<q:substring>
<q:path>emailAddress</q:path>
<q:value>gmail.com</q:value>
<q:anchorEnd>true</q:anchorEnd>
</q:substring>
</q:filter>
</query>