Program: 12633
Project: 12633
Buggy source:
private static ComponentDefinition parseDnaComponentV1(SBOLDocument SBOLDoc,IdentifiableDocument<QName> componentDef){
  String displayId=null;
  String name=null;
  String description=null;
  URI seq_identity=null;
  Set<URI> roles=new HashSet<>();
  URI identity=componentDef.getIdentity();
  String persIdentity="String_Node_Str";
  List<Annotation> annotations=new ArrayList<>();
  List<SequenceAnnotation> sequenceAnnotations=new ArrayList<>();
  List<Component> components=new ArrayList<>();
  List<SequenceConstraint> sequenceConstraints=new ArrayList<>();
  List<SBOLPair> precedePairs=new ArrayList<>();
  Map<URI,URI> componentDefMap=new HashMap<>();
  Set<URI> type=new HashSet<>();
  type.add(ComponentDefinition.DNA);
  int component_num=0;
  int sa_num=0;
  if (URIPrefix != null) {
    displayId=findDisplayId(componentDef.getIdentity().toString());
    identity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,version,typesInURI);
    persIdentity=createCompliantURI(URIPrefix,TopLevel.SEQUENCE,displayId,"String_Node_Str",typesInURI).toString();
  }
  for (  NamedProperty<QName> namedProperty : componentDef.getProperties()) {
    if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.displayId)) {
      displayId=((Literal<QName>)namedProperty.getValue()).getValue().toString();
      displayId=fixDisplayId(displayId);
      if (URIPrefix != null) {
        persIdentity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,"String_Node_Str",typesInURI).toString();
        identity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,version,typesInURI);
      }
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.name)) {
      name=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.description)) {
      description=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.type)) {
      URI convertedSO=SequenceOntology.convertSeqOntologyV1(((Literal<QName>)namedProperty.getValue()).getValue().toString());
      roles.add(convertedSO);
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.annotations)) {
      SequenceAnnotation sa=parseSequenceAnnotationV1(SBOLDoc,((NestedDocument<QName>)namedProperty.getValue()),precedePairs,persIdentity,++sa_num);
      sequenceAnnotations.add(sa);
      URI component_identity=createCompliantURI(persIdentity,"String_Node_Str" + component_num,version);
      AccessType access=AccessType.PUBLIC;
      URI instantiatedComponent=sa.getComponentURI();
      URI originalURI=((NestedDocument<QName>)namedProperty.getValue()).getIdentity();
      componentDefMap.put(originalURI,component_identity);
      sa.setComponent(component_identity);
      Component component=new Component(component_identity,access,instantiatedComponent);
      if (!persIdentity.equals("String_Node_Str")) {
        component.setPersistentIdentity(createCompliantURI(persIdentity,"String_Node_Str" + component_num,"String_Node_Str"));
        component.setDisplayId("String_Node_Str" + component_num);
        component.setVersion(version);
      }
      component_num++;
      components.add(component);
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.dnaSequence)) {
      seq_identity=parseDnaSequenceV1(SBOLDoc,(NestedDocument<QName>)namedProperty.getValue()).getIdentity();
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  if (roles.isEmpty())   roles.add(SequenceOntology.ENGINEERED_REGION);
  int sc_number=0;
  for (  SBOLPair pair : precedePairs) {
    URI sc_identity=createCompliantURI(persIdentity,"String_Node_Str" + ++sc_number,version);
    URI restrictionURI=RestrictionType.convertToURI(RestrictionType.PRECEDES);
    URI subject=null;
    URI object=null;
    for (    URI key : componentDefMap.keySet()) {
      if (pair.getLeft().equals(key)) {
        subject=componentDefMap.get(key);
      }
 else       if (pair.getRight().equals(key)) {
        object=componentDefMap.get(key);
      }
    }
    SequenceConstraint sc=new SequenceConstraint(sc_identity,restrictionURI,subject,object);
    if (!persIdentity.equals("String_Node_Str")) {
      sc.setPersistentIdentity(createCompliantURI(persIdentity,"String_Node_Str" + sc_number,version));
      sc.setDisplayId("String_Node_Str" + sc_number);
      sc.setVersion(version);
    }
    sequenceConstraints.add(sc);
  }
  ComponentDefinition c=new ComponentDefinition(identity,type);
  if (!persIdentity.equals("String_Node_Str")) {
    c.setPersistentIdentity(URI.create(persIdentity));
    c.setVersion(version);
  }
  if (roles != null)   c.setRoles(roles);
  if (identity != componentDef.getIdentity())   c.setWasDerivedFrom(componentDef.getIdentity());
  if (displayId != null)   c.setDisplayId(displayId);
  if (name != null && !name.isEmpty())   c.setName(name);
  if (description != null && !description.isEmpty())   c.setDescription(description);
  if (seq_identity != null)   c.addSequence(seq_identity);
  if (!annotations.isEmpty())   c.setAnnotations(annotations);
  if (!sequenceAnnotations.isEmpty())   c.setSequenceAnnotations(sequenceAnnotations);
  if (!components.isEmpty())   c.setComponents(components);
  if (!sequenceConstraints.isEmpty())   c.setSequenceConstraints(sequenceConstraints);
  ComponentDefinition oldC=SBOLDoc.getComponentDefinition(identity);
  if (oldC == null) {
    SBOLDoc.addComponentDefinition(c);
  }
 else {
    if (!c.equals(oldC)) {
      throw new SBOLValidationException("String_Node_Str" + identity);
    }
  }
  return c;
}

