public MappingType source(VariableBindingDefinitionType value) { getSource().add(value); return this; }
public List<VariableBindingDefinitionType> createSourceList() { PrismForJAXBUtil.createProperty(asPrismContainerValue(), F_SOURCE); return getSource(); }
private void parseSources(Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, SecurityViolationException, ConfigurationException, CommunicationException { List<VariableBindingDefinitionType> sourceTypes = mappingType.getSource(); if (defaultSource != null) { defaultSource.recompute(); sources.add(defaultSource); defaultSource.recompute(); } if (sourceTypes != null) { for (VariableBindingDefinitionType sourceType: sourceTypes) { Source<?,?> source = parseSource(sourceType, task, result); source.recompute(); // Override existing sources (e.g. default source) sources.removeIf(next -> next.getName().equals(source.getName())); sources.add(source); } } }
private void processOutboundMapping(@NotNull DataModel model, @NotNull ResourceDataItem targetItem, @NotNull MappingType mapping, @Nullable ItemPath defaultSourceItemPath) { LOGGER.debug("Processing outbound mapping: {} for {}", mapping, targetItem); List<DataItem> sources = new ArrayList<>(); for (VariableBindingDefinitionType sourceDecl : mapping.getSource()) { LOGGER.debug(" - src: {}", sourceDecl.getPath()); DataItem sourceItem = resolveSourceItem(model, targetItem, mapping, sourceDecl, ExpressionConstants.VAR_FOCUS); sources.add(sourceItem); } if (defaultSourceItemPath != null) { DataItem defaultSource = resolveSourceItem(model, targetItem, mapping, defaultSourceItemPath, ExpressionConstants.VAR_FOCUS); if (!sources.contains(defaultSource)) { sources.add(defaultSource); } } VariableBindingDefinitionType targetDecl = mapping.getTarget(); if (targetDecl != null) { LOGGER.warn(" - ignoring target (mapping is outbound): {}; using {} instead", targetDecl.getPath(), targetItem); } model.registerMappingRelation(sources, targetItem, mapping); }
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 <F extends FocusType> boolean isActivated(List<MappingType> outboundMappingTypes, ObjectDelta<F> focusDelta) { if (focusDelta == null) { return false; } for (MappingType outboundMappingType: outboundMappingTypes) { List<VariableBindingDefinitionType> sources = outboundMappingType.getSource(); if (sources.isEmpty()) { // Default source if (focusDelta.hasItemDelta(SchemaConstants.PATH_PASSWORD_VALUE)) { return true; } } for (VariableBindingDefinitionType source: sources) { ItemPathType pathType = source.getPath(); ItemPath path = pathType.getItemPath().stripVariableSegment(); if (focusDelta.hasItemDelta(path)) { return true; } } } return 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()); } }
private boolean dependsOn(FocalMappingSpec mappingSpec1, FocalMappingSpec mappingSpec2) { MappingType mapping1 = mappingSpec1.getMappingType(); MappingType mapping2 = mappingSpec2.getMappingType(); if (mapping2.getTarget() == null || mapping2.getTarget().getPath() == null) { return false; } ItemPath targetPath = mapping2.getTarget().getPath().getItemPath().stripVariableSegment(); for (VariableBindingDefinitionType source : mapping1.getSource()) { ItemPath sourcePath = prismContext.toPath(source.getPath()); if (sourcePath != null && stripFocusVariableSegment(sourcePath).equivalent(targetPath)) { return true; } } return false; }
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; }
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);
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));
PolicyViolationException, SchemaException { ObjectDeltaObject<AH> focusOdoCloned = null; for (VariableBindingDefinitionType source : mappingSpec.getMappingType().getSource()) { if (source.getPath() == null) { continue;