Page tree

Versions Compared

Key

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

...

Info
titleWhy do we need reference time?
The mappings are usually evaluated when a change happens. It may be tempting to try to use current time of the evaluation as a reference time. E.g. specifying something like "10 days after the account status was evaluated to be disabled". However there are cases when the mapping is evaluated or re-evaluated much later, e.g. in case of reconciliation or recompute. If we would use the current time of evaluation the result of evaluation may be different each time we re-evaluate the mapping. E.g. in the "10 days after disabled" case the notion of "10 days after" may change each time the mapping is evaluated. Such approach will setting it to 10 days from the current time every time it is re-evaluated. Therefore  we usually cannot just use the current time of mapping evaluation as a reference. We want to use something more stable instead. Enable/disable timestamps which are stored in midPoint repository are usually good candidates. Or even create/modify timestamps from the object metadata. Using such values for reference time will make sure the result of the mapping evaluation is consistent even if it is re-evaluated.

Time Constraint Expressions

Info
titleMidPoint 4.0 and later

The timestamp to be used for the time constraint can be determined by an expression. E.g. scripting expressions can be used to set the time constraint in a very flexible manner:

Code Block
languagexml
    <mapping>
    	<timeFrom>
			<expression>
				<script>
					<code>
						def createTimestamp = focus?.metadata?.createTimestamp
						def timestamp = basic.addDuration(createTimestamp, "P3M")
						return basic.roundDownToMidnight(timestamp)
					</code>
				</script>
			</expression>
		</timeFrom>
    	...
    </mapping>

The expression above returns a timestamp that is based on object creation timestamp, delayed by three months and rounded down to the midnight.

If referenceTime specification is used together with expression, the reference time value will be passed to the expression in referenceTime variable. If both expression and offset are used, the offset is applied to the timestamp produced by the expression. If the expression returns null then the time constraint will be considered unsatisfied. Which is a similar behavior as if reference time was not set.

Condition

Condition is a special kind of expression in the mapping that influences whether the mapping will be applied or not. If a condition evaluates to true value the mapping will be applied. If it evaluates to false then the system will pretend that the mapping does not exist at all. The condition can be used to set conditional property values, conditionally assign roles, define mapping constraints and so on.

...