ResourceSet resourceSet = ((DataGraphImpl)dataGraph).getResourceSet();
for (Iterator iterator = packages.iterator(); iterator.hasNext();) {
EPackage typePackage = (EPackage)iterator.next();
Resource resource = typePackage.eResource();
if (resource == null) {
resource = resourceSet.createResource(URI.createURI(".ecore"));
resource.setURI(URI.createURI(typePackage.getNsURI()));
resource.getContents().add(typePackage);
} else if (resource.getResourceSet() != resourceSet)