Program: 17836
Project: 17836
Buggy source:
@Override public void build() throws ODataJPAModelException, ODataJPARuntimeException {
  JPAEdmBuilder keyViewBuilder=null;
  properties=new ArrayList<Property>();
  List<Attribute<?,?>> jpaAttributes=null;
  String currentEntityName=null;
  String targetEntityName=null;
  String entityTypeName=null;
  if (isBuildModeComplexType) {
    jpaAttributes=sortInAscendingOrder(complexTypeView.getJPAEmbeddableType().getAttributes());
    entityTypeName=complexTypeView.getJPAEmbeddableType().getJavaType().getSimpleName();
  }
 else {
    jpaAttributes=sortInAscendingOrder(entityTypeView.getJPAEntityType().getAttributes());
    entityTypeName=entityTypeView.getJPAEntityType().getName();
  }
  for (  Object jpaAttribute : jpaAttributes) {
    currentAttribute=(Attribute<?,?>)jpaAttribute;
    if (isExcluded((JPAEdmPropertyView)JPAEdmProperty.this,entityTypeName,currentAttribute.getName())) {
      continue;
    }
    PersistentAttributeType attributeType=currentAttribute.getPersistentAttributeType();
switch (attributeType) {
case BASIC:
      currentSimpleProperty=new SimpleProperty();
    JPAEdmNameBuilder.build((JPAEdmPropertyView)JPAEdmProperty.this,isBuildModeComplexType);
  EdmSimpleTypeKind simpleTypeKind=JPATypeConvertor.convertToEdmSimpleType(currentAttribute.getJavaType(),currentAttribute);
currentSimpleProperty.setType(simpleTypeKind);
currentSimpleProperty.setFacets(setFacets(currentAttribute));
properties.add(currentSimpleProperty);
if (((SingularAttribute<?,?>)currentAttribute).isId()) {
if (keyView == null) {
keyView=new JPAEdmKey(JPAEdmProperty.this);
keyViewBuilder=keyView.getBuilder();
}
keyViewBuilder.build();
}
break;
case EMBEDDED:
ComplexType complexType=complexTypeView.searchEdmComplexType(currentAttribute.getJavaType().getName());
if (complexType == null) {
JPAEdmComplexTypeView complexTypeViewLocal=new JPAEdmComplexType(schemaView,currentAttribute);
complexTypeViewLocal.getBuilder().build();
complexType=complexTypeViewLocal.getEdmComplexType();
complexTypeView.addJPAEdmCompleTypeView(complexTypeViewLocal);
}
if (isBuildModeComplexType == false && entityTypeView.getJPAEntityType().getIdType().getJavaType().equals(currentAttribute.getJavaType())) {
if (keyView == null) {
keyView=new JPAEdmKey(complexTypeView,JPAEdmProperty.this);
}
keyView.getBuilder().build();
complexTypeView.expandEdmComplexType(complexType,properties,currentAttribute.getName());
}
 else {
currentComplexProperty=new ComplexProperty();
if (isBuildModeComplexType) {
JPAEdmNameBuilder.build((JPAEdmComplexPropertyView)JPAEdmProperty.this,complexTypeView.getJPAEmbeddableType().getJavaType().getSimpleName());
}
 else {
JPAEdmNameBuilder.build((JPAEdmComplexPropertyView)JPAEdmProperty.this,JPAEdmProperty.this);
}
currentComplexProperty.setType(new FullQualifiedName(schemaView.getEdmSchema().getNamespace(),complexType.getName()));
properties.add(currentComplexProperty);
List<String> nonKeyComplexTypes=schemaView.getNonKeyComplexTypeList();
if (!nonKeyComplexTypes.contains(currentComplexProperty.getType().getName())) {
schemaView.addNonKeyComplexName(currentComplexProperty.getType().getName());
}
}
break;
case MANY_TO_MANY:
case ONE_TO_MANY:
case ONE_TO_ONE:
case MANY_TO_ONE:
JPAEdmAssociationEndView associationEndView=new JPAEdmAssociationEnd(entityTypeView,JPAEdmProperty.this);
associationEndView.getBuilder().build();
JPAEdmAssociationView associationView=schemaView.getJPAEdmAssociationView();
if (associationView.searchAssociation(associationEndView) == null) {
int count=associationView.getNumberOfAssociationsWithSimilarEndPoints(associationEndView);
JPAEdmAssociationView associationViewLocal=new JPAEdmAssociation(associationEndView,entityTypeView,JPAEdmProperty.this,count);
associationViewLocal.getBuilder().build();
associationView.addJPAEdmAssociationView(associationViewLocal,associationEndView);
}
JPAEdmReferentialConstraintView refConstraintView=new JPAEdmReferentialConstraint(associationView,entityTypeView,JPAEdmProperty.this);
refConstraintView.getBuilder().build();
if (refConstraintView.isExists()) {
associationView.addJPAEdmRefConstraintView(refConstraintView);
}
if (navigationPropertyView == null) {
navigationPropertyView=new JPAEdmNavigationProperty(schemaView);
}
currentEntityName=entityTypeView.getJPAEntityType().getName();
targetEntityName=currentAttribute.getJavaType().getSimpleName();
Integer sequenceNumber=associationCount.get(currentEntityName + targetEntityName);
if (sequenceNumber == null) {
sequenceNumber=new Integer(1);
}
 else {
sequenceNumber=new Integer(sequenceNumber.intValue() + 1);
}
associationCount.put(currentEntityName + targetEntityName,sequenceNumber);
JPAEdmNavigationPropertyView localNavigationPropertyView=new JPAEdmNavigationProperty(associationView,JPAEdmProperty.this,sequenceNumber.intValue());
localNavigationPropertyView.getBuilder().build();
navigationPropertyView.addJPAEdmNavigationPropertyView(localNavigationPropertyView);
break;
default :
break;
}
}
}

