private static boolean hasExplicitTarget(MappingType mappingType) { return mappingType.getTarget() != null; }
public boolean hasTargetRange() { return mappingType.getTarget().getSet() != null || mappingType.getRange() != null; }
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 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 checkRange(Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { VariableBindingDefinitionType target = mappingType.getTarget(); if (target != null && target.getSet() != null) { checkRangeTarget(task, result); } if (mappingType.getRange() != null) { checkRangeLegacy(task, result); } }
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 void checkRangeTarget(Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { QName name = outputPath.lastName(); if (originalTargetValues == null) { throw new IllegalStateException("Couldn't check range for mapping in " + contextDescription + ", as original target values are not known."); } ValueSetDefinitionType rangetSetDefType = mappingType.getTarget().getSet(); ValueSetDefinition setDef = new ValueSetDefinition(rangetSetDefType, name, "range of "+name.getLocalPart()+" in "+getMappingContextDescription(), task, result); setDef.init(expressionFactory); setDef.setAdditionalVariables(variables); for (V originalValue : originalTargetValues) { if (!setDef.contains(originalValue)) { continue; } addToMinusIfNecessary(originalValue); } }
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 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); } }
private void parseTarget() throws SchemaException { VariableBindingDefinitionType targetType = mappingType.getTarget(); if (targetType == null) { outputDefinition = defaultTargetDefinition; outputPath = defaultTargetPath; } else { ItemPathType itemPathType = targetType.getPath(); if (itemPathType == null) { outputDefinition = defaultTargetDefinition; outputPath = defaultTargetPath; } else { ItemPath path = itemPathType.getItemPath(); outputDefinition = ExpressionUtil.resolveDefinitionPath(path, variables, targetContext, "target definition in "+getMappingContextDescription()); if (outputDefinition == null) { throw new SchemaException("No target item that would conform to the path "+path+" in "+getMappingContextDescription()); } outputPath = path.stripVariableSegment(); } } if (stringPolicyResolver != null) { stringPolicyResolver.setOutputDefinition(outputDefinition); stringPolicyResolver.setOutputPath(outputPath); } }
Collection<V> originalValues = ExpressionUtil.computeTargetValues(inboundMappingType.getTarget(), focusNew, variables, mappingFactory.getObjectResolver() , "resolving range", prismContext, task, result); builder.originalTargetValues(originalValues);
variables.addVariableDefinition(ExpressionConstants.VAR_OPERATION, context.getFocusContext().getOperation().getValue()); Collection<V> targetValues = ExpressionUtil.computeTargetValues(mappingType.getTarget(), defaultTargetObject, variables, mappingFactory.getObjectResolver(), contextDesc, prismContext, task, result);