Program: 73736
Project: 73736
Buggy source:
/** 
 * Given a model name, return an Entity object.
 * @param name The model name.  An alphanumeric string without special characters. If no model with the given name is found, return null.
 * @param byReference Indication that the model should be included by reference.
 * @return An Entity object that the GUI can display.
 * @exception DBConnectionException Thrown by DBModelFetcher if a problem occurs with the database connection.
 * @exception DBExecutionException Thrown by DBModelFetcher if a problem while executing a  command.
 * @exception Exception Thrown if a problem occurs creating an effigy from the MoML.
 */
public static Entity importModel(String name,boolean byReference) throws DBConnectionException, DBExecutionException, Exception {
  XMLDBModel dbModel=DBModelFetcher.load(name);
  if (dbModel == null)   return null;
  Entity returnEntity=_getEntity(dbModel);
  if (byReference) {
    if (returnEntity.getAttribute("String_Node_Str") == null) {
      String referenceTag="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
      MoMLChangeRequest change=new MoMLChangeRequest(null,returnEntity,referenceTag);
      change.setUndoable(true);
      returnEntity.requestChange(change);
    }
 else {
      ((StringParameter)returnEntity.getAttribute("String_Node_Str")).setExpression("String_Node_Str");
    }
  }
 else {
    if (returnEntity.getAttribute("String_Node_Str") == null) {
      String referenceTag="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
      MoMLChangeRequest change=new MoMLChangeRequest(null,returnEntity,referenceTag);
      change.setUndoable(true);
      returnEntity.requestChange(change);
    }
 else {
      ((StringParameter)returnEntity.getAttribute("String_Node_Str")).setExpression("String_Node_Str");
    }
  }
  return returnEntity;
}

Fixed version (ground truth):
/** 
 * Given a model name, return an Entity object.
 * @param name The model name.  An alphanumeric string without special characters. If no model with the given name is found, return null.
 * @param byReference Indication that the model should be included by reference.
 * @param container The NamedObj that will contain this imported model. It is used here to obtain a unique name.
 * @return An Entity object that the GUI can display.
 * @exception DBConnectionException Thrown by DBModelFetcher if a problem occurs with the database connection.
 * @exception DBExecutionException Thrown by DBModelFetcher if a problem while executing a  command.
 * @exception Exception Thrown if a problem occurs creating an effigy from the MoML.
 */
public static Entity importModel(String name,boolean byReference,NamedObj container) throws DBConnectionException, DBExecutionException, Exception {
  XMLDBModel dbModel=DBModelFetcher.load(name);
  if (dbModel == null)   return null;
  Entity returnEntity=_getEntity(dbModel);
  if (byReference) {
    if (returnEntity.getAttribute("String_Node_Str") == null) {
      String referenceTag="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
      MoMLChangeRequest change=new MoMLChangeRequest(null,returnEntity,referenceTag);
      change.setUndoable(true);
      returnEntity.requestChange(change);
    }
 else {
      ((StringParameter)returnEntity.getAttribute("String_Node_Str")).setExpression("String_Node_Str");
    }
  }
 else {
    if (returnEntity.getAttribute("String_Node_Str") == null) {
      String referenceTag="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
      MoMLChangeRequest change=new MoMLChangeRequest(null,returnEntity,referenceTag);
      change.setUndoable(true);
      returnEntity.requestChange(change);
    }
 else {
      ((StringParameter)returnEntity.getAttribute("String_Node_Str")).setExpression("String_Node_Str");
    }
  }
  if (returnEntity.getAttribute("String_Node_Str") == null) {
    String dbNameTag="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + returnEntity.getName() + "String_Node_Str";
    MoMLChangeRequest change=new MoMLChangeRequest(null,returnEntity,dbNameTag);
    change.setUndoable(true);
    returnEntity.requestChange(change);
  }
 else {
    ((StringParameter)returnEntity.getAttribute("String_Node_Str")).setExpression(returnEntity.getName());
  }
  returnEntity.setName(container.uniqueName(returnEntity.getName()));
  return returnEntity;
}