/** * Create an instance of {@link MappingType } * */ public MappingType createMappingType() { return new MappingType(); }
public MappingType source(VariableBindingDefinitionType value) { getSource().add(value); return this; }
public MappingType expression(ExpressionType value) { setExpression(value); return this; }
@Override protected MappingType createItem(PrismContainerValue value) { MappingType mapping = new MappingType(); mapping.setupContainerValue(value); return mapping; }
public MappingType clone() { MappingType object = new MappingType(); PrismContainerValue value = asPrismContainerValue().clone(); object.setupContainerValue(value); return object; }
public List<VariableBindingDefinitionType> createSourceList() { PrismForJAXBUtil.createProperty(asPrismContainerValue(), F_SOURCE); return getSource(); }
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(); }
MappingType outbound = new MappingType(); outbound.setStrength(MappingStrengthType.STRONG); // to see changes on the resource ExpressionType expression = new ExpressionType(); expression.getExpressionEvaluator().add(new ObjectFactory().createValue(value)); outbound.setExpression(expression); attributeDefinitionType.setOutbound(outbound);
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; }
MappingType mapping = new MappingType(); mapping.setName(name + "-" + i); VariableBindingDefinitionType source = new VariableBindingDefinitionType(); source.setPath(new ItemPathType(UserType.F_NAME)); mapping.getSource().add(source); VariableBindingDefinitionType target = new VariableBindingDefinitionType(); target.setPath(new ItemPathType(UserType.F_DESCRIPTION)); mapping.setTarget(target); MappingsType mappings = new MappingsType(prismContext); mappings.getMapping().add(mapping);
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()); } }
private void processInboundMapping(@NotNull DataModel model, @NotNull ResourceDataItem sourceItem, @NotNull MappingType mapping, @Nullable ItemPath defaultTargetItemPath) { LOGGER.debug("Processing inbound mapping: {} for {}", mapping, sourceItem); List<DataItem> sources = new ArrayList<>(); for (VariableBindingDefinitionType sourceDecl : mapping.getSource()) { LOGGER.debug(" - src: {}", sourceDecl.getPath()); DataItem explicitSourceItem = resolveSourceItem(model, sourceItem, mapping, sourceDecl, null); sources.add(explicitSourceItem); } if (!sources.contains(sourceItem)) { sources.add(sourceItem); } DataItem targetItem = null; VariableBindingDefinitionType targetDecl = mapping.getTarget(); if (mapping.getTarget() != null) { LOGGER.debug(" - target: {}", targetDecl.getPath()); targetItem = resolveTargetItem(model, sourceItem, mapping, targetDecl, ExpressionConstants.VAR_FOCUS); } else if (defaultTargetItemPath != null) { targetItem = resolveTargetItem(model, sourceItem, mapping, defaultTargetItemPath, ExpressionConstants.VAR_FOCUS); } model.registerMappingRelation(sources, targetItem, mapping); }
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); }
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); foundDepartmentNumber = true; MappingType outbound = attributeDefinitionType.getOutbound(); VariableBindingDefinitionType source = outbound.getSource().get(0); System.out.println("source for departmentNumber = " + source); assertNotNull("no source for outbound mapping for departmentNumber", source);
ResourceAttributeDefinitionType radt = new ResourceAttributeDefinitionType(); radt.setRef(new ItemPathType(gossipDefinition.getName())); MappingType outbound = new MappingType(); radt.setOutbound(outbound); outbound.setExpression(expression); MappingType value = new MappingType(); value.setExpression(expression); radt.setOutbound(value); accountConstruction.getAttribute().add(radt);
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; if (mappingType.getStrength() != null) { sb.append(" (").append(mappingType.getStrength().value()).append(")");
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);
@Override public String getIdentifier() { return mappingType != null ? mappingType.getName() : null; }
public static MappingStrengthType getStrength(MappingType mappingType) { if (mappingType == null) { return MappingStrengthType.NORMAL; } MappingStrengthType value = mappingType.getStrength(); if (value == null) { value = MappingStrengthType.NORMAL; } return value; }
private void setMappingTarget(MappingType mapping, ItemPathType path) { VariableBindingDefinitionType target = mapping.getTarget(); if (target == null) { target = new VariableBindingDefinitionType(); target.setPath(path); mapping.setTarget(target); } else if (target.getPath() == null) { target = target.clone(); target.setPath(path); mapping.setTarget(target); } }