Fixed version (ground truth):
private static ComponentDefinition parseDnaComponentV1(SBOLDocument SBOLDoc,IdentifiableDocument<QName> componentDef){
  String displayId=null;
  String name=null;
  String description=null;
  URI seq_identity=null;
  Set<URI> roles=new HashSet<>();
  URI identity=componentDef.getIdentity();
  String persIdentity="String_Node_Str";
  List<Annotation> annotations=new ArrayList<>();
  List<SequenceAnnotation> sequenceAnnotations=new ArrayList<>();
  List<Component> components=new ArrayList<>();
  List<SequenceConstraint> sequenceConstraints=new ArrayList<>();
  List<SBOLPair> precedePairs=new ArrayList<>();
  Map<URI,URI> componentDefMap=new HashMap<>();
  Set<URI> type=new HashSet<>();
  type.add(ComponentDefinition.DNA);
  int component_num=0;
  int sa_num=0;
  if (URIPrefix != null) {
    displayId=findDisplayId(componentDef.getIdentity().toString());
    identity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,version,typesInURI);
    persIdentity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,"String_Node_Str",typesInURI).toString();
  }
  for (  NamedProperty<QName> namedProperty : componentDef.getProperties()) {
    if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.displayId)) {
      displayId=((Literal<QName>)namedProperty.getValue()).getValue().toString();
      displayId=fixDisplayId(displayId);
      if (URIPrefix != null) {
        persIdentity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,"String_Node_Str",typesInURI).toString();
        identity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,version,typesInURI);
      }
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.name)) {
      name=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.description)) {
      description=((Literal<QName>)namedProperty.getValue()).getValue().toString();
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.type)) {
      URI convertedSO=SequenceOntology.convertSeqOntologyV1(((Literal<QName>)namedProperty.getValue()).getValue().toString());
      roles.add(convertedSO);
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.annotations)) {
      SequenceAnnotation sa=parseSequenceAnnotationV1(SBOLDoc,((NestedDocument<QName>)namedProperty.getValue()),precedePairs,persIdentity,++sa_num);
      sequenceAnnotations.add(sa);
      URI component_identity=createCompliantURI(persIdentity,"String_Node_Str" + component_num,version);
      AccessType access=AccessType.PUBLIC;
      URI instantiatedComponent=sa.getComponentURI();
      URI originalURI=((NestedDocument<QName>)namedProperty.getValue()).getIdentity();
      componentDefMap.put(originalURI,component_identity);
      sa.setComponent(component_identity);
      Component component=new Component(component_identity,access,instantiatedComponent);
      if (!persIdentity.equals("String_Node_Str")) {
        component.setPersistentIdentity(createCompliantURI(persIdentity,"String_Node_Str" + component_num,"String_Node_Str"));
        component.setDisplayId("String_Node_Str" + component_num);
        component.setVersion(version);
      }
      component_num++;
      components.add(component);
    }
 else     if (namedProperty.getName().equals(Sbol1Terms.DNAComponent.dnaSequence)) {
      seq_identity=parseDnaSequenceV1(SBOLDoc,(NestedDocument<QName>)namedProperty.getValue()).getIdentity();
    }
 else {
      annotations.add(new Annotation(namedProperty));
    }
  }
  if (roles.isEmpty())   roles.add(SequenceOntology.ENGINEERED_REGION);
  int sc_number=0;
  for (  SBOLPair pair : precedePairs) {
    URI sc_identity=createCompliantURI(persIdentity,"String_Node_Str" + ++sc_number,version);
    URI restrictionURI=RestrictionType.convertToURI(RestrictionType.PRECEDES);
    URI subject=null;
    URI object=null;
    for (    URI key : componentDefMap.keySet()) {
      if (pair.getLeft().equals(key)) {
        subject=componentDefMap.get(key);
      }
 else       if (pair.getRight().equals(key)) {
        object=componentDefMap.get(key);
      }
    }
    SequenceConstraint sc=new SequenceConstraint(sc_identity,restrictionURI,subject,object);
    if (!persIdentity.equals("String_Node_Str")) {
      sc.setPersistentIdentity(createCompliantURI(persIdentity,"String_Node_Str" + sc_number,version));
      sc.setDisplayId("String_Node_Str" + sc_number);
      sc.setVersion(version);
    }
    sequenceConstraints.add(sc);
  }
  ComponentDefinition c=new ComponentDefinition(identity,type);
  if (!persIdentity.equals("String_Node_Str")) {
    c.setPersistentIdentity(URI.create(persIdentity));
    c.setVersion(version);
  }
  if (roles != null)   c.setRoles(roles);
  if (identity != componentDef.getIdentity())   c.setWasDerivedFrom(componentDef.getIdentity());
  if (displayId != null)   c.setDisplayId(displayId);
  if (name != null && !name.isEmpty())   c.setName(name);
  if (description != null && !description.isEmpty())   c.setDescription(description);
  if (seq_identity != null)   c.addSequence(seq_identity);
  if (!annotations.isEmpty())   c.setAnnotations(annotations);
  if (!sequenceAnnotations.isEmpty())   c.setSequenceAnnotations(sequenceAnnotations);
  if (!components.isEmpty())   c.setComponents(components);
  if (!sequenceConstraints.isEmpty())   c.setSequenceConstraints(sequenceConstraints);
  ComponentDefinition oldC=SBOLDoc.getComponentDefinition(identity);
  if (oldC == null) {
    SBOLDoc.addComponentDefinition(c);
  }
 else   if (c.isSetWasDerivedFrom() && oldC.isSetWasDerivedFrom() && !c.getWasDerivedFrom().equals(oldC.getWasDerivedFrom())) {
    do {
      displayId=displayId + "String_Node_Str";
      identity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,version,typesInURI);
      persIdentity=createCompliantURI(URIPrefix,TopLevel.COMPONENT_DEFINITION,displayId,"String_Node_Str",typesInURI).toString();
    }
 while (SBOLDoc.getComponentDefinition(identity) != null);
    c=c.copy(URIPrefix,displayId,version);
    if (identity != componentDef.getIdentity())     c.setWasDerivedFrom(componentDef.getIdentity());
    SBOLDoc.addComponentDefinition(c);
  }
 else   if (dropObjectsWithDuplicateURIs) {
    return oldC;
  }
 else {
    if (!c.equals(oldC)) {
      throw new SBOLValidationException("String_Node_Str" + identity);
    }
  }
  return c;
}