/**
   * @see
   *     com.metamatrix.modeler.core.metamodel.aspect.sql.SqlColumnAspect#isTranformationInputParameter(org.eclipse.emf.ecore.EObject)
   * @since 4.2
   */
  public boolean isTranformationInputParameter(EObject eObject) {
    CoreArgCheck.isInstanceOf(XmlElement.class, eObject);
    final XmlElement element = (XmlElement) eObject;

    if (element instanceof XmlRoot) {
      return false;
    }

    final XmlDocument doc = getDocParent(element);
    final XmlElement parent = getElementParent(element);
    if (doc == null || parent == null) {
      return false;
    }

    Resource eResource = element.eResource();
    if (eResource instanceof EmfResource) {
      EmfResource emfResource = (EmfResource) eResource;
      ModelContents contents = emfResource.getModelContents();
      if (contents != null) {
        for (final Iterator mappings = contents.getTransformations(doc).iterator();
            mappings.hasNext(); ) {
          final TreeMappingRoot tmr = (TreeMappingRoot) mappings.next();
          if (tmr.getOutputs().contains(parent)) {
            final Iterator nested = tmr.getNested().iterator();
            while (nested.hasNext()) {
              final Mapping mapping = (Mapping) nested.next();
              if (mapping.getOutputs().contains(element)) {
                if (mapping.getInputs().size() == 0) {
                  return false;
                }
                Iterator i = mapping.getInputs().iterator();
                while (i.hasNext()) {
                  MappingClassColumn column = (MappingClassColumn) i.next();
                  SqlAspect aspect = AspectManager.getSqlAspect(column);
                  if (!(aspect instanceof SqlColumnAspect)) {
                    return false;
                  }
                  if (!((SqlColumnAspect) aspect).isTranformationInputParameter(column)) {
                    return false;
                  }
                }
                return true;
              }
            }
          }
        }
      }
    }
    return false;
  }
  /*
   * @see com.metamatrix.modeler.core.metamodel.aspect.sql.SqlColumnAspect#getDatatype(org.eclipse.emf.ecore.EObject)
   */
  public EObject getDatatype(EObject eObject) {
    CoreArgCheck.isInstanceOf(XmlElement.class, eObject);
    XmlElement xmlElement = (XmlElement) eObject;
    if (elementMap == null) {
      populateMappingInfo(xmlElement);
    }

    Object lookupObj = elementMap.get(xmlElement);
    if (lookupObj == null
        && (elementFullNames.contains(this.getFullName(xmlElement))
            || !currentDocumentName.equals(getXmlDocument(xmlElement).getName()))) {
      populateMappingInfo(xmlElement);
      lookupObj = elementMap.get(xmlElement);
    }

    Container cntr = ModelerCore.getContainer(eObject);

    if (lookupObj != null) {
      CoreArgCheck.isInstanceOf(MappingClassColumn.class, lookupObj, null);
      MappingClassColumn mappingColumn = (MappingClassColumn) lookupObj;
      EObject type = mappingColumn.getType();
      return resolveWhenProxy(type, cntr);
    }

    try {
      final XSDComponent xsdComp = xmlElement.getXsdComponent();
      if (xsdComp instanceof XSDElementDeclaration) {
        final EObject type = ((XSDElementDeclaration) xsdComp).getTypeDefinition();
        if (type != null) {
          return resolveWhenProxy(type, cntr);
        }
      }

      return ModelerCore.getDatatypeManager(eObject)
          .getBuiltInDatatype(DatatypeConstants.BuiltInNames.STRING);
    } catch (Throwable e) {
    } // ignore

    return null;
  }
  private XmlElement getElementParent(final XmlElement child) {
    if (child == null) {
      return null;
    }

    EObject parent = child.eContainer();
    while (parent != null) {
      if (parent instanceof XmlElement) {
        return (XmlElement) parent;
      }

      parent = parent.eContainer();
    }

    return null;
  }