Program: 122078
Project: 122078
Buggy source:
private void prepareEmfTreeFromMdm(MDMConnection connection,String selectedConcept){
  if (connection == null || selectedConcept == null) {
    return;
  }
  EList<Concept> schemas=connection.getSchemas();
  Concept selected=null;
  for (int i=0; i < schemas.size(); i++) {
    Concept concept=schemas.get(i);
    if (selectedConcept.equals(concept.getLabel())) {
      selected=concept;
      break;
    }
  }
  if (selected != null) {
    IMDMProviderService service=(IMDMProviderService)GlobalServiceRegister.getDefault().getService(IMDMProviderService.class);
    if (service != null) {
      boolean initConcepts=service.initConcepts(connection);
      if (initConcepts) {
        if (!MdmConceptType.OUTPUT.equals(selected.getConceptType())) {
          String prefix=service.getXPathPrefixValue(selected);
          prefix=TalendTextUtils.removeQuotes(prefix);
          absoluteXPathQuery=selected.getLoopExpression();
          EList<ConceptTarget> conceptTargets=selected.getConceptTargets();
          if (conceptTargets == null || absoluteXPathQuery == null) {
            return;
          }
          this.schemaTargets=conceptTargets;
          List<FOXTreeNode> list=TreeUtil.getFoxTreeNodesForXmlMap(getTempTemplateXSDFile().getAbsolutePath(),absoluteXPathQuery);
          TreeNode pNode=schemaNode;
          if (MdmConceptType.RECEIVE.equals(selected.getConceptType())) {
            List<FOXTreeNode> updateNodesList=TreeUtil.parseMDMUpdateReport(shell,true);
            if (updateNodesList == null) {
              if (prefix != null && !"String_Node_Str".equals(prefix)) {
                String[] preValues=prefix.split(XmlMapUtil.XPATH_SEPARATOR);
                for (                String value : preValues) {
                  if (!"String_Node_Str".equals(value)) {
                    TreeNode createTreeNode=createModel();
                    createTreeNode.setName(value);
                    createTreeNode.setNodeType(NodeType.ELEMENT);
                    createTreeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
                    createTreeNode.setXpath(XmlMapUtil.getXPath(pNode.getXpath(),createTreeNode.getName(),createTreeNode.getNodeType()));
                    pNode.getChildren().add(createTreeNode);
                    pNode=createTreeNode;
                  }
                }
                absoluteXPathQuery=prefix + absoluteXPathQuery;
              }
            }
 else {
              TreeNode rootNode=createDefaultTreeNode(pNode,"String_Node_Str");
              TreeNode reportNode=createDefaultTreeNode(rootNode,"String_Node_Str");
              TreeNode itemNode=createDefaultTreeNode(rootNode,"String_Node_Str");
              prepareEmfTree(updateNodesList,reportNode,true);
              pNode=itemNode;
              absoluteXPathQuery="String_Node_Str" + absoluteXPathQuery;
            }
          }
          prepareEmfTree(list,pNode);
        }
 else {
          List<FOXTreeNode> list=TreeUtil.getFoxTreeNodesForXmlMap(getTempTemplateXSDFile().getAbsolutePath(),selected.getRoot().get(0).getXMLPath());
          root=selected.getRoot();
          loop=selected.getLoop();
          group=selected.getGroup();
          groupElements=new ArrayList<TreeNode>();
          prepareModelFromOutput(list,schemaNode);
          if (loopNode != null) {
            fillGroup(loopNode,groupElements);
          }
 else {
            if (!schemaNode.getChildren().isEmpty()) {
              schemaNode.getChildren().get(0).setLoop(true);
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void prepareEmfTreeFromMdm(MDMConnection connection,String selectedConcept) throws Exception {
  if (connection == null || selectedConcept == null) {
    return;
  }
  EList<Concept> schemas=connection.getSchemas();
  Concept selected=null;
  for (int i=0; i < schemas.size(); i++) {
    Concept concept=schemas.get(i);
    if (selectedConcept.equals(concept.getLabel())) {
      selected=concept;
      break;
    }
  }
  if (selected != null) {
    IMDMProviderService service=(IMDMProviderService)GlobalServiceRegister.getDefault().getService(IMDMProviderService.class);
    if (service != null) {
      boolean initConcepts=service.initConcepts(connection);
      if (initConcepts) {
        if (!MdmConceptType.OUTPUT.equals(selected.getConceptType())) {
          String prefix=service.getXPathPrefixValue(selected);
          prefix=TalendTextUtils.removeQuotes(prefix);
          absoluteXPathQuery=selected.getLoopExpression();
          EList<ConceptTarget> conceptTargets=selected.getConceptTargets();
          if (conceptTargets == null || absoluteXPathQuery == null) {
            return;
          }
          this.schemaTargets=conceptTargets;
          List<FOXTreeNode> list=TreeUtil.getFoxTreeNodesForXmlMap(getTempTemplateXSDFile().getAbsolutePath(),absoluteXPathQuery);
          TreeNode pNode=schemaNode;
          if (MdmConceptType.RECEIVE.equals(selected.getConceptType())) {
            List<FOXTreeNode> updateNodesList=TreeUtil.parseMDMUpdateReport(shell,true);
            schemaNode.getChildren().clear();
            if (updateNodesList == null) {
              if (prefix != null && !"String_Node_Str".equals(prefix)) {
                String[] preValues=prefix.split(XmlMapUtil.XPATH_SEPARATOR);
                for (                String value : preValues) {
                  if (!"String_Node_Str".equals(value)) {
                    TreeNode createTreeNode=createModel();
                    createTreeNode.setName(value);
                    createTreeNode.setNodeType(NodeType.ELEMENT);
                    createTreeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
                    createTreeNode.setXpath(XmlMapUtil.getXPath(pNode.getXpath(),createTreeNode.getName(),createTreeNode.getNodeType()));
                    pNode.getChildren().add(createTreeNode);
                    pNode=createTreeNode;
                  }
                }
                absoluteXPathQuery=prefix + absoluteXPathQuery;
              }
            }
 else {
              TreeNode rootNode=createDefaultTreeNode(pNode,"String_Node_Str");
              TreeNode reportNode=createDefaultTreeNode(rootNode,"String_Node_Str");
              TreeNode itemNode=createDefaultTreeNode(rootNode,"String_Node_Str");
              prepareEmfTree(updateNodesList,reportNode,true);
              pNode=itemNode;
              absoluteXPathQuery="String_Node_Str" + absoluteXPathQuery;
            }
          }
 else {
            schemaNode.getChildren().clear();
          }
          prepareEmfTree(list,pNode);
        }
 else {
          List<FOXTreeNode> list=TreeUtil.getFoxTreeNodesForXmlMap(getTempTemplateXSDFile().getAbsolutePath(),selected.getRoot().get(0).getXMLPath());
          schemaNode.getChildren().clear();
          root=selected.getRoot();
          loop=selected.getLoop();
          group=selected.getGroup();
          groupElements=new ArrayList<TreeNode>();
          prepareModelFromOutput(list,schemaNode);
          if (loopNode != null) {
            fillGroup(loopNode,groupElements);
          }
 else {
            if (!schemaNode.getChildren().isEmpty()) {
              schemaNode.getChildren().get(0).setLoop(true);
            }
          }
        }
      }
    }
  }
}