Class ExpressionUtil
- java.lang.Object
-
- com.evolveum.midpoint.repo.common.expression.ExpressionUtil
-
public class ExpressionUtil extends Object
- Author:
- semancik
-
-
Constructor Summary
Constructors Constructor Description ExpressionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addActorVariable(ExpressionVariables scriptVariables, SecurityContextManager securityContextManager, PrismContext prismContext)
static void
checkEvaluatorProfileSimple(ExpressionEvaluator<?,?> evaluator, ExpressionEvaluationContext context)
Works only for simple evaluators that do not have any profile settings.static VariablesMap
compileSources(Collection<Source<?,?>> sources)
static VariablesMap
compileVariablesAndSources(ExpressionEvaluationContext params)
static boolean
computeConditionResult(Collection<PrismPropertyValue<Boolean>> booleanPropertyValues)
static PlusMinusZero
computeConditionResultMode(boolean condOld, boolean condNew)
static <V extends PrismValue,F extends FocusType>
Collection<V>computeTargetValues(VariableBindingDefinitionType target, TypedValue defaultTargetContext, ExpressionVariables variables, ObjectResolver objectResolver, String contextDesc, PrismContext prismContext, 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 value, ItemDefinition definition, String contextDescription, PrismContext prismContext)
static <I,O>
OconvertValue(Class<O> finalExpectedJavaType, Function<Object,Object> additionalConvertor, I inputVal, Protector protector, PrismContext prismContext)
Slightly more powerful version of "convert" as compared to JavaTypeConverter.static <T> TypedValue<T>
convertVariableValue(TypedValue<T> originalTypedValue, String variableName, ObjectResolver objectResolver, String contextDescription, ObjectVariableModeType objectVariableModeType, PrismContext prismContext, Task task, OperationResult result)
static Expression<PrismPropertyValue<Boolean>,PrismPropertyDefinition<Boolean>>
createCondition(ExpressionType conditionExpressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult result)
static PrismPropertyDefinition<Boolean>
createConditionOutputDefinition(PrismContext prismContext)
static Function<Object,Object>
createRefConvertor(QName defaultType)
static ItemDefinition
determineDefinitionFromValueClass(PrismContext prismContext, String name, Class<?> valueClass, QName typeQName)
Used in cases when we do not have a definition.static PrismPropertyValue<Boolean>
evaluateCondition(ExpressionVariables variables, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult)
static <V extends PrismValue,D extends ItemDefinition>
VevaluateExpression(ExpressionVariables 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, ExpressionVariables variables, D outputDefinition, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult)
static ObjectFilter
evaluateFilterExpressions(ObjectFilter origFilter, ExpressionVariables variables, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, PrismContext prismContext, String shortDesc, Task task, OperationResult result)
static ObjectQuery
evaluateQueryExpressions(ObjectQuery origQuery, ExpressionVariables variables, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, PrismContext prismContext, String shortDesc, Task task, OperationResult result)
static Collection<String>
evaluateStringExpression(ExpressionVariables variables, PrismContext prismContext, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult)
static boolean
getBooleanConditionOutput(PrismPropertyValue<Boolean> conditionOutput)
static <V extends PrismValue>
VgetExpressionOutputValue(PrismValueDeltaSetTriple<V> outputTriple, String shortDesc)
static boolean
hasExplicitTarget(List<MappingType> mappingTypes)
static boolean
hasExpressions(ObjectFilter filter)
static <T> boolean
isEmpty(T val)
static <ID extends ItemDefinition>
IDresolveDefinitionPath(ItemPath path, ExpressionVariables variables, PrismContainerDefinition<?> defaultContext, String shortDesc)
static TypedValue
resolvePathGetTypedValue(ItemPath path, ExpressionVariables variables, boolean normalizeValuesToDelete, TypedValue defaultContext, ObjectResolver objectResolver, PrismContext prismContext, String shortDesc, Task task, OperationResult result)
normalizeValuesToDelete: Whether to normalize container values that are to be deleted, i.e.static Object
resolvePathGetValue(ItemPath path, ExpressionVariables variables, boolean normalizeValuesToDelete, TypedValue defaultContext, ObjectResolver objectResolver, PrismContext prismContext, String shortDesc, Task task, OperationResult result)
static <IV extends PrismValue,ID extends ItemDefinition>
ItemDeltaItem<IV,ID>toItemDeltaItem(Object object, ObjectResolver objectResolver, String string, OperationResult result)
static <V extends PrismValue>
PrismValueDeltaSetTriple<V>toOutputTriple(PrismValueDeltaSetTriple<V> resultTriple, ItemDefinition outputDefinition, Function<Object,Object> additionalConvertor, ItemPath residualPath, Protector protector, PrismContext prismContext)
-
-
-
Method Detail
-
toOutputTriple
public static <V extends PrismValue> PrismValueDeltaSetTriple<V> toOutputTriple(PrismValueDeltaSetTriple<V> resultTriple, ItemDefinition outputDefinition, Function<Object,Object> additionalConvertor, ItemPath residualPath, Protector protector, PrismContext prismContext)
-
convertValue
public static <I,O> O convertValue(Class<O> finalExpectedJavaType, Function<Object,Object> additionalConvertor, I inputVal, Protector protector, PrismContext prismContext)
Slightly more powerful version of "convert" as compared to JavaTypeConverter. This version can also encrypt/decrypt and also handles polystrings.
-
resolvePathGetValue
public static Object resolvePathGetValue(ItemPath path, ExpressionVariables variables, boolean normalizeValuesToDelete, TypedValue defaultContext, ObjectResolver objectResolver, PrismContext prismContext, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException
-
resolvePathGetTypedValue
public static TypedValue resolvePathGetTypedValue(ItemPath path, ExpressionVariables variables, boolean normalizeValuesToDelete, TypedValue defaultContext, ObjectResolver objectResolver, PrismContext prismContext, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException
normalizeValuesToDelete: Whether to normalize container values that are to be deleted, i.e. convert them from id-only to full data (MID-4863). TODO: 1. consider setting this parameter to true at some other places where it might be relevant 2. consider normalizing delete deltas earlier in the clockwork, probably at the very beginning of the operation
-
computeTargetValues
public static <V extends PrismValue,F extends FocusType> Collection<V> computeTargetValues(VariableBindingDefinitionType target, TypedValue defaultTargetContext, ExpressionVariables variables, ObjectResolver objectResolver, String contextDesc, PrismContext prismContext, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException
-
convertVariableValue
public static <T> TypedValue<T> convertVariableValue(TypedValue<T> originalTypedValue, String variableName, ObjectResolver objectResolver, String contextDescription, ObjectVariableModeType objectVariableModeType, PrismContext prismContext, Task task, OperationResult result) throws ExpressionSyntaxException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException
-
resolveDefinitionPath
public static <ID extends ItemDefinition> ID resolveDefinitionPath(@NotNull ItemPath path, ExpressionVariables variables, PrismContainerDefinition<?> defaultContext, String shortDesc) throws SchemaException
- Throws:
SchemaException
-
toItemDeltaItem
public static <IV extends PrismValue,ID extends ItemDefinition> ItemDeltaItem<IV,ID> toItemDeltaItem(Object object, ObjectResolver objectResolver, String string, OperationResult result)
-
evaluateQueryExpressions
public static ObjectQuery evaluateQueryExpressions(ObjectQuery origQuery, ExpressionVariables variables, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, PrismContext prismContext, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException
-
evaluateFilterExpressions
public static ObjectFilter evaluateFilterExpressions(ObjectFilter origFilter, ExpressionVariables variables, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, PrismContext prismContext, String shortDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException
-
hasExpressions
public static boolean hasExpressions(@Nullable ObjectFilter filter)
-
evaluateExpression
public static <V extends PrismValue,D extends ItemDefinition> V evaluateExpression(Collection<Source<?,?>> sources, ExpressionVariables 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(ExpressionVariables 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(ExpressionVariables variables, PrismContext prismContext, 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(ExpressionVariables variables, ExpressionType expressionType, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException
-
getBooleanConditionOutput
public static boolean getBooleanConditionOutput(PrismPropertyValue<Boolean> conditionOutput)
-
compileVariablesAndSources
public static VariablesMap compileVariablesAndSources(ExpressionEvaluationContext params)
-
compileSources
public static VariablesMap compileSources(Collection<Source<?,?>> sources)
-
hasExplicitTarget
public static boolean hasExplicitTarget(List<MappingType> mappingTypes)
-
computeConditionResult
public static boolean computeConditionResult(Collection<PrismPropertyValue<Boolean>> booleanPropertyValues)
-
computeConditionResultMode
public static PlusMinusZero computeConditionResultMode(boolean condOld, boolean condNew)
-
addActorVariable
public static void addActorVariable(ExpressionVariables scriptVariables, SecurityContextManager securityContextManager, PrismContext prismContext)
-
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 value, ItemDefinition definition, String contextDescription, PrismContext prismContext) throws ExpressionEvaluationException
- 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
-
createConditionOutputDefinition
public static PrismPropertyDefinition<Boolean> createConditionOutputDefinition(PrismContext prismContext)
-
determineDefinitionFromValueClass
public static ItemDefinition determineDefinitionFromValueClass(PrismContext prismContext, String name, Class<?> valueClass, QName typeQName)
Used in cases when we do not have a definition.
-
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
-
-