Program: 138808
Project: 138808
Buggy source:
/** 
 * DOC bZhou Comment method "createItem".
 * @param element
 * @return
 */
public Item createItem(ModelElement element){
  Item item=null;
  if (ModelElementIdentifier.isAnalysis(element)) {
    item=PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
  }
 else   if (ModelElementIdentifier.isDQRule(element)) {
    item=PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
  }
 else   if (ModelElementIdentifier.isDataProvider(element)) {
    if (element instanceof DatabaseConnection) {
      item=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
    }
 else     if (element instanceof MDMConnection) {
      item=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createMDMConnectionItem();
    }
    ((ConnectionItem)item).setConnection((Connection)element);
  }
 else   if (ModelElementIdentifier.isID(element)) {
    item=PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
  }
 else   if (ModelElementIdentifier.isPattern(element)) {
    item=PropertiesFactory.eINSTANCE.createTDQPatternItem();
  }
 else   if (ModelElementIdentifier.isReport(element)) {
    item=PropertiesFactory.eINSTANCE.createTDQReportItem();
  }
 else {
    item=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createTDQItem();
  }
  ItemState itemState=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
  itemState.setDeleted(false);
  item.setState(itemState);
  Resource eResource=element.eResource();
  if (eResource != null) {
    URI uri=eResource.getURI();
    if (item instanceof TDQItem) {
      ((TDQItem)item).setFilename(uri.lastSegment());
    }
    if (uri.isPlatform()) {
      IPath elementPath=new Path(uri.toPlatformString(true)).removeLastSegments(1);
      IPath typedPath=ResourceManager.getRootProject().getFullPath().append(PropertyHelper.getItemTypedPath(item));
      IPath statePath=elementPath.makeRelativeTo(typedPath);
      itemState.setPath(statePath.toString());
    }
  }
  return item;
}

Fixed version (ground truth):
/** 
 * DOC bZhou Comment method "createItem".
 * @param element
 * @return
 */
public Item createItem(ModelElement element){
  Item item=null;
  if (ModelElementIdentifier.isAnalysis(element)) {
    item=PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
  }
 else   if (ModelElementIdentifier.isDQRule(element)) {
    item=PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
  }
 else   if (ModelElementIdentifier.isDataProvider(element)) {
    if (element instanceof DatabaseConnection) {
      item=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
    }
 else     if (element instanceof MDMConnection) {
      item=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createMDMConnectionItem();
    }
    ((ConnectionItem)item).setConnection((Connection)element);
  }
 else   if (ModelElementIdentifier.isID(element)) {
    item=PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
  }
 else   if (ModelElementIdentifier.isPattern(element)) {
    item=PropertiesFactory.eINSTANCE.createTDQPatternItem();
  }
 else   if (ModelElementIdentifier.isReport(element)) {
    item=PropertiesFactory.eINSTANCE.createTDQReportItem();
  }
 else {
    item=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createTDQItem();
  }
  ItemState itemState=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
  itemState.setDeleted(false);
  item.setState(itemState);
  Resource eResource=element.eResource();
  if (eResource != null) {
    URI uri=eResource.getURI();
    if (item instanceof TDQItem) {
      ((TDQItem)item).setFilename(URI.decode(uri.lastSegment()));
    }
    if (uri.isPlatform()) {
      IPath elementPath=new Path(uri.toPlatformString(true)).removeLastSegments(1);
      IPath typedPath=ResourceManager.getRootProject().getFullPath().append(PropertyHelper.getItemTypedPath(item));
      IPath statePath=elementPath.makeRelativeTo(typedPath);
      itemState.setPath(statePath.toString());
    }
  }
  return item;
}