Class ExpressionUtil
java.lang.Object
com.evolveum.midpoint.repo.common.expression.ExpressionUtil
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addActorVariableIfNeeded
(VariablesMap variables, SecurityContextManager securityContextManager) static void
addDefaultVariablesMap
(VariablesMap variables, PrismObject<? extends ObjectType> focus, PrismObject<? extends ShadowType> shadow, PrismObject<ResourceType> resource, PrismObject<SystemConfigurationType> configuration) static void
checkEvaluatorProfileSimple
(ExpressionEvaluator<?> evaluator, ExpressionEvaluationContext context) Works only for simple evaluators that do not have any profile settings.static boolean
computeConditionResult
(Collection<PrismPropertyValue<Boolean>> booleanPropertyValues) static <V extends PrismValue>
Collection<V>computeTargetValues
(ItemPath path, TypedValue<?> defaultTargetContext, VariablesMap variables, ObjectResolver objectResolver, String contextDesc, Task task, OperationResult result) static <D extends ItemDefinition<?>>
ObjectconvertToOutputValue
(Long longValue, D outputDefinition, Protector protector) static <D extends ItemDefinition<?>>
ObjectconvertToOutputValue
(String stringValue, D outputDefinition, Protector protector) static <T,
V extends PrismValue>
VconvertToPrismValue
(T realValue, ItemDefinition<?> definition, String contextDescription) Guaranteed to return _detached_ (i.e., parent-less) prism value.static <I,
O> O convertValue
(Class<O> finalExpectedJavaType, Function<Object, Object> additionalConvertor, I inputVal, Protector protector) Slightly more powerful version of "convert" as compared toJavaTypeConverter.convert(Class, Object)
.static TypedValue<?>
convertVariableValue
(TypedValue<?> originalTypedValue, String variableName, ObjectResolver objectResolver, String contextDescription, ObjectVariableModeType objectVariableMode, @NotNull ValueVariableModeType valueVariableMode, PrismContext prismContext, Task task, OperationResult result) createCondition
(ExpressionType conditionExpressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult result) static PrismPropertyDefinition<Boolean>
createRefConvertor
(QName defaultType) static PrismValueDeltaSetTriple<?>
evaluateAnyExpressionInContext
(Expression<?, ?> expression, ExpressionEvaluationContext context, Task task, OperationResult result) static PrismPropertyValue<Boolean>
evaluateCondition
(VariablesMap variables, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) static boolean
evaluateConditionDefaultFalse
(VariablesMap variables, ExpressionType expressionBean, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) static boolean
evaluateConditionDefaultTrue
(VariablesMap variables, ExpressionType expressionBean, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) static <V extends PrismValue,
D extends ItemDefinition<?>>
VevaluateExpression
(VariablesMap variables, D outputDefinition, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) static <V extends PrismValue,
D extends ItemDefinition<?>>
VevaluateExpression
(Collection<Source<?, ?>> sources, VariablesMap variables, D outputDefinition, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) static <T> PrismValueDeltaSetTriple<PrismPropertyValue<T>>
evaluateExpressionInContext
(Expression<PrismPropertyValue<T>, PrismPropertyDefinition<T>> expression, ExpressionEvaluationContext eeContext, ExpressionEnvironment env, OperationResult result) static <T> PrismValueDeltaSetTriple<PrismPropertyValue<T>>
evaluateExpressionInContext
(Expression<PrismPropertyValue<T>, PrismPropertyDefinition<T>> expression, ExpressionEvaluationContext eeContext, Task task, OperationResult result) static <V extends PrismValue,
D extends ItemDefinition<?>>
@NotNull Collection<V>evaluateExpressionNative
(Collection<Source<?, ?>> sources, VariablesMap variables, D outputDefinition, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) static ObjectFilter
evaluateFilterExpressions
(ObjectFilter origFilter, VariablesMap variables, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult result) static ObjectQuery
evaluateQueryExpressions
(ObjectQuery origQuery, VariablesMap variables, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult result) evaluateRefExpressionInContext
(Expression<PrismReferenceValue, PrismReferenceDefinition> expression, ExpressionEvaluationContext eeContext, Task task, OperationResult result) static Collection<String>
evaluateStringExpression
(VariablesMap variables, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) static boolean
getBooleanConditionOutput
(PrismPropertyValue<Boolean> conditionOutput) static VariablesMap
getDefaultVariablesMap
(ObjectType focus, ShadowType shadow, ResourceType resource, SystemConfigurationType configuration) Used by both `provisioning` and `model`.static <V extends PrismValue>
VgetExpressionOutputValue
(PrismValueDeltaSetTriple<V> outputTriple, String shortDesc) static @Nullable ItemPath
getPath
(@Nullable VariableBindingDefinitionType bindingDefinition) static <T> @NotNull Set<T>
getUniqueNonNullRealValues
(@Nullable PrismValueDeltaSetTriple<PrismPropertyValue<T>> outputTriple) Post-condition: the result does not contain null valuesstatic boolean
hasExplicitTarget
(List<MappingType> mappingTypes) static boolean
hasExpressions
(@Nullable ObjectFilter filter) static boolean
hasExpressionsAndHasNoValue
(@Nullable ObjectFilter filter) static <T> boolean
isEmpty
(T val) static <ID extends ItemDefinition<?>>
IDresolveDefinitionPath
(@NotNull ItemPath path, VariablesMap variables, PrismContainerDefinition<?> defaultContext, String shortDesc) static TypedValue<?>
resolvePathGetTypedValue
(ItemPath path, VariablesMap variables, boolean normalizeValuesToDelete, TypedValue<?> defaultContext, ObjectResolver objectResolver, String shortDesc, Task task, OperationResult result) static Object
resolvePathGetValue
(ItemPath path, VariablesMap variables, boolean normalizeValuesToDelete, TypedValue<?> defaultContext, ObjectResolver objectResolver, String shortDesc, Task task, OperationResult result) static AbstractItemDeltaItem<?>
toAbstractItemDeltaTriple
(Object object)
-
Constructor Details
-
ExpressionUtil
public ExpressionUtil()
-
-
Method Details
-
convertValue
public static <I,O> O convertValue(Class<O> finalExpectedJavaType, Function<Object, Object> additionalConvertor, I inputVal, Protector protector) Slightly more powerful version of "convert" as compared toJavaTypeConverter.convert(Class, Object)
. This version can also encrypt/decrypt and also handles poly-strings. -
resolvePathGetValue
public static Object resolvePathGetValue(ItemPath path, VariablesMap variables, boolean normalizeValuesToDelete, TypedValue<?> defaultContext, ObjectResolver objectResolver, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException -
resolvePathGetTypedValue
public static TypedValue<?> resolvePathGetTypedValue(ItemPath path, VariablesMap variables, boolean normalizeValuesToDelete, TypedValue<?> defaultContext, ObjectResolver objectResolver, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException - Parameters:
normalizeValuesToDelete
- Whether to normalize container values that are to be deleted, i.e. convert them from id-only to full data (MID-4863). Note that normally the delta should be already normalized, as this is done now in LensFocusContext (due to MID-7057). So at this point it is just to be sure. TODO Anyway, we should analyze existing code and resolve this issue in more general way.- Throws:
SchemaException
ObjectNotFoundException
CommunicationException
ConfigurationException
SecurityViolationException
ExpressionEvaluationException
-
getPath
@Nullable public static @Nullable ItemPath getPath(@Nullable @Nullable VariableBindingDefinitionType bindingDefinition) -
computeTargetValues
public static <V extends PrismValue> Collection<V> computeTargetValues(ItemPath path, TypedValue<?> defaultTargetContext, VariablesMap variables, ObjectResolver objectResolver, String contextDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException -
convertVariableValue
public static TypedValue<?> convertVariableValue(TypedValue<?> originalTypedValue, String variableName, ObjectResolver objectResolver, String contextDescription, ObjectVariableModeType objectVariableMode, @NotNull @NotNull ValueVariableModeType valueVariableMode, PrismContext prismContext, Task task, OperationResult result) throws ExpressionSyntaxException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException -
resolveDefinitionPath
public static <ID extends ItemDefinition<?>> ID resolveDefinitionPath(@NotNull @NotNull ItemPath path, VariablesMap variables, PrismContainerDefinition<?> defaultContext, String shortDesc) throws SchemaException - Throws:
SchemaException
-
toAbstractItemDeltaTriple
-
evaluateQueryExpressions
public static ObjectQuery evaluateQueryExpressions(ObjectQuery origQuery, VariablesMap variables, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException -
evaluateFilterExpressions
@Contract("null, _, _, _, _, _, _ -> null; !null, _, _, _, _, _, _ -> !null") public static ObjectFilter evaluateFilterExpressions(ObjectFilter origFilter, VariablesMap variables, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException -
hasExpressions
-
hasExpressionsAndHasNoValue
-
evaluateExpression
public static <V extends PrismValue,D extends ItemDefinition<?>> V evaluateExpression(Collection<Source<?, ?>> sources, VariablesMap variables, D outputDefinition, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
evaluateExpressionNative
@NotNull public static <V extends PrismValue,D extends ItemDefinition<?>> @NotNull Collection<V> evaluateExpressionNative(Collection<Source<?, ?>> sources, VariablesMap variables, D outputDefinition, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
evaluateExpression
public static <V extends PrismValue,D extends ItemDefinition<?>> V evaluateExpression(VariablesMap variables, D outputDefinition, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
getExpressionOutputValue
public static <V extends PrismValue> V getExpressionOutputValue(PrismValueDeltaSetTriple<V> outputTriple, String shortDesc) throws ExpressionEvaluationException - Throws:
ExpressionEvaluationException
-
evaluateStringExpression
public static Collection<String> evaluateStringExpression(VariablesMap variables, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
evaluateCondition
public static PrismPropertyValue<Boolean> evaluateCondition(VariablesMap variables, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
evaluateConditionDefaultTrue
public static boolean evaluateConditionDefaultTrue(VariablesMap variables, ExpressionType expressionBean, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
evaluateConditionDefaultFalse
public static boolean evaluateConditionDefaultFalse(VariablesMap variables, ExpressionType expressionBean, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
getBooleanConditionOutput
-
hasExplicitTarget
-
computeConditionResult
public static boolean computeConditionResult(Collection<PrismPropertyValue<Boolean>> booleanPropertyValues) -
addActorVariableIfNeeded
public static void addActorVariableIfNeeded(VariablesMap variables, SecurityContextManager securityContextManager) -
convertToOutputValue
public static <D extends ItemDefinition<?>> Object convertToOutputValue(Long longValue, D outputDefinition, Protector protector) throws ExpressionEvaluationException, SchemaException -
convertToOutputValue
public static <D extends ItemDefinition<?>> Object convertToOutputValue(String stringValue, D outputDefinition, Protector protector) throws ExpressionEvaluationException, SchemaException -
isEmpty
public static <T> boolean isEmpty(T val) -
convertToPrismValue
public static <T,V extends PrismValue> V convertToPrismValue(T realValue, ItemDefinition<?> definition, String contextDescription) throws ExpressionEvaluationException Guaranteed to return _detached_ (i.e., parent-less) prism value.- Throws:
ExpressionEvaluationException
-
createCondition
public static Expression<PrismPropertyValue<Boolean>,PrismPropertyDefinition<Boolean>> createCondition(ExpressionType conditionExpressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, ConfigurationException -
createRefConvertor
-
createConditionOutputDefinition
-
checkEvaluatorProfileSimple
public static void checkEvaluatorProfileSimple(ExpressionEvaluator<?> evaluator, ExpressionEvaluationContext context) throws SecurityViolationException Works only for simple evaluators that do not have any profile settings.- Throws:
SecurityViolationException
-
getUniqueNonNullRealValues
@NotNull public static <T> @NotNull Set<T> getUniqueNonNullRealValues(@Nullable @Nullable PrismValueDeltaSetTriple<PrismPropertyValue<T>> outputTriple) Post-condition: the result does not contain null values -
evaluateAnyExpressionInContext
public static PrismValueDeltaSetTriple<?> evaluateAnyExpressionInContext(Expression<?, ?> expression, ExpressionEvaluationContext context, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
evaluateExpressionInContext
public static <T> PrismValueDeltaSetTriple<PrismPropertyValue<T>> evaluateExpressionInContext(Expression<PrismPropertyValue<T>, PrismPropertyDefinition<T>> expression, ExpressionEvaluationContext eeContext, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
evaluateRefExpressionInContext
public static PrismValueDeltaSetTriple<PrismReferenceValue> evaluateRefExpressionInContext(Expression<PrismReferenceValue, PrismReferenceDefinition> expression, ExpressionEvaluationContext eeContext, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
evaluateExpressionInContext
public static <T> PrismValueDeltaSetTriple<PrismPropertyValue<T>> evaluateExpressionInContext(Expression<PrismPropertyValue<T>, PrismPropertyDefinition<T>> expression, ExpressionEvaluationContext eeContext, ExpressionEnvironment env, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException -
getDefaultVariablesMap
public static VariablesMap getDefaultVariablesMap(ObjectType focus, ShadowType shadow, ResourceType resource, SystemConfigurationType configuration) Used by both `provisioning` and `model`. -
addDefaultVariablesMap
public static void addDefaultVariablesMap(VariablesMap variables, PrismObject<? extends ObjectType> focus, PrismObject<? extends ShadowType> shadow, PrismObject<ResourceType> resource, PrismObject<SystemConfigurationType> configuration)
-