Page tree

Versions Compared

Key

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

...

Code Block
<mapping>
	<strength>strong</strength>
	<expression>
		<script>
			<code>
                import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType;
                import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType;
                import com.evolveum.midpoint.schema.GetOperationOptions;
                import com.evolveum.midpoint.schema.RelationalValueSearchQuery;
                import com.evolveum.midpoint.schema.RelationalValueSearchType;
                import com.evolveum.midpoint.schema.SelectorOptions;

				// default label, if key is not in lookup table
                returnValue = 'DEFAULT LABEL';
                
                query = new RelationalValueSearchQuery(LookupTableRowType.F_KEY, 'myKeyValue', RelationalValueSearchType.EXACT);
                options = SelectorOptions.createCollection(prismContext.toUniformPath(LookupTableType.F_ROW), GetOperationOptions.createRetrieve(query));
			    LookupTableType lookup = midpoint.getObject(LookupTableType.class, 'lookup-table-oid', options);

			    log.info('lookup object = {}',lookup);
				lookupRow = lookup.getRow();
			    log.info('lookup Row = {}',lookupRow);

				// check if value exists in lookup table
                if (lookupRow.size() > 0) {
                    returnValue = basic.stringify(lookupRow[0].getLabel());
                }

			    log.info('Returned value = {}',returnValue);
				return returnValue;
			</code>
		</script>
	</expression>
	<target>
		<path>$user/extension/myAttribute</path>
	</target>
</mapping>

...