Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

All the script expressions have the same internal structure no matter where and how they are used. The structure is illustrated in the following code snippet.

Code Block
xml
xml

<expression>
    <script>
        <language>http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</language>
        <code>
            'Mr. ' + user.getFamilyName();
        </code>
    </script>
</expression>

...

Field

 

Description

language

optional

Language URL. Specifies the language in which the expression is written. If not specified it defaults to Groovy language.

returnType

optional

TODO

relativityMode

optional

TODO Values: relative (default) or absolute. See below for more details. If not specified and allowed by the expression usage it defaults to relative mode.

code

mandatory

Expression code. Depends on the script language used for the expression. This is usually a string, but it also may be an XML. Please note that the code is embedded in the XML therefore proper XML escaping is required

...

The XPath expressions used in midPoint are most frequently using variables. For example, the following XPath expression will evaluate to the content of the fullName property of a user (using c as a namespace prefix):

Code Block
xml
xml

<code>
   $c:user/c:fullName
</code>

The same expression in Groovy and JavaScript looks like this:

Code Block
xml
xml

<code>
    user.getFullName();
</code>

...

Absolute and Relative Script Expressions

MidPoint works with relative changes by default. In some cases, it might be useful to handle e.g. list mappings in absolute way. Imagine, that you have multi-value UID attribute in LDAP and you want to select the right value based on DN. Then you need list of all the values. On the other hand, in relative approach, each value in UID attribute would be processed individually as a String.

Code Block
<expression>
	<script>
		<relativityMode>absolute</relativityMode>
		<code>
             //...   
		</code>
	</script>
</expression>

 

Future

The expressions are designed to be extensible and the expression language is not fixed. New expression languages may come in the future if there is a demand for them.

...