Program: 121501
Project: 121501
Buggy source:
/** 
 * Save the diagram in a Xml File.
 * @param file
 * @return
 * @throws IOException
 */
@Override public ProcessType saveXmlFile() throws IOException {
  init();
  TalendFileFactory fileFact=TalendFileFactory.eINSTANCE;
  ProcessType processType=createProcessType(fileFact);
  ParametersType params=fileFact.createParametersType();
  processType.setParameters(params);
  saveElementParameters(fileFact,this.getElementParameters(),processType.getParameters().getElementParameter(),processType);
  saveRoutinesDependencies(processType);
  EList nList=processType.getNode();
  EList cList=processType.getConnection();
  MetadataEmfFactory factory=new MetadataEmfFactory();
  JobletUtil jutil=new JobletUtil();
  for (  Element element : elem) {
    if (element instanceof SubjobContainer) {
      saveSubjob(fileFact,processType,(SubjobContainer)element);
      for (      NodeContainer container : ((SubjobContainer)element).getNodeContainers()) {
        if (container instanceof JobletContainer) {
          JobletContainer jobletCon=(JobletContainer)container;
          boolean needUpdate=false;
          IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
          if (service != null) {
            needUpdate=service.checkModify(jobletCon);
          }
          saveJobletNode(jobletCon,needUpdate);
          saveNode(fileFact,processType,nList,cList,container.getNode(),factory);
        }
 else {
          saveNode(fileFact,processType,nList,cList,container.getNode(),factory);
        }
      }
    }
    if (element instanceof JobletContainer) {
      JobletContainer jobletCon=(JobletContainer)element;
      boolean needUpdate=false;
      IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
      if (service != null) {
        needUpdate=service.checkModify(jobletCon);
      }
      saveJobletNode(jobletCon,needUpdate);
      saveNode(fileFact,processType,nList,cList,((NodeContainer)element).getNode(),factory);
    }
 else     if (element instanceof NodeContainer) {
      saveNode(fileFact,processType,nList,cList,((NodeContainer)element).getNode(),factory);
    }
 else     if (element instanceof Note) {
      saveNote(fileFact,processType,(Note)element);
    }
  }
  processType.setDefaultContext(contextManager.getDefaultContext().getName());
  processType.setScreenshot(getScreenshot());
  if (getScreenshot() != null) {
    processType.getScreenshots().put("String_Node_Str",getScreenshot());
  }
  setScreenshot(null);
  contextManager.saveToEmf(processType.getContext());
  return processType;
}

Fixed version (ground truth):
/** 
 * Save the diagram in a Xml File.
 * @param file
 * @return
 * @throws IOException
 */
@Override public ProcessType saveXmlFile() throws IOException {
  init();
  TalendFileFactory fileFact=TalendFileFactory.eINSTANCE;
  ProcessType processType=createProcessType(fileFact);
  ParametersType params=fileFact.createParametersType();
  processType.setParameters(params);
  saveElementParameters(fileFact,this.getElementParameters(),processType.getParameters().getElementParameter(),processType);
  saveRoutinesDependencies(processType);
  EList nList=processType.getNode();
  EList cList=processType.getConnection();
  MetadataEmfFactory factory=new MetadataEmfFactory();
  JobletUtil jutil=new JobletUtil();
  for (  Element element : elem) {
    if (element instanceof SubjobContainer) {
      saveSubjob(fileFact,processType,(SubjobContainer)element);
      for (      NodeContainer container : ((SubjobContainer)element).getNodeContainers()) {
        if (container instanceof JobletContainer) {
          JobletContainer jobletCon=(JobletContainer)container;
          boolean needUpdate=false;
          IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
          if (service != null) {
            needUpdate=service.checkModify(jobletCon);
          }
          saveJobletNode(jobletCon,needUpdate);
          saveNode(fileFact,processType,nList,cList,container.getNode(),factory);
        }
 else {
          saveNode(fileFact,processType,nList,cList,container.getNode(),factory);
        }
      }
    }
    if (element instanceof JobletContainer) {
      JobletContainer jobletCon=(JobletContainer)element;
      boolean needUpdate=false;
      IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
      if (service != null) {
        needUpdate=service.checkModify(jobletCon);
      }
      saveJobletNode(jobletCon,needUpdate);
      saveNode(fileFact,processType,nList,cList,((NodeContainer)element).getNode(),factory);
    }
 else     if (element instanceof NodeContainer) {
      saveNode(fileFact,processType,nList,cList,((NodeContainer)element).getNode(),factory);
    }
 else     if (element instanceof Note) {
      saveNote(fileFact,processType,(Note)element);
    }
  }
  processType.setDefaultContext(contextManager.getDefaultContext().getName());
  processType.setScreenshot(getScreenshot());
  if (getScreenshot() != null) {
    processType.getScreenshots().put("String_Node_Str",getScreenshot());
  }
  setScreenshot(null);
  contextManager.saveToEmf(processType.getContext());
  EmfHelper.removeProxy(processType);
  return processType;
}