Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/docs/cleanup-4.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
mspanik committed Jan 12, 2024
2 parents 814f1a8 + 10afa8f commit 1957c80
Show file tree
Hide file tree
Showing 12 changed files with 433 additions and 531 deletions.
2 changes: 1 addition & 1 deletion docs/concepts/query/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This section describes usage and configuration details of:

* xref:midpoint-query-language/[midPoint Query Language],
* xref:xml-query-language.adoc[XML Query Language] (deprecated),
* concept of xref:query-in-midpoint/[query in midPoint] in more depth.
* concept of xref:query-concepts/[query in midPoint] in more depth.
It should be mentioned, that midPoint provides also xref:full-text-search.adoc[*Full text search*] option.
It is available only for searching of specific data in GUI. The full text search is not enabled by default and must be configured by engineer.
Expand Down
201 changes: 0 additions & 201 deletions docs/concepts/query/midpoint-query-language/basic-usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,205 +3,4 @@
:page-display-order: 100


This document provides information and examples of queries in midPoint Query Language, mainly used in objects while configuration of midPoint itself.

Additional examples how to use the midPoint query in GUI can be found in xref:/midpoint/guides/gui-midpoint-query-examples[Advanced search - EXAMPLES].

== Searching by Archetype Name

Search for reports with archetype specified by its name

.midPoint Query
----
archetypeRef/@/name = "Report export task"
----

.XML Query
[source, xml]
----
<filter>
<eq>
<path>archetypeRef/@/name</path>
<value>Report export Task</value>
</eq>
<filter>
----

Where:

* `archetypeRef/@` - specifies we are not matching reference value, but it's target. In this case it is archetype.



== Search by Assigned Role Name

.midPoint Query
----
assignment/targetRef/@/name = "Role Name"
----

Where:

* `assignment/targetRef/@` -specifies that we are not matching reference value, but it's target. In this case it is assigned role.


== Users with account on specific resource

Search for users, which have account specified resource, with default intent.

.midPoint Query
----
linkRef/@ matches (
. type ShadowType
and resourceRef matches (oid = "ff735c0a-21e3-11e8-a91a-df0065248d2d")
and intent = "default"
)
----

Where:

* `linkRef/@` - we dereference target of `linkRef`, this behaves similar to SQL `JOIN`,
allows us to filter on properties of the target
* `matches` specifies subfilter for dereferenced target, filter which linkRef must match
** `. type ShadowType`, we are searching for shadows on resource, this is necessary in order to be able to use shadow properties for filter
** `resourceRef matches (oid = "..." )` - matches specific resource, to which shadow belongs
** `intent = "default"` - matches shadow with default intent


.XML equivalent
[source, xml]
----
<query>
<filter>
<exists>
<path>linkRef/@</path>
<filter>
<and>
<ref>
<path>resourceRef</path>
<value oid="ff735c0a-21e3-11e8-a91a-df0065248d2d" />
</ref>
<equal>
<path>intent</path>
<value>default</value>
</equal>
</and>
</filter>
</exists>
</filter>
</query>
----

.Translated SQL query in native PostgreSQL repository
[source, sql]
----
select u.oid, u.fullObject from m_user u
where exists (
select 1 from m_ref_projection refpj
where u.oid = refpj.ownerOid and exists (
select 1 from m_shadow sh
where refpj.targetOid = sh.oid and (sh.resourceRefTargetOid = ? and sh.resourceRefRelationId = ? and sh.intent = ?)
)
)
limit ?
----


=== All roles which are assigned to System users

NOTE: Filter is currently supported in midPoint 4.6 Postgres native repository only

// All roles which are assigned to system users
.midPoint Query using `UserType` as referencedBy
----
. referencedBy (
@type = UserType
and @path = assignment/targetRef
and archetypeRef/@/name = "System user"
)
----

.midPoint Query using `AssignmentType` for referencedBy
----
. referencedBy (
@type = AssignmentType
and @path = targetRef
and . ownedBy (
@type = UserType
and @path = assignment
and archetypeRef/@/name = "System user"
)
)
----

=== All roles, which are assigned using inducement
NOTE: Filter is currently supported in midPoint 4.6 Postgres native repository only

// All roles which are assigned using inducement
.midPoint Query
----
. referencedBy (
@type = AbstractRoleType
and @path = inducement/targetRef
)
----

.XML Query
[source, xml]
----
<filter>
<referencedBy>
<type>AbstractRoleType</type>
<path>inducement/targetRef</path>
</referencedBy>
</filter>
----

=== All roles, which are assigned to administrator using full text serach

.midPoint Query
----
. referencedBy (
@type = UserType
and @path = roleMembershipRef
and . fullText "administrator"
)
----

.XML Query
[source, xml]
----
<filter>
<referencedBy>
<type>UserType</type>
<path>roleMembershipRef</path>
<filter>
<fullText>
<value>administrator</value>
</fullText>
</filter>
</referencedBy>
</filter>
----

=== Search on assigned role using fullText

.midPoint Query
----
assignment/targetRef/@ matches (
. fullText "secret"
)
----

.XML Query
[source, xml]
----
<filter>
<exists>
<path>assignment/targetRef/@</path>
<fullText>
<value>secret</value>
</fullText>
</exists>
</filter>
----
33 changes: 2 additions & 31 deletions docs/concepts/query/midpoint-query-language/expressions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ as right-hand side value.
name = $c:account/c:attributes/ri:uid
----

.XML equivalent
----
<q:equal>
<q:path>name</q:path>
<c:expression>
<c:path>$c:account/c:attributes/ri:uid</c:path>
</c:expression>
</q:equal>
----

== Script

Expand Down Expand Up @@ -107,31 +98,11 @@ metadata/createTimestamp > yaml```
```
----

.XML Equivalent
[source,xml]
----
<filter>
<gt>
<path>metadata/createTimestamp</path>
<expression>
<script>
<language>groovy</language>
<code>
ret = basic.addDuration(now, "-P30D");
now = basic.currentDateTime();
return ret
</code>
</script>
</expression>
</gt>
</filter>
----

[WARNING]
====
In midPoint 4.5 and 4.6 you *have to indent* the content of the YAML expression with at least
You *have to indent* the content of the YAML expression with at least
one space, otherwise it will not parse with quite an obscure error.
// TODO fixed in 4.7? MID-8286
// TODO fixed in 4.9? MID-8286
====

== See Also
Expand Down

0 comments on commit 1957c80

Please sign in to comment.