Program: 101965
Project: 101965
Buggy source:
/** 
 * Copy the model to the target, only copying those nodes selected in the tree viewer.
 * @param sourceModelResource modelResource containing the old information
 * @param targetModelResource the target ModelResource
 * @param viewer the tree viewer; root is the ModelResource
 * @param extraProperties optional properties to tweak creation of objects.
 * @param copyAllDescriptions option to copy or suppress copying all descriptions
 * @param monitor a progress monitor
 * @throws ModelerCoreException 
 */
@Override public void copyModel(ModelResource sourceModelResource,ModelResource targetModelResource,Map extraProperties,boolean copyAllDescriptions,IProgressMonitor monitor) throws ModelerCoreException {
  List allSourceRootContents=sourceModelResource.getEmfResource().getContents();
  boolean sourceIsVirtual=sourceModelResource.getModelAnnotation().getModelType().equals(ModelType.VIRTUAL_LITERAL);
  boolean targetIsVirtual=targetModelResource.getModelAnnotation().getModelType().equals(ModelType.VIRTUAL_LITERAL);
  ModelType targetModelType=targetModelResource.getModelAnnotation().getModelType();
  List filteredChildren=new ArrayList(allSourceRootContents.size());
  for (Iterator iter=allSourceRootContents.iterator(); iter.hasNext(); ) {
    EObject nextChild=(EObject)iter.next();
    if (nextChild instanceof AnnotationContainer) {
      if (copyAllDescriptions) {
        filteredChildren.add(nextChild);
      }
    }
 else     if (nextChild instanceof TransformationContainer) {
      if (targetIsVirtual && sourceIsVirtual) {
        filteredChildren.add(nextChild);
      }
    }
 else     if (ModelObjectUtilities.isJdbcSource(nextChild)) {
      if (!targetIsVirtual) {
        filteredChildren.add(nextChild);
      }
    }
 else {
      filteredChildren.add(nextChild);
    }
  }
  Collection sourceFirstLevelChildrenCopies=null;
  try {
    sourceFirstLevelChildrenCopies=ModelerCore.getModelEditor().copyAll(filteredChildren);
    List targetChildren=targetModelResource.getEmfResource().getContents();
    for (int numKids=targetChildren.size(), i=0; i < numKids; ++i) {
      Object kid=targetChildren.get(i);
      if (kid instanceof ModelAnnotation) {
        targetChildren.remove(kid);
        break;
      }
    }
  }
 catch (  ModelerCoreException ex) {
    throw ex;
  }
  targetModelResource.getEmfResource().getContents().addAll(sourceFirstLevelChildrenCopies);
  targetModelResource.getModelAnnotation().setModelType(targetModelType);
  if (targetIsVirtual) {
    try {
      List eObjects=targetModelResource.getEObjects();
      for (Iterator iter=eObjects.iterator(); iter.hasNext(); ) {
        NewModelObjectHelperManager.helpCreate(iter.next(),extraProperties);
      }
    }
 catch (    ModelerCoreException err) {
      throw err;
    }
  }
}

Fixed version (ground truth):
/** 
 * Copy the model to the target, only copying those nodes selected in the tree viewer.
 * @param sourceModelResource modelResource containing the old information
 * @param targetModelResource the target ModelResource
 * @param viewer the tree viewer; root is the ModelResource
 * @param extraProperties optional properties to tweak creation of objects.
 * @param copyAllDescriptions option to copy or suppress copying all descriptions
 * @param monitor a progress monitor
 * @throws ModelerCoreException 
 */
@Override public void copyModel(ModelResource sourceModelResource,ModelResource targetModelResource,Map extraProperties,boolean copyAllDescriptions,IProgressMonitor monitor) throws ModelerCoreException {
  List allSourceRootContents=sourceModelResource.getEmfResource().getContents();
  boolean sourceIsVirtual=sourceModelResource.getModelAnnotation().getModelType().equals(ModelType.VIRTUAL_LITERAL);
  boolean targetIsVirtual=targetModelResource.getModelAnnotation().getModelType().equals(ModelType.VIRTUAL_LITERAL);
  ModelType targetModelType=targetModelResource.getModelAnnotation().getModelType();
  List filteredChildren=new ArrayList(allSourceRootContents.size());
  for (Iterator iter=allSourceRootContents.iterator(); iter.hasNext(); ) {
    EObject nextChild=(EObject)iter.next();
    if (nextChild instanceof AnnotationContainer) {
      if (copyAllDescriptions) {
        filteredChildren.add(nextChild);
      }
    }
 else     if (nextChild instanceof TransformationContainer) {
      if (targetIsVirtual && sourceIsVirtual) {
        filteredChildren.add(nextChild);
      }
    }
 else     if (ModelObjectUtilities.isJdbcSource(nextChild)) {
      if (!targetIsVirtual) {
        filteredChildren.add(nextChild);
      }
    }
 else {
      filteredChildren.add(nextChild);
    }
  }
  Collection sourceFirstLevelChildrenCopies=null;
  try {
    sourceFirstLevelChildrenCopies=ModelerCore.getModelEditor().copyAll(filteredChildren);
    List targetChildren=targetModelResource.getEmfResource().getContents();
    for (int numKids=targetChildren.size(), i=0; i < numKids; ++i) {
      Object kid=targetChildren.get(i);
      if (kid instanceof ModelAnnotation) {
        targetChildren.remove(kid);
        break;
      }
    }
  }
 catch (  ModelerCoreException ex) {
    throw ex;
  }
  SqlTransformationMappingRootSqlAspect.replaceTransformationLiteral(sourceFirstLevelChildrenCopies,sourceModelResource.getItemName(),targetModelResource.getItemName());
  targetModelResource.getEmfResource().getContents().addAll(sourceFirstLevelChildrenCopies);
  ModelAnnotation modelAnnotation=targetModelResource.getModelAnnotation();
  modelAnnotation.setModelType(targetModelType);
  EList imports=modelAnnotation.getModelImports();
  if (imports != null) {
    ResourceFinder resourceFinder;
    try {
      resourceFinder=ModelerCore.getModelContainer().getResourceFinder();
    }
 catch (    CoreException ex) {
      throw new ModelerCoreException(ex);
    }
    List<Object> mImports=Arrays.asList(imports.toArray());
    for (    Object mImport : mImports) {
      ModelImport modelImport=(ModelImport)mImport;
      URI uri=URI.createURI(modelImport.getModelLocation());
      if (resourceFinder.isBuiltInResource(uri))       continue;
      Resource resource=resourceFinder.findByWorkspaceUri(uri,targetModelResource.getEmfResource());
      if (resource == null) {
        imports.remove(mImport);
      }
    }
  }
  if (targetIsVirtual) {
    try {
      List eObjects=targetModelResource.getEObjects();
      for (Iterator iter=eObjects.iterator(); iter.hasNext(); ) {
        NewModelObjectHelperManager.helpCreate(iter.next(),extraProperties);
      }
    }
 catch (    ModelerCoreException err) {
      throw err;
    }
  }
}