private void populateMappingInfo(EObject xmlEntity) {
    Resource resource = xmlEntity.eResource();

    // model contents for this resource
    ModelContents mdlContents = new ModelContents(resource);
    XmlDocument document = getXmlDocument(xmlEntity);
    currentDocumentName = document.getName();
    // fill the map with element to its mappingClass column value
    this.elementMap = new HashMap();
    this.elementFullNames = new HashSet();
    // get the mapping root associated with the transformation
    Iterator rootIter = mdlContents.getTransformations(document).iterator();
    while (rootIter.hasNext()) {
      MappingRoot mappingRoot = (MappingRoot) rootIter.next();
      // if there is a mapping root
      if (mappingRoot != null && mappingRoot instanceof TreeMappingRoot) {
        Iterator mappingIter = mappingRoot.getNested().iterator();
        while (mappingIter.hasNext()) {
          Mapping nestedMapping = (Mapping) mappingIter.next();
          // mapping Class columns
          List inputs = nestedMapping.getInputs();
          // xml elements
          List outputs = nestedMapping.getOutputs();
          if (!outputs.isEmpty() && !inputs.isEmpty()) {
            Object output = outputs.iterator().next();
            Object input = inputs.iterator().next();
            elementMap.put(output, input);
            if (output instanceof XmlElement) {
              elementFullNames.add(this.getFullName((EObject) output));
            }
          }
        }
      }
    }
  }
Пример #2
0
  public void dispose() {
    if (mappedObjectStateAdapterFactory instanceof IDisposable) {
      ((IDisposable) mappedObjectStateAdapterFactory).dispose();
    }

    MappingRoot typeMappingRoot = getTypeMappingRoot();
    if (typeMappingRoot != null) {
      typeMappingRoot.dispose();
    }

    // printAdapters();
  }