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(VariablesMap 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 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, VariablesMap 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 TypedValue<?>
convertVariableValue(TypedValue<?> originalTypedValue, String variableName, ObjectResolver objectResolver, String contextDescription, ObjectVariableModeType objectVariableMode, @NotNull ValueVariableModeType valueVariableMode, 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()
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(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 <V extends PrismValue,D extends ItemDefinition>
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, PrismContext prismContext, String shortDesc, Task task, OperationResult result)
static ObjectQuery
evaluateQueryExpressions(ObjectQuery origQuery, VariablesMap variables, ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, PrismContext prismContext, String shortDesc, Task task, OperationResult result)
static Collection<String>
evaluateStringExpression(VariablesMap 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(@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, PrismContext prismContext, String shortDesc, Task task, OperationResult result)
static Object
resolvePathGetValue(ItemPath path, VariablesMap 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)
-
-
-
Method Detail
-
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, VariablesMap 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, VariablesMap variables, boolean normalizeValuesToDelete, TypedValue<?> defaultContext, ObjectResolver objectResolver, PrismContext prismContext, 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
-
computeTargetValues
public static <V extends PrismValue,F extends FocusType> Collection<V> computeTargetValues(VariableBindingDefinitionType target, TypedValue defaultTargetContext, VariablesMap variables, ObjectResolver objectResolver, String contextDesc, PrismContext prismContext, 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
-
toItemDeltaItem
public static <IV extends PrismValue,ID extends ItemDefinition> ItemDeltaItem<IV,ID> toItemDeltaItem(Object object)
-
evaluateQueryExpressions
public static ObjectQuery evaluateQueryExpressions(ObjectQuery origQuery, VariablesMap 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, VariablesMap 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 @Nullable ObjectFilter filter)
-
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
public static <V extends PrismValue,D extends ItemDefinition> 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, 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(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
public static boolean getBooleanConditionOutput(PrismPropertyValue<Boolean> conditionOutput)
-
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(VariablesMap 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()
-
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
-
-