Program: 35359
Project: 35359
Buggy source:
public static ValueLabel getDefElementPair(final ValueResult valueResult,final FlexibleElement element,final Contact contact,final EntityManager entityManager,final I18nServer i18nTranslator,final Language language){
  Object value=null;
  String label=ExporterUtil.getFlexibleElementLabel(element,i18nTranslator,language);
  final DefaultContactFlexibleElement defaultElement=(DefaultContactFlexibleElement)element;
  boolean hasValue=valueResult != null && valueResult.isValueDefined();
switch (defaultElement.getType()) {
case FAMILY_NAME:
{
      if (hasValue) {
        value=valueResult.getValueObject();
      }
 else {
        value=contact.getName();
      }
    }
  break;
case FIRST_NAME:
{
  if (hasValue) {
    value=valueResult.getValueObject();
  }
 else {
    value=contact.getFirstname();
  }
}
break;
case ORGANIZATION_NAME:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getOrganization() != null ? contact.getOrganization().getName() : null;
}
}
break;
case MAIN_ORG_UNIT:
{
int orgUnitId=-1;
if (hasValue) {
orgUnitId=Integer.parseInt(valueResult.getValueObject());
}
 else {
orgUnitId=contact.getMainOrgUnit().getId();
}
OrgUnit orgUnit=entityManager.find(OrgUnit.class,orgUnitId);
if (orgUnit != null) {
value=orgUnit.getName() + "String_Node_Str" + orgUnit.getFullName();
}
}
break;
case SECONDARY_ORG_UNITS:
{
List<OrgUnit> orgUnits=new ArrayList<>();
if (hasValue) {
List<Integer> orgUnitsIds=ValueResultUtils.splitValuesAsInteger(valueResult.getValueObject());
for (Integer id : orgUnitsIds) {
OrgUnit unit=entityManager.find(OrgUnit.class,id);
if (unit != null) orgUnits.add(unit);
}
}
 else {
orgUnits=contact.getSecondaryOrgUnits();
}
String val="String_Node_Str";
for (OrgUnit unit : orgUnits) {
val+=unit.getName() + "String_Node_Str" + unit.getFullName()+ "String_Node_Str";
}
if (!val.isEmpty()) {
value=val.substring(0,val.length() - 1);
}
}
break;
case CREATION_DATE:
{
if (hasValue) {
value=new Date(Long.parseLong(valueResult.getValueObject()));
}
 else {
value=contact.getDateCreated();
}
}
break;
case LOGIN:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getLogin();
}
}
break;
case EMAIL_ADDRESS:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getEmail();
}
}
break;
case PHONE_NUMBER:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getPhoneNumber();
}
}
break;
case POSTAL_ADDRESS:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getPostalAddress();
}
}
break;
case PHOTO:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getPhoto();
}
}
break;
case COUNTRY:
{
if (hasValue) {
int countryId=Integer.parseInt(valueResult.getValueObject());
value=entityManager.find(Country.class,countryId).getName();
}
 else {
value=contact.getCountry() != null ? contact.getCountry().getName() : null;
}
}
break;
case DIRECT_MEMBERSHIP:
{
int orgUnitId=-1;
if (hasValue) {
orgUnitId=Integer.parseInt(valueResult.getValueObject());
}
 else {
if (contact.getParent() != null) {
orgUnitId=contact.getParent().getId();
}
}
OrgUnit orgUnit=entityManager.find(OrgUnit.class,orgUnitId);
if (orgUnit != null) {
value=orgUnit.getName() + "String_Node_Str" + orgUnit.getFullName();
}
}
break;
case TOP_MEMBERSHIP:
{
int orgUnitId=-1;
if (hasValue) {
orgUnitId=Integer.parseInt(valueResult.getValueObject());
}
 else {
if (contact.getRoot() != null) {
orgUnitId=contact.getRoot().getId();
}
}
OrgUnit orgUnit=entityManager.find(OrgUnit.class,orgUnitId);
if (orgUnit != null) {
value=orgUnit.getName() + "String_Node_Str" + orgUnit.getFullName();
}
}
break;
default :
break;
}
return new ValueLabel(label,value);
}

