public static String prettyPrint(ResourceAttributeDefinitionType vc) { if (vc == null) { return "null"; } StringBuilder sb = new StringBuilder("ResourceAttributeDefinitionType("); if (vc.getRef() != null) { sb.append("ref="); sb.append(prettyPrint(vc.getRef())); boolean other = !vc.getInbound().isEmpty(); if (vc.getOutbound() != null && vc.getOutbound().getExpression() != null ) { Object value = SimpleExpressionUtil.getConstantIfPresent(vc.getOutbound().getExpression()); if (value != null) { sb.append(", value='").append(PrettyPrinter.prettyPrint(value)).append("'"); } else { other = true; } } if (other) { sb.append(", ..."); } } // TODO: Other properties sb.append(")"); return sb.toString(); }
@Override public String getNodeStyleAttributes() { ExpressionType expression = getMapping().getExpression(); if (expression == null || expression.getExpressionEvaluator().isEmpty()) { return ""; } JAXBElement<?> evalElement = expression.getExpressionEvaluator().get(0); Object eval = evalElement.getValue(); if (QNameUtil.match(evalElement.getName(), SchemaConstants.C_VALUE)) { return "style=filled, fillcolor=ivory"; } else if (eval instanceof AsIsExpressionEvaluatorType) { return ""; } else if (eval instanceof ScriptExpressionEvaluatorType) { return "style=filled, fillcolor=wheat"; } else { return ""; } }
private String getTooltipString() { ExpressionType expression = getMapping().getExpression(); if (expression == null || expression.getExpressionEvaluator().isEmpty()) { return "asIs"; } JAXBElement<?> evalElement = expression.getExpressionEvaluator().get(0); Object eval = evalElement.getValue(); if (QNameUtil.match(evalElement.getName(), SchemaConstants.C_VALUE)) { return getStringConstant(eval); } else if (eval instanceof AsIsExpressionEvaluatorType) { return "asIs"; } else if (eval instanceof ScriptExpressionEvaluatorType) { return ((ScriptExpressionEvaluatorType) eval).getCode(); } else if (eval instanceof ItemPathType) { return String.valueOf(((ItemPathType) eval).getItemPath()); } else { return ""; } }
@Nullable private String getLabel(String defaultLabel, boolean showConstant) { ExpressionType expression = getMapping().getExpression(); if (expression == null || expression.getExpressionEvaluator().isEmpty()) { return defaultLabel;
@Override public ValuePolicyType resolve() { if (mappingBuilder.getMappingType().getExpression() != null) { List<JAXBElement<?>> evaluators = mappingBuilder.getMappingType().getExpression().getExpressionEvaluator(); for (JAXBElement jaxbEvaluator : evaluators) { Object object = jaxbEvaluator.getValue(); if (object instanceof GenerateExpressionEvaluatorType && ((GenerateExpressionEvaluatorType) object).getValuePolicyRef() != null) { ObjectReferenceType ref = ((GenerateExpressionEvaluatorType) object).getValuePolicyRef(); try { ValuePolicyType valuePolicyType = mappingBuilder.getObjectResolver().resolve(ref, ValuePolicyType.class, null, "resolving value policy for generate attribute "+ outputDefinition.getName()+"value", task, new OperationResult("Resolving value policy")); if (valuePolicyType != null) { return valuePolicyType; } } catch (CommonException ex) { throw new SystemException(ex.getMessage(), ex); } } } } return null; } };
@Override protected void assertPrismContainerValueLocal(PrismContainerValue<MappingType> value) throws SchemaException { MappingType mappingType = value.getValue(); ExpressionType expressionType = mappingType.getExpression(); List<JAXBElement<?>> expressionEvaluatorElements = expressionType.getExpressionEvaluator(); assertEquals("Wrong number of expression evaluator elemenets", 1, expressionEvaluatorElements.size()); JAXBElement<?> expressionEvaluatorElement = expressionEvaluatorElements.get(0); Object evaluatorElementObject = expressionEvaluatorElement.getValue(); if (!(evaluatorElementObject instanceof ConstExpressionEvaluatorType)) { AssertJUnit.fail("Const expression is of type " + evaluatorElementObject.getClass().getName()); } ConstExpressionEvaluatorType constExpressionEvaluatorType = (ConstExpressionEvaluatorType)evaluatorElementObject; System.out.println("ConstExpressionEvaluatorType: "+constExpressionEvaluatorType); assertEquals("Wrong value in const evaluator", "foo", constExpressionEvaluatorType.getValue()); }
MappingType mappingType = radt.getOutbound(); if (mappingType != null) { if (mappingType.getExpression() == null) { sb.append("Empty mapping for ").append(path); } else { sb.append(path).append(" = "); boolean first = true; for (JAXBElement<?> evaluator : mappingType.getExpression().getExpressionEvaluator()) { if (first) { first = false;
private void checkMapping(ResourceValidationContext ctx, ItemPath path, ResourceObjectTypeDefinitionType objectType, QName itemName, MappingType mapping, boolean outbound, int index, boolean implicitSourceOrTarget) { String inOut = outbound ? getString("ResourceValidator.outboundMapping") : getString("ResourceValidator.inboundMapping", index); String itemNameText = prettyPrintUsingStandardPrefix(itemName); if (outbound && mapping.getTarget() != null) { ctx.validationResult.add(Issue.Severity.INFO, CAT_SCHEMA_HANDLING, C_SUPERFLUOUS_MAPPING_TARGET, getString(CLASS_DOT + C_SUPERFLUOUS_MAPPING_TARGET, getName(objectType), inOut, itemNameText, format(mapping.getTarget())), ctx.resourceRef, path); } if (!implicitSourceOrTarget && (mapping.getExpression() == null || mapping.getExpression().getExpressionEvaluator().isEmpty() || (mapping.getExpression().getExpressionEvaluator().size() == 1 && QNameUtil.match(mapping.getExpression().getExpressionEvaluator().get(0).getName(), SchemaConstantsGenerated.C_AS_IS)))) { if ((outbound && (mapping.getSource() == null || mapping.getSource().isEmpty())) || (!outbound && mapping.getTarget() == null)) { String code = outbound ? C_MISSING_MAPPING_SOURCE : C_MISSING_MAPPING_TARGET; ctx.validationResult.add(Issue.Severity.WARNING, CAT_SCHEMA_HANDLING, code, getString(CLASS_DOT + code, getName(objectType), inOut, itemNameText), ctx.resourceRef, path); } } for (VariableBindingDefinitionType source : mapping.getSource()) { checkItemPath(ctx, path, objectType, itemName, mapping, outbound, itemNameText, true, index, source.getPath()); } if (mapping.getTarget() != null) { checkItemPath(ctx, path, objectType, itemName, mapping, outbound, itemNameText, false, index, mapping.getTarget().getPath()); } }
if (mappingType.getExpression() != null){ List<JAXBElement<?>> evaluators = mappingType.getExpression().getExpressionEvaluator(); if (evaluators != null) { for (JAXBElement jaxbEvaluator : evaluators) {
private void checkAssignmentConstruction(UserType jack, String attributeName, String value) throws SchemaException { assertEquals("jack's assignments", 1, jack.getAssignment().size()); AssignmentType assignmentType = jack.getAssignment().get(0); ConstructionType constructionType = assignmentType.getConstruction(); assertNotNull("construction is null", constructionType); boolean found = false; for (ResourceAttributeDefinitionType attributeDefinitionType : constructionType.getAttribute()) { if (attributeDefinitionType.getRef().equivalent(new ItemPathType(ItemPath.create(new QName(attributeName))))) { ExpressionType expressionType = attributeDefinitionType.getOutbound().getExpression(); assertNotNull("no expression", expressionType); assertEquals("wrong # of expression evaluators", 1, expressionType.getExpressionEvaluator().size()); JAXBElement<?> element = expressionType.getExpressionEvaluator().get(0); PrimitiveXNode valueXNode = (PrimitiveXNode) (((RawType) element.getValue()).serializeToXNode()); assertEquals("wrong outbound value", value, valueXNode.getStringValue()); found = true; } } assertTrue("attribute " + attributeName + " mapping not found", found); }
List<ResourceAttributeDefinitionType> outboundAttributes = role.asObjectable().getInducement().get(0).getConstruction().getAttribute(); if (hasMultivalueInterests()) { ExpressionType outboundExpression = outboundAttributes.get(0).getOutbound().getExpression(); JAXBElement jaxbElement = outboundExpression.getExpressionEvaluator().get(0); jaxbElement.setValue(getRoleInterest(i));
foundDescription = true; MappingType outbound = attributeDefinitionType.getOutbound(); JAXBElement<?> valueEvaluator = outbound.getExpression().getExpressionEvaluator().get(0); System.out.println("value evaluator for description = " + valueEvaluator); assertNotNull("no expression evaluator for description", valueEvaluator);
private void evaluateExpression(Task task, OperationResult result, boolean conditionResultOld, boolean conditionResultNew) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { ExpressionType expressionType = null; if (mappingType != null) { expressionType = mappingType.getExpression();
JAXBElement<?> cutlassExpressionEvalJaxbElement = newAttrContainer.getValue().getOutbound().getExpression().getExpressionEvaluator().get(0); RawType cutlassValueEvaluator = (RawType) cutlassExpressionEvalJaxbElement.getValue(); XNode daggerXNode = prismContext.xnodeFactory().primitive("dagger"); RawType daggerValueEvaluator = new RawType(daggerXNode, prismContext); JAXBElement<?> daggerExpressionEvalJaxbElement = new JAXBElement<>(SchemaConstants.C_VALUE, Object.class, daggerValueEvaluator); newAttrContainer.getValue().getOutbound().getExpression().getExpressionEvaluator().add(daggerExpressionEvalJaxbElement); newAttrContainer.getValue().getOutbound().setStrength(MappingStrengthType.STRONG);