Fixed version (ground truth):
@Override public void build() throws ODataJPAModelException, ODataJPARuntimeException {
  JPAEdmBuilder keyViewBuilder=null;
  properties=new ArrayList<Property>();
  List<Attribute<?,?>> jpaAttributes=null;
  String currentEntityName=null;
  String targetEntityName=null;
  String entityTypeName=null;
  if (isBuildModeComplexType) {
    jpaAttributes=sortInAscendingOrder(complexTypeView.getJPAEmbeddableType().getAttributes());
    entityTypeName=complexTypeView.getJPAEmbeddableType().getJavaType().getSimpleName();
  }
 else {
    jpaAttributes=sortInAscendingOrder(entityTypeView.getJPAEntityType().getAttributes());
    entityTypeName=entityTypeView.getJPAEntityType().getName();
  }
  for (  Object jpaAttribute : jpaAttributes) {
    currentAttribute=(Attribute<?,?>)jpaAttribute;
    if (isExcluded((JPAEdmPropertyView)JPAEdmProperty.this,entityTypeName,currentAttribute.getName())) {
      continue;
    }
    PersistentAttributeType attributeType=currentAttribute.getPersistentAttributeType();
switch (attributeType) {
case BASIC:
      currentSimpleProperty=new SimpleProperty();
    JPAEdmNameBuilder.build((JPAEdmPropertyView)JPAEdmProperty.this,isBuildModeComplexType);
  EdmSimpleTypeKind simpleTypeKind=JPATypeConvertor.convertToEdmSimpleType(currentAttribute.getJavaType(),currentAttribute);
currentSimpleProperty.setType(simpleTypeKind);
JPAEdmFacets.setFacets(currentAttribute,currentSimpleProperty);
properties.add(currentSimpleProperty);
if (((SingularAttribute<?,?>)currentAttribute).isId()) {
if (keyView == null) {
keyView=new JPAEdmKey(JPAEdmProperty.this);
keyViewBuilder=keyView.getBuilder();
}
keyViewBuilder.build();
}
break;
case EMBEDDED:
ComplexType complexType=complexTypeView.searchEdmComplexType(currentAttribute.getJavaType().getName());
if (complexType == null) {
JPAEdmComplexTypeView complexTypeViewLocal=new JPAEdmComplexType(schemaView,currentAttribute);
complexTypeViewLocal.getBuilder().build();
complexType=complexTypeViewLocal.getEdmComplexType();
complexTypeView.addJPAEdmCompleTypeView(complexTypeViewLocal);
}
if (isBuildModeComplexType == false && entityTypeView.getJPAEntityType().getIdType().getJavaType().equals(currentAttribute.getJavaType())) {
if (keyView == null) {
keyView=new JPAEdmKey(complexTypeView,JPAEdmProperty.this);
}
keyView.getBuilder().build();
complexTypeView.expandEdmComplexType(complexType,properties,currentAttribute.getName());
}
 else {
currentComplexProperty=new ComplexProperty();
if (isBuildModeComplexType) {
JPAEdmNameBuilder.build((JPAEdmComplexPropertyView)JPAEdmProperty.this,complexTypeView.getJPAEmbeddableType().getJavaType().getSimpleName());
}
 else {
JPAEdmNameBuilder.build((JPAEdmComplexPropertyView)JPAEdmProperty.this,JPAEdmProperty.this);
}
currentComplexProperty.setType(new FullQualifiedName(schemaView.getEdmSchema().getNamespace(),complexType.getName()));
properties.add(currentComplexProperty);
List<String> nonKeyComplexTypes=schemaView.getNonKeyComplexTypeList();
if (!nonKeyComplexTypes.contains(currentComplexProperty.getType().getName())) {
schemaView.addNonKeyComplexName(currentComplexProperty.getType().getName());
}
}
break;
case MANY_TO_MANY:
case ONE_TO_MANY:
case ONE_TO_ONE:
case MANY_TO_ONE:
JPAEdmAssociationEndView associationEndView=new JPAEdmAssociationEnd(entityTypeView,JPAEdmProperty.this);
associationEndView.getBuilder().build();
JPAEdmAssociationView associationView=schemaView.getJPAEdmAssociationView();
if (associationView.searchAssociation(associationEndView) == null) {
int count=associationView.getNumberOfAssociationsWithSimilarEndPoints(associationEndView);
JPAEdmAssociationView associationViewLocal=new JPAEdmAssociation(associationEndView,entityTypeView,JPAEdmProperty.this,count);
associationViewLocal.getBuilder().build();
associationView.addJPAEdmAssociationView(associationViewLocal,associationEndView);
}
JPAEdmReferentialConstraintView refConstraintView=new JPAEdmReferentialConstraint(associationView,entityTypeView,JPAEdmProperty.this);
refConstraintView.getBuilder().build();
if (refConstraintView.isExists()) {
associationView.addJPAEdmRefConstraintView(refConstraintView);
}
if (navigationPropertyView == null) {
navigationPropertyView=new JPAEdmNavigationProperty(schemaView);
}
currentEntityName=entityTypeView.getJPAEntityType().getName();
targetEntityName=currentAttribute.getJavaType().getSimpleName();
Integer sequenceNumber=associationCount.get(currentEntityName + targetEntityName);
if (sequenceNumber == null) {
sequenceNumber=new Integer(1);
}
 else {
sequenceNumber=new Integer(sequenceNumber.intValue() + 1);
}
associationCount.put(currentEntityName + targetEntityName,sequenceNumber);
JPAEdmNavigationPropertyView localNavigationPropertyView=new JPAEdmNavigationProperty(associationView,JPAEdmProperty.this,sequenceNumber.intValue());
localNavigationPropertyView.getBuilder().build();
navigationPropertyView.addJPAEdmNavigationPropertyView(localNavigationPropertyView);
break;
default :
break;
}
}
}