Program: 73505
Project: 73505
Buggy source:
/** 
 * Returns the display label of this element. To get the display label of an element, the following step should be done: <ul> <li>The localized display name of this element if set</li> <li>The display property value of this element if set</li> <li>The name of element if set</li> <li>The localized display name of this kind of element, which is defined in metadata, if set</li> <li>The name of this kind of element, which is also defined in metadata </li> </ul> <p> User can also decide at which detail level the display label should be returned. The level could be one of the following 3 options: <ul> <li>USER_LABEL: Only the first 3 steps can be visited, if not found, return null</li> <li>SHORT_LABEL: All the above 5 steps can be visited. This will ensure there will be a return value</li> <li>FULL_LABEL: Besides the return value of SHORT_LABEL, this option says we need to return additional information. To get this, every child element needs to overwrite this method</li> </ul>
 * @param module the module
 * @param level the description level.
 * @return the display label of this element.
 */
public String getDisplayLabel(Module module,int level){
  String displayLabel=ModelUtil.searchForExternalizedValue(this,DISPLAY_NAME_ID_PROP,ThreadResources.getLocale());
  if (StringUtil.isBlank(displayLabel)) {
    displayLabel=getDisplayName();
  }
  if (StringUtil.isBlank(displayLabel)) {
    displayLabel=getNameForDisplayLabel();
  }
  if (level == USER_LABEL) {
    return displayLabel;
  }
  MetaDataDictionary dictionary=MetaDataDictionary.getInstance();
  IElementDefn elementDefn=dictionary.getElement(getElementName());
  if (StringUtil.isBlank(displayLabel)) {
    displayLabel=elementDefn.getDisplayName();
  }
  if (StringUtil.isBlank(displayLabel)) {
    displayLabel=elementDefn.getName();
  }
  return displayLabel;
}

Fixed version (ground truth):
/** 
 * Returns the display label of this element. To get the display label of an element, the following step should be done: <ul> <li>The localized display name of this element if set</li> <li>The display property value of this element if set</li> <li>The name of element if set</li> <li>The localized display name of this kind of element, which is defined in metadata, if set</li> <li>The name of this kind of element, which is also defined in metadata </li> </ul> <p> User can also decide at which detail level the display label should be returned. The level could be one of the following 3 options: <ul> <li>USER_LABEL: Only the first 3 steps can be visited, if not found, return null</li> <li>SHORT_LABEL: All the above 5 steps can be visited. This will ensure there will be a return value</li> <li>FULL_LABEL: Besides the return value of SHORT_LABEL, this option says we need to return additional information. To get this, every child element needs to overwrite this method</li> </ul>
 * @param module the module
 * @param level the description level.
 * @return the display label of this element.
 */
public String getDisplayLabel(Module module,int level){
  String displayLabel=ModelUtil.searchForExternalizedValue(this,DISPLAY_NAME_ID_PROP,ThreadResources.getLocale());
  if (StringUtil.isBlank(displayLabel)) {
    displayLabel=getDisplayName();
  }
  if (StringUtil.isBlank(displayLabel)) {
    displayLabel=getNameForDisplayLabel();
  }
  if (level == USER_LABEL) {
    return displayLabel;
  }
  if (!StringUtil.isBlank(displayLabel))   return displayLabel;
  return getDefnDisplayName(module);
}