Program: 84503
Project: 84503
Buggy source:
/** 
 * This method takes all the form data from the input boxes and puts it onto the concept object so that it can be saved to the database
 * @return the concept to be saved to the database
 */
public Concept getConceptFromFormData(){
  for (  Locale locale : locales) {
    ConceptName fullySpecifiedNameInLocale=namesByLocale.get(locale);
    if (StringUtils.hasText(fullySpecifiedNameInLocale.getName())) {
      concept.setFullySpecifiedName(fullySpecifiedNameInLocale);
      if (fullySpecifiedNameInLocale.getName().equalsIgnoreCase(preferredNamesByLocale.get(locale))) {
        concept.setPreferredName(fullySpecifiedNameInLocale);
      }
    }
    ConceptName shortNameInLocale=shortNamesByLocale.get(locale);
    if (StringUtils.hasText(shortNameInLocale.getName())) {
      concept.setShortName(shortNameInLocale);
    }
    for (    ConceptName synonym : synonymsByLocale.get(locale)) {
      if (synonym != null && StringUtils.hasText(synonym.getName())) {
        synonym.setLocale(locale);
        if (synonym.getName().equalsIgnoreCase(preferredNamesByLocale.get(locale))) {
          concept.setPreferredName(synonym);
        }
 else         if (!concept.getNames().contains(synonym) && !concept.hasName(synonym.getName(),locale)) {
          concept.addName(synonym);
        }
        if (!synonym.isVoided())         synonym.setVoidReason(null);
 else         if (synonym.isVoided() && !StringUtils.hasText(synonym.getVoidReason()))         synonym.setVoidReason(Context.getMessageSourceService().getMessage("String_Node_Str"));
      }
    }
    for (    ConceptName indexTerm : indexTermsByLocale.get(locale)) {
      if (indexTerm != null && StringUtils.hasText(indexTerm.getName())) {
        if (!concept.getNames().contains(indexTerm) && !concept.hasName(indexTerm.getName(),locale)) {
          indexTerm.setConceptNameType(ConceptNameType.INDEX_TERM);
          indexTerm.setLocale(locale);
          concept.addName(indexTerm);
        }
        if (!indexTerm.isVoided())         indexTerm.setVoidReason(null);
 else         if (indexTerm.isVoided() && !StringUtils.hasText(indexTerm.getVoidReason()))         indexTerm.setVoidReason(Context.getMessageSourceService().getMessage("String_Node_Str"));
      }
    }
    ConceptDescription descInLocale=descriptionsByLocale.get(locale);
    if (StringUtils.hasLength(descInLocale.getDescription()) && !concept.getDescriptions().contains(descInLocale)) {
      concept.addDescription(descInLocale);
    }
  }
  for (  ConceptMap map : mappings) {
    if (map != null) {
      if (map.getSourceCode() == null) {
        concept.removeConceptMapping(map);
      }
 else       if (!concept.getConceptMappings().contains(map)) {
        concept.addConceptMapping(map);
      }
    }
  }
  if (!concept.isSet()) {
    if (concept.getConceptSets() != null) {
      concept.getConceptSets().clear();
    }
  }
  if (!concept.getDatatype().isCoded()) {
    if (concept.getAnswers(true) != null) {
      concept.getAnswers(true).clear();
    }
  }
  if (concept.getDatatype().getName().equals("String_Node_Str")) {
    ConceptNumeric cn;
    if (concept instanceof ConceptNumeric)     cn=(ConceptNumeric)concept;
 else {
      cn=new ConceptNumeric(concept);
    }
    cn.setHiAbsolute(hiAbsolute);
    cn.setLowAbsolute(lowAbsolute);
    cn.setHiCritical(hiCritical);
    cn.setLowCritical(lowCritical);
    cn.setHiNormal(hiNormal);
    cn.setLowNormal(lowNormal);
    cn.setPrecise(precise);
    cn.setUnits(units);
    concept=cn;
  }
 else   if (concept.getDatatype().getName().equals("String_Node_Str")) {
    ConceptComplex complexConcept;
    if (concept instanceof ConceptComplex)     complexConcept=(ConceptComplex)concept;
 else {
      complexConcept=new ConceptComplex(concept);
    }
    complexConcept.setHandler(handlerKey);
    concept=complexConcept;
  }
  return concept;
}

