this.name = ((o.name == null)?null:o.getName()); this.description = ((o.description == null)?null:o.getDescription()); this.extension = ((o.extension == null)?null:((o.getExtension() == null)?null:o.getExtension().clone())); copyParameter(o.getParameter(), this.getParameter()); this.returnType = ((o.returnType == null)?null:o.getReturnType()); this.trace = ((o.trace == null)?null:o.isTrace()); copyStringFilter(o.getStringFilter(), this.getStringFilter()); copyVariable(o.getVariable(), this.getVariable()); this.returnMultiplicity = ((o.returnMultiplicity == null)?null:o.getReturnMultiplicity()); this.allowEmptyValues = ((o.allowEmptyValues == null)?null:o.isAllowEmptyValues()); this.queryInterpretationOfNoValue = ((o.queryInterpretationOfNoValue == null)?null:o.getQueryInterpretationOfNoValue()); this.runAsRef = ((o.runAsRef == null)?null:((o.getRunAsRef() == null)?null:o.getRunAsRef().clone())); copyExpressionEvaluator(o.getExpressionEvaluator(), this.getExpressionEvaluator());
/** * Create an instance of {@link ExpressionType } * */ public ExpressionType createExpressionType() { return new ExpressionType(); }
public boolean equals(Object object) { final EqualsStrategy strategy = DomAwareEqualsStrategy.INSTANCE; return equals(null, null, object, strategy); }
lhsName = this.getName(); String rhsName; rhsName = that.getName(); if (!strategy.equals(LocatorUtils.property(thisLocator, "name", lhsName), LocatorUtils.property(thatLocator, "name", rhsName), lhsName, rhsName)) { return false; lhsDescription = this.getDescription(); String rhsDescription; rhsDescription = that.getDescription(); if (!strategy.equals(LocatorUtils.property(thisLocator, "description", lhsDescription), LocatorUtils.property(thatLocator, "description", rhsDescription), lhsDescription, rhsDescription)) { return false; lhsExtension = this.getExtension(); ExtensionType rhsExtension; rhsExtension = that.getExtension(); if (!strategy.equals(LocatorUtils.property(thisLocator, "extension", lhsExtension), LocatorUtils.property(thatLocator, "extension", rhsExtension), lhsExtension, rhsExtension)) { return false; lhsParameter = (((this.parameter!= null)&&(!this.parameter.isEmpty()))?this.getParameter():null); List<ExpressionParameterType> rhsParameter; rhsParameter = (((that.parameter!= null)&&(!that.parameter.isEmpty()))?that.getParameter():null); if (!strategy.equals(LocatorUtils.property(thisLocator, "parameter", lhsParameter), LocatorUtils.property(thatLocator, "parameter", rhsParameter), lhsParameter, rhsParameter)) { return false; lhsReturnType = this.getReturnType(); QName rhsReturnType; rhsReturnType = that.getReturnType(); if (!strategy.equals(LocatorUtils.property(thisLocator, "returnType", lhsReturnType), LocatorUtils.property(thatLocator, "returnType", rhsReturnType), lhsReturnType, rhsReturnType)) { return false;
public ExpressionType expressionEvaluator(JAXBElement<?> value) { getExpressionEvaluator().add(value); return this; }
appendPropertyIfNotNull(sb, "description", expressionType.getDescription()); appendPropertyIfNotNull(sb, "extension", expressionType.getExtension()); appendPropertyIfNotNull(sb, "trace", expressionType.isTrace()); appendPropertyIfNotNull(sb, "variable", expressionType.getVariable()); appendPropertyIfNotNull(sb, "returnMultiplicity", expressionType.getReturnMultiplicity()); appendPropertyIfNotNull(sb, "allowEmptyValues", expressionType.isAllowEmptyValues()); appendPropertyIfNotNull(sb, "queryInterpretationOfNoValue", expressionType.getQueryInterpretationOfNoValue()); appendPropertyIfNotNull(sb, "runAsRef", expressionType.getRunAsRef()); List<JAXBElement<?>> expressionEvaluators = expressionType.getExpressionEvaluator(); sb.append("evaluator").append("="); if (expressionEvaluators.isEmpty()) {
private MappingType createCondition(String conditionName, char conditionType) { ScriptExpressionEvaluatorType script = new ScriptExpressionEvaluatorType(); switch (conditionType) { case '+': script.setCode("basic.stringify(name) == 'jack1'"); break; case '-': script.setCode("basic.stringify(name) == 'jack'"); break; case '0': script.setCode("basic.stringify(name) == 'never there'"); break; case '!': script.setCode(createDumpConditionCode(conditionName)); break; default: throw new AssertionError(conditionType); } ExpressionType expression = new ExpressionType(); expression.getExpressionEvaluator().add(new ObjectFactory().createScript(script)); VariableBindingDefinitionType source = new VariableBindingDefinitionType(); source.setPath(new ItemPathType(UserType.F_NAME)); MappingType rv = new MappingType(); rv.setName(conditionName); rv.setExpression(expression); rv.getSource().add(source); return rv; }
public <V extends PrismValue, D extends ItemDefinition> Object execute(String functionName, Map<String, Object> params) throws ExpressionEvaluationException { Validate.notNull(functionName, "Function name must be specified"); List<ExpressionType> functions = library.getFunction().stream().filter(expression -> functionName.equals(expression.getName())).collect(Collectors.toList()); QName returnType = expressionType.getReturnType(); if (returnType == null) { returnType = DOMUtil.XSD_STRING; outputDefinition = (D) prismContext.definitionFactory().createPropertyDefinition(SchemaConstantsGenerated.C_VALUE, returnType); if (expressionType.getReturnMultiplicity() != null && expressionType.getReturnMultiplicity() == ExpressionReturnMultiplicityType.MULTI) { outputDefinition.toMutable().setMaxOccurs(-1); } else {
private D determineVariableOutputDefinition(ExpressionType functionToExecute, String paramName, ExpressionEvaluationContext context) throws SchemaException { for (ExpressionParameterType functionParam: functionToExecute.getParameter()) { if (functionParam.getName().equals(paramName)) { functionParameter = functionParam; if (returnTypeDef == null) { returnTypeDef = (D) prismContext.definitionFactory().createPropertyDefinition(SchemaConstantsGenerated.C_VALUE, returnType); returnTypeDef.toMutable().setMaxOccurs(functionToExecute.getReturnMultiplicity() != null && functionToExecute.getReturnMultiplicity() == ExpressionReturnMultiplicityType.SINGLE ? 1 : -1);
/** * Returns either Object (if result is supposed to be single-value) or Collection<X> (if result is supposed to be multi-value) */ public static Object getStaticOutput(ExpressionType expressionType, PrismPropertyDefinition outputDefinition, String contextDescription, ExpressionReturnMultiplicityType preferredMultiplicity, PrismContext prismContext) throws SchemaException { PrismProperty<?> output = getPropertyStatic(expressionType, outputDefinition, contextDescription, prismContext); ExpressionReturnMultiplicityType multiplicity = preferredMultiplicity; if (expressionType.getReturnMultiplicity() != null) { multiplicity = expressionType.getReturnMultiplicity(); } else if (output != null && output.size() > 1) { multiplicity = ExpressionReturnMultiplicityType.MULTI; } if (output == null) { switch (multiplicity) { case MULTI: return new ArrayList<>(0); case SINGLE: return null; default: throw new IllegalStateException("Unknown return type "+multiplicity); } } else { Collection<?> realValues = output.getRealValues(); switch (multiplicity) { case MULTI: return realValues; case SINGLE: return MiscUtil.extractSingleton(realValues); default: throw new IllegalStateException("Unknown return type "+multiplicity); } } }
public ExpressionType parameter(ExpressionParameterType value) { getParameter().add(value); return this; }
private static ObjectFilter createFilterForNoValue(ObjectFilter filter, ExpressionType valueExpression, PrismContext prismContext) throws ExpressionEvaluationException { QueryInterpretationOfNoValueType queryInterpretationOfNoValue = valueExpression.getQueryInterpretationOfNoValue(); if (queryInterpretationOfNoValue == null) { queryInterpretationOfNoValue = QueryInterpretationOfNoValueType.FILTER_EQUAL_NULL;
List<ExpressionType> filteredExpressions = expressions.stream().filter(expression -> functionName.equals(expression.getName())).collect(Collectors.toList()); if (filteredExpressions.size() ==0 ){ String possibleFunctions = ""; for (ExpressionType expression : expressions) { possibleFunctions += expression.getName() + ", ";
theName = this.getName(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "name", theName), currentHashCode, theName); theDescription = this.getDescription(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "description", theDescription), currentHashCode, theDescription); theExtension = this.getExtension(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "extension", theExtension), currentHashCode, theExtension); theParameter = (((this.parameter!= null)&&(!this.parameter.isEmpty()))?this.getParameter():null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "parameter", theParameter), currentHashCode, theParameter); theReturnType = this.getReturnType(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "returnType", theReturnType), currentHashCode, theReturnType); theTrace = this.isTrace(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "trace", theTrace), currentHashCode, theTrace); theStringFilter = (((this.stringFilter!= null)&&(!this.stringFilter.isEmpty()))?this.getStringFilter():null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "stringFilter", theStringFilter), currentHashCode, theStringFilter); theVariable = (((this.variable!= null)&&(!this.variable.isEmpty()))?this.getVariable():null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "variable", theVariable), currentHashCode, theVariable); theReturnMultiplicity = this.getReturnMultiplicity(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "returnMultiplicity", theReturnMultiplicity), currentHashCode, theReturnMultiplicity); theAllowEmptyValues = this.isAllowEmptyValues(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "allowEmptyValues", theAllowEmptyValues), currentHashCode, theAllowEmptyValues);
public static <X> PrismProperty<X> getPropertyStatic(ExpressionType expressionType, PrismPropertyDefinition outputDefinition, String contextDescription, PrismContext prismContext) throws SchemaException { Collection<JAXBElement<?>> expressionEvaluatorElement = expressionType.getExpressionEvaluator(); return (PrismProperty) parseValueElements(expressionEvaluatorElement, outputDefinition, contextDescription); }
private void createCustomConstruction(RoleType role, String name, int order) { ConstructionType c = new ConstructionType(prismContext); c.setDescription(name); c.setResourceRef(ObjectTypeUtil.createObjectRef(RESOURCE_DUMMY_EMPTY_OID, ObjectTypes.RESOURCE)); ResourceAttributeDefinitionType nameDef = new ResourceAttributeDefinitionType(); nameDef.setRef(new ItemPathType(ItemPath.create(new QName(SchemaConstants.NS_ICF_SCHEMA, "name")))); MappingType outbound = new MappingType(); outbound.setName(name); ExpressionType expression = new ExpressionType(); ScriptExpressionEvaluatorType script = new ScriptExpressionEvaluatorType(); script.setCode( "import com.evolveum.midpoint.model.impl.lens.TestAssignmentProcessor2\n\n" + "TestAssignmentProcessor2.startCallback('" + name + "')\n" + "this.binding.variables.each {k,v -> TestAssignmentProcessor2.variableCallback(k, v, '" + name + "')}\n" + "TestAssignmentProcessor2.finishCallback('" + name + "')\n" + "return null"); expression.getExpressionEvaluator().add(new ObjectFactory().createScript(script)); outbound.setExpression(expression); nameDef.setOutbound(outbound); c.getAttribute().add(nameDef); AssignmentType a = new AssignmentType(prismContext); a.setDescription("Assignment for " + c.getDescription()); a.setConstruction(c); addAssignmentOrInducement(role, order, a); }
private ExpressionType determineFunctionToExecute(List<ExpressionType> filteredExpressions) { if (filteredExpressions.size() == 1) { return filteredExpressions.iterator().next(); } List<ExpressionParameterType> functionParams = functionEvaluatorType.getParameter(); for (ExpressionType filteredExpression : filteredExpressions) { List<ExpressionParameterType> filteredExpressionParameters = filteredExpression.getParameter(); if (functionParams.size() != filteredExpressionParameters.size()) { continue; } if (!compareParameters(functionParams, filteredExpressionParameters)) { continue; } return filteredExpression; } return null; }
clone.name = ((this.name == null)?null:this.getName()); clone.description = ((this.description == null)?null:this.getDescription()); clone.extension = ((this.extension == null)?null:((this.getExtension() == null)?null:this.getExtension().clone())); copyParameter(this.getParameter(), clone.getParameter()); clone.returnType = ((this.returnType == null)?null:this.getReturnType()); clone.trace = ((this.trace == null)?null:this.isTrace()); copyStringFilter(this.getStringFilter(), clone.getStringFilter()); copyVariable(this.getVariable(), clone.getVariable()); clone.returnMultiplicity = ((this.returnMultiplicity == null)?null:this.getReturnMultiplicity()); clone.allowEmptyValues = ((this.allowEmptyValues == null)?null:this.isAllowEmptyValues()); clone.queryInterpretationOfNoValue = ((this.queryInterpretationOfNoValue == null)?null:this.getQueryInterpretationOfNoValue()); clone.runAsRef = ((this.runAsRef == null)?null:((this.getRunAsRef() == null)?null:this.getRunAsRef().clone())); copyExpressionEvaluator(this.getExpressionEvaluator(), clone.getExpressionEvaluator());
public ExpressionType beginCondition() { ExpressionType value = new ExpressionType(); condition(value); return value; }
public static Object getConstantIfPresent(ExpressionType expression) { if (expression == null || expression.getExpressionEvaluator().size() != 1) { return null; } JAXBElement<?> jaxb = expression.getExpressionEvaluator().get(0); if (QNameUtil.match(jaxb.getName(), SchemaConstants.C_VALUE)) { return jaxb.getValue(); } else { return null; } } }