コード例 #1
0
 /**
  * @see
  *     org.teiid.designer.core.container#isExternalResource(org.eclipse.emf.ecore.resource.Resource)
  * @since 4.3
  */
 @Override
 public boolean isExternalResource(final Resource theResource) {
   if (theResource != null && ModelerCore.getContainer(theResource) == getContainer()) {
     return false;
   }
   return true;
 }
コード例 #2
0
  /**
   * Find the EObject having the specified UUID using the ObjectManager for the lookup. If an
   * EObject with this UUID cannot be found then null is returned.
   */
  protected EObject lookupEObject(final String uuid) {
    CoreArgCheck.isNotEmpty(uuid);

    // Before searching by UUID make sure all resources associated with this QMI are loaded
    if (this.getResources() != null) {
      for (Iterator iter = this.getResources().iterator(); iter.hasNext(); ) {
        Resource r = (Resource) iter.next();
        if (!r.isLoaded()) {
          try {
            r.load(Collections.EMPTY_MAP);
          } catch (IOException e) {
            TransformationPlugin.Util.log(IStatus.ERROR, e.getLocalizedMessage());
          }
        }
      }
    }

    // Go to the Container ...
    EObject eObject = null;

    if (this.getContainer() != null) {
      eObject = (EObject) this.getContainer().getEObjectFinder().find(uuid);

      if (eObject != null) {
        // get the resource on the object
        Resource resource = eObject.eResource();
        // check if this is among the resources is scope for this QMI
        if (this.getResources() != null) {
          Container cntr = ModelerCore.getContainer(resource);
          // If the resource exists in the same Container as the one associated with this QMI
          // but the resource is not in the scope of resources then return null
          if (cntr == this.getContainer() && !this.getResources().contains(resource)) {
            return null;
          }
        }
      }
      return eObject;
    }

    // We are in a non-container environment
    Iterator rsrs = this.getResources().iterator();
    while (rsrs.hasNext()) {
      Resource rsrc = (Resource) rsrs.next();
      if (rsrc instanceof MMXmiResource) {
        eObject = ((MMXmiResource) rsrc).getEObject(uuid);
        if (eObject != null) {
          return eObject;
        }
      } else if (rsrc instanceof XSDResourceImpl) {
        eObject = ((XSDResourceImpl) rsrc).getEObject(uuid);
        if (eObject != null) {
          return eObject;
        }
      }
    }

    return eObject;
  }
コード例 #3
0
 /**
  * @see org.teiid.designer.core.container#findByURI(org.eclipse.emf.common.util.URI, boolean)
  * @since 4.3
  */
 @Override
 public Resource findByURI(final URI theUri, final boolean searchExternal) {
   Resource result = getContainer().getResource(theUri, false);
   if (result == null && searchExternal) {
     ResourceSet[] externalSets = getContainer().getExternalResourceSets();
     for (int i = 0; i != externalSets.length; ++i) {
       result = externalSets[i].getResource(theUri, false);
       if (result != null) {
         break;
       }
     }
   }
   // If the result cannot be an external resource then check its resource set
   if (result != null && !searchExternal && ModelerCore.getContainer(result) != getContainer()) {
     result = null;
   }
   return result;
 }