public JSONObject setXPathMapping(String source, String target, int index) {
    MappingElement sourceElement = this.inputSchema.getMappingElement(source);
    JSONObject targetElement = this.elementCache.get(target);
    String xpath = sourceElement.getXPath();
    String type = sourceElement.getType();

    //		setXPathMapping(xpath, targetElement, index);
    setXPathMapping(xpath, type, targetElement, index);
    saveMappings();

    return targetElement;
  }
  public JSONObject setConditionXPath(String target, String value) {
    JSONObject targetElement = this.elementCache.get(target);
    MappingElement sourceElement = this.inputSchema.getMappingElement(value);
    String xpath = sourceElement.getXPath();
    String type = sourceElement.getType();

    if (targetElement.has("condition")) {
      log.debug("Set condition xpath for " + target + " to " + xpath);
      targetElement.getJSONObject("condition").put("xpath", xpath);
      targetElement.getJSONObject("condition").put("type", type);
      targetElement.getJSONObject("condition").remove("value");
      saveMappings();
    }

    return targetElement;
  }
  public JSONObject setConditionClauseXPath(String id, String path, String source) {
    JSONObject result = new JSONObject();
    JSONObject targetElement = this.elementCache.get(id);
    if (targetElement.has("condition")) {
      MappingElement sourceElement = this.inputSchema.getMappingElement(source);
      String value = sourceElement.getXPath();
      String type = sourceElement.getType();
      JSONObject condition = targetElement.getJSONObject("condition");
      this.setConditionClauseKey(condition, path, "xpath", value);
      this.setConditionClauseKey(condition, path, "type", type);
      this.removeConditionClauseKey(condition, path, "value");
      result = condition;

      saveMappings();
    }

    return result;
  }
Example #4
0
  public void addChildElement(MappingElement elem) {
    if (elem.isRecursive()) {
      MappingRecursiveElement recursiveElement = (MappingRecursiveElement) elem;
      MappingBaseNode recursiveRoot = getRecursiveRootNode(recursiveElement);
      String mappingClass = recursiveElement.getMappingClass();

      /* The upper case of the class is used in Teiid 7 mappings */
      ITeiidVersion minVersion = getTeiidVersion().getMinimumVersion();
      if (minVersion.isLessThan(Version.TEIID_8_0.get())) mappingClass = mappingClass.toUpperCase();

      recursiveRoot.setRootRecursiveNode(true, mappingClass);
      addChild(elem);
    } else {
      addChild(elem);
    }
  }
 /** Make sure the cardinality is set correctly */
 private void fixCardinality(MappingElement root) {
   root.setMaxOccurrs(1);
   root.setMinOccurrs(1);
 }