Fixed version (ground truth):
/** 
 * This method takes all the form data from the input boxes and puts it onto the concept object so that it can be saved to the database
 * @return the concept to be saved to the database
 */
public Concept getConceptFromFormData(){
  for (  Locale locale : locales) {
    ConceptName fullySpecifiedNameInLocale=namesByLocale.get(locale);
    if (StringUtils.hasText(fullySpecifiedNameInLocale.getName())) {
      concept.setFullySpecifiedName(fullySpecifiedNameInLocale);
      if (fullySpecifiedNameInLocale.getName().equalsIgnoreCase(preferredNamesByLocale.get(locale))) {
        concept.setPreferredName(fullySpecifiedNameInLocale);
      }
    }
    ConceptName shortNameInLocale=shortNamesByLocale.get(locale);
    if (StringUtils.hasText(shortNameInLocale.getName())) {
      concept.setShortName(shortNameInLocale);
    }
    for (    ConceptName synonym : synonymsByLocale.get(locale)) {
      if (synonym != null && StringUtils.hasText(synonym.getName())) {
        synonym.setLocale(locale);
        if (synonym.getName().equalsIgnoreCase(preferredNamesByLocale.get(locale)) && !synonym.isVoided()) {
          concept.setPreferredName(synonym);
        }
 else         if (!concept.getNames().contains(synonym) && !concept.hasName(synonym.getName(),locale)) {
          concept.addName(synonym);
        }
        if (!synonym.isVoided())         synonym.setVoidReason(null);
 else         if (synonym.isVoided() && !StringUtils.hasText(synonym.getVoidReason()))         synonym.setVoidReason(Context.getMessageSourceService().getMessage("String_Node_Str"));
      }
    }
    for (    ConceptName indexTerm : indexTermsByLocale.get(locale)) {
      if (indexTerm != null && StringUtils.hasText(indexTerm.getName())) {
        if (!concept.getNames().contains(indexTerm) && !concept.hasName(indexTerm.getName(),locale)) {
          indexTerm.setConceptNameType(ConceptNameType.INDEX_TERM);
          indexTerm.setLocale(locale);
          concept.addName(indexTerm);
        }
        if (!indexTerm.isVoided())         indexTerm.setVoidReason(null);
 else         if (indexTerm.isVoided() && !StringUtils.hasText(indexTerm.getVoidReason()))         indexTerm.setVoidReason(Context.getMessageSourceService().getMessage("String_Node_Str"));
      }
    }
    ConceptDescription descInLocale=descriptionsByLocale.get(locale);
    if (StringUtils.hasLength(descInLocale.getDescription()) && !concept.getDescriptions().contains(descInLocale)) {
      concept.addDescription(descInLocale);
    }
  }
  for (  ConceptMap map : mappings) {
    if (map != null) {
      if (map.getSourceCode() == null) {
        concept.removeConceptMapping(map);
      }
 else       if (!concept.getConceptMappings().contains(map)) {
        concept.addConceptMapping(map);
      }
    }
  }
  if (!concept.isSet()) {
    if (concept.getConceptSets() != null) {
      concept.getConceptSets().clear();
    }
  }
  if (!concept.getDatatype().isCoded()) {
    if (concept.getAnswers(true) != null) {
      concept.getAnswers(true).clear();
    }
  }
  if (concept.getDatatype().getName().equals("String_Node_Str")) {
    ConceptNumeric cn;
    if (concept instanceof ConceptNumeric)     cn=(ConceptNumeric)concept;
 else {
      cn=new ConceptNumeric(concept);
    }
    cn.setHiAbsolute(hiAbsolute);
    cn.setLowAbsolute(lowAbsolute);
    cn.setHiCritical(hiCritical);
    cn.setLowCritical(lowCritical);
    cn.setHiNormal(hiNormal);
    cn.setLowNormal(lowNormal);
    cn.setPrecise(precise);
    cn.setUnits(units);
    concept=cn;
  }
 else   if (concept.getDatatype().getName().equals("String_Node_Str")) {
    ConceptComplex complexConcept;
    if (concept instanceof ConceptComplex)     complexConcept=(ConceptComplex)concept;
 else {
      complexConcept=new ConceptComplex(concept);
    }
    complexConcept.setHandler(handlerKey);
    concept=complexConcept;
  }
  return concept;
}