Fixed version (ground truth):
public static ValueLabel getDefElementPair(final ValueResult valueResult,final FlexibleElement element,final Contact contact,final EntityManager entityManager,final I18nServer i18nTranslator,final Language language){
  Object value=null;
  String label=ExporterUtil.getFlexibleElementLabel(element,i18nTranslator,language);
  final DefaultContactFlexibleElement defaultElement=(DefaultContactFlexibleElement)element;
  boolean hasValue=valueResult != null && valueResult.isValueDefined();
switch (defaultElement.getType()) {
case FAMILY_NAME:
{
      if (hasValue) {
        value=valueResult.getValueObject();
      }
 else {
        value=contact.getName();
      }
    }
  break;
case FIRST_NAME:
{
  if (hasValue) {
    value=valueResult.getValueObject();
  }
 else {
    value=contact.getFirstname();
  }
}
break;
case ORGANIZATION_NAME:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getName();
}
}
break;
case MAIN_ORG_UNIT:
{
int orgUnitId=-1;
if (hasValue) {
orgUnitId=Integer.parseInt(valueResult.getValueObject());
}
 else {
orgUnitId=contact.getMainOrgUnit().getId();
}
OrgUnit orgUnit=entityManager.find(OrgUnit.class,orgUnitId);
if (orgUnit != null) {
value=orgUnit.getName() + "String_Node_Str" + orgUnit.getFullName();
}
}
break;
case SECONDARY_ORG_UNITS:
{
List<OrgUnit> orgUnits=new ArrayList<>();
if (hasValue) {
List<Integer> orgUnitsIds=ValueResultUtils.splitValuesAsInteger(valueResult.getValueObject());
for (Integer id : orgUnitsIds) {
OrgUnit unit=entityManager.find(OrgUnit.class,id);
if (unit != null) orgUnits.add(unit);
}
}
 else {
orgUnits=contact.getSecondaryOrgUnits();
}
String val="String_Node_Str";
for (OrgUnit unit : orgUnits) {
val+=unit.getName() + "String_Node_Str" + unit.getFullName()+ "String_Node_Str";
}
if (!val.isEmpty()) {
value=val.substring(0,val.length() - 1);
}
}
break;
case CREATION_DATE:
{
if (hasValue) {
value=new Date(Long.parseLong(valueResult.getValueObject()));
}
 else {
value=contact.getDateCreated();
}
}
break;
case LOGIN:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getLogin();
}
}
break;
case EMAIL_ADDRESS:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getEmail();
}
}
break;
case PHONE_NUMBER:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getPhoneNumber();
}
}
break;
case POSTAL_ADDRESS:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getPostalAddress();
}
}
break;
case PHOTO:
{
if (hasValue) {
value=valueResult.getValueObject();
}
 else {
value=contact.getPhoto();
}
}
break;
case COUNTRY:
{
if (hasValue) {
int countryId=Integer.parseInt(valueResult.getValueObject());
value=entityManager.find(Country.class,countryId).getName();
}
 else {
value=contact.getCountry() != null ? contact.getCountry().getName() : null;
}
}
break;
case DIRECT_MEMBERSHIP:
{
int orgUnitId=-1;
if (hasValue) {
orgUnitId=Integer.parseInt(valueResult.getValueObject());
}
 else {
if (contact.getParent() != null) {
orgUnitId=contact.getParent().getId();
}
}
OrgUnit orgUnit=entityManager.find(OrgUnit.class,orgUnitId);
if (orgUnit != null) {
value=orgUnit.getName() + "String_Node_Str" + orgUnit.getFullName();
}
}
break;
case TOP_MEMBERSHIP:
{
int orgUnitId=-1;
if (hasValue) {
orgUnitId=Integer.parseInt(valueResult.getValueObject());
}
 else {
if (contact.getRoot() != null) {
orgUnitId=contact.getRoot().getId();
}
}
OrgUnit orgUnit=entityManager.find(OrgUnit.class,orgUnitId);
if (orgUnit != null) {
value=orgUnit.getName() + "String_Node_Str" + orgUnit.getFullName();
}
}
break;
default :
break;
}
return new ValueLabel(label,value);
}