nus-yam/ex-repair huggingface dataset:
Program: 84524
Project: 84524
Buggy source:
/** 
 * Called by   {@link #doFilter(ServletRequest,ServletResponse,FilterChain)} on GET requests
 * @param httpRequest
 * @param httpResponse
 */
protected void doGet(HttpServletRequest httpRequest,HttpServletResponse httpResponse) throws IOException, ServletException {
  Writer writer=httpResponse.getWriter();
  Map<String,Object> referenceMap=new HashMap<String,Object>();
  File runtimeProperties=getRuntimePropertiesFile();
  if (!runtimeProperties.exists()) {
    try {
      runtimeProperties.createNewFile();
    }
 catch (    IOException io) {
      wizardModel.canCreate=false;
      wizardModel.cannotCreateErrorMessage=io.getMessage();
    }
    wizardModel.canWrite=runtimeProperties.canWrite();
    runtimeProperties.delete();
  }
 else {
    wizardModel.canWrite=runtimeProperties.canWrite();
  }
  wizardModel.runtimePropertiesPath=runtimeProperties.getAbsolutePath();
  renderTemplate(DEFAULT_PAGE,referenceMap,writer);
}

Fixed version (ground truth):
/** 
 * Called by   {@link #doFilter(ServletRequest,ServletResponse,FilterChain)} on GET requests
 * @param httpRequest
 * @param httpResponse
 */
protected void doGet(HttpServletRequest httpRequest,HttpServletResponse httpResponse) throws IOException, ServletException {
  Writer writer=httpResponse.getWriter();
  Map<String,Object> referenceMap=new HashMap<String,Object>();
  File runtimeProperties=getRuntimePropertiesFile();
  if (!runtimeProperties.exists()) {
    try {
      runtimeProperties.createNewFile();
      wizardModel.canCreate=true;
      wizardModel.cannotCreateErrorMessage="String_Node_Str";
    }
 catch (    IOException io) {
      wizardModel.canCreate=false;
      wizardModel.cannotCreateErrorMessage=io.getMessage();
    }
    wizardModel.canWrite=runtimeProperties.canWrite();
    runtimeProperties.delete();
  }
 else {
    wizardModel.canWrite=runtimeProperties.canWrite();
  }
  wizardModel.runtimePropertiesPath=runtimeProperties.getAbsolutePath();
  renderTemplate(DEFAULT_PAGE,referenceMap,writer);
}
Program: 84526
Project: 84526
Buggy source:
/** 
 * Private method for converting a serialized object to a deserialized object of the given type
 * @param clazz the class to deserialize into
 * @param serializedObject the serialized object to convert
 * @return the deserialized Object
 */
@SuppressWarnings("String_Node_Str") private <T extends OpenmrsObject>T convertSerializedObject(Class<T> clazz,SerializedObject serializedObject) throws DAOException {
  if (serializedObject == null) {
    return null;
  }
  OpenmrsSerializer serializer=getSerializer(serializedObject,null);
  T obj=null;
  try {
    obj=(T)serializer.deserialize(serializedObject.getSerializedData(),serializedObject.getSubtype());
  }
 catch (  SerializationException e) {
  }
  if (obj == null) {
    throw new DAOException("String_Node_Str" + serializedObject);
  }
  obj.setId(serializedObject.getId());
  obj.setUuid(serializedObject.getUuid());
  return obj;
}

Fixed version (ground truth):
/** 
 * Private method for converting a serialized object to a deserialized object of the given type
 * @param clazz the class to deserialize into
 * @param serializedObject the serialized object to convert
 * @return the deserialized Object
 */
@SuppressWarnings("String_Node_Str") private <T extends OpenmrsObject>T convertSerializedObject(Class<T> clazz,SerializedObject serializedObject) throws DAOException {
  if (serializedObject == null) {
    return null;
  }
  OpenmrsSerializer serializer=getSerializer(serializedObject);
  T obj=null;
  try {
    obj=(T)serializer.deserialize(serializedObject.getSerializedData(),serializedObject.getSubtype());
  }
 catch (  SerializationException e) {
  }
  if (obj == null) {
    throw new DAOException("String_Node_Str" + serializedObject);
  }
  obj.setId(serializedObject.getId());
  obj.setUuid(serializedObject.getUuid());
  return obj;
}
Program: 84528
Project: 84528
Buggy source:
/** 
 * Private method for retrieving the Serializer that should be used for the passed SerializedObject, defaulting to the default system serializer if none is explicitly set on the object
 */
private OpenmrsSerializer getSerializer(SerializedObject o,OpenmrsSerializer s){
  if (s == null) {
    s=Context.getSerializationService().getDefaultSerializer();
  }
  if (o != null && o.getSerializationClass() != null) {
    s=Context.getSerializationService().getSerializer(o.getSerializationClass());
  }
  return s;
}

Fixed version (ground truth):
/** 
 * Private method for retrieving the Serializer that should be used for the passed SerializedObject, defaulting to the default system serializer if none is explicitly set on the object
 */
private OpenmrsSerializer getSerializer(SerializedObject o){
  if (o != null && o.getSerializationClass() != null) {
    return Context.getSerializationService().getSerializer(o.getSerializationClass());
  }
  return Context.getSerializationService().getDefaultSerializer();
}
Program: 84529
Project: 84529
Buggy source:
/** 
 * This method isn't needed anymore. There are handlers that are mapped around the saveObs(obs) method that get called automatically. See   {@link SaveHandler}, et al.
 * @see SaveHandler
 * @see OpenmrsObjectSaveHandler
 * @see AuditableSaveHandler
 * @deprecated no longer needed. Replaced by handlers.
 */
@Deprecated public void setRequiredProperties(User creator,Date dateCreated){
  RequiredDataAdvice.recursivelyHandle(SaveHandler.class,this,creator,dateCreated,null);
}

Fixed version (ground truth):
/** 
 * This method isn't needed anymore. There are handlers that are mapped around the saveObs(obs) method that get called automatically. See   {@link SaveHandler}, et al.
 * @see SaveHandler
 * @see OpenmrsObjectSaveHandler
 * @see AuditableSaveHandler
 * @deprecated no longer needed. Replaced by handlers.
 */
@Deprecated public void setRequiredProperties(User creator,Date dateCreated){
  RequiredDataAdvice.recursivelyHandle(SaveHandler.class,this,creator,dateCreated,null,null);
}
Program: 84530
Project: 84530
Buggy source:
/** 
 * Sends an email with system information and the given exception
 * @param error
 */
public static void sendSchedulerError(Throwable throwable){
  try {
    Boolean emailIsEnabled=Boolean.valueOf(Context.getAdministrationService().getGlobalProperty(SchedulerConstants.SCHEDULER_ADMIN_EMAIL_ENABLED_PROPERTY));
    if (emailIsEnabled) {
      String recipients=Context.getAdministrationService().getGlobalProperty(SchedulerConstants.SCHEDULER_ADMIN_EMAIL_PROPERTY);
      if (recipients != null) {
        String sender=SchedulerConstants.SCHEDULER_DEFAULT_FROM;
        String subject=SchedulerConstants.SCHEDULER_DEFAULT_SUBJECT + "String_Node_Str" + throwable.getClass().getName();
        String message=new String();
        message+="String_Node_Str";
        message+=SchedulerUtil.getExceptionAsString(throwable);
        message+="String_Node_Str";
        for (        Map.Entry<String,String> entry : Context.getAdministrationService().getSystemVariables().entrySet()) {
          message+=entry.getKey() + "String_Node_Str" + entry.getValue()+ "String_Node_Str";
        }
        log.debug("String_Node_Str" + recipients + "String_Node_Str"+ sender+ "String_Node_Str"+ subject+ "String_Node_Str"+ message);
        Context.getMessageService().sendMessage(recipients,sender,subject,message);
      }
    }
  }
 catch (  Exception e) {
    log.warn("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Sends an email with system information and the given exception
 * @param error
 */
public static void sendSchedulerError(Throwable throwable){
  try {
    Context.openSession();
    Boolean emailIsEnabled=Boolean.valueOf(Context.getAdministrationService().getGlobalProperty(SchedulerConstants.SCHEDULER_ADMIN_EMAIL_ENABLED_PROPERTY));
    if (emailIsEnabled) {
      String recipients=Context.getAdministrationService().getGlobalProperty(SchedulerConstants.SCHEDULER_ADMIN_EMAIL_PROPERTY);
      if (recipients != null) {
        String sender=SchedulerConstants.SCHEDULER_DEFAULT_FROM;
        String subject=SchedulerConstants.SCHEDULER_DEFAULT_SUBJECT + "String_Node_Str" + throwable.getClass().getName();
        String message=new String();
        message+="String_Node_Str";
        message+=SchedulerUtil.getExceptionAsString(throwable);
        message+="String_Node_Str";
        for (        Map.Entry<String,String> entry : Context.getAdministrationService().getSystemVariables().entrySet()) {
          message+=entry.getKey() + "String_Node_Str" + entry.getValue()+ "String_Node_Str";
        }
        log.debug("String_Node_Str" + recipients + "String_Node_Str"+ sender+ "String_Node_Str"+ subject+ "String_Node_Str"+ message);
        Context.getMessageService().sendMessage(recipients,sender,subject,message);
      }
    }
  }
 catch (  Exception e) {
    log.warn("String_Node_Str",e);
  }
 finally {
    Context.closeSession();
  }
}
Program: 84531
Project: 84531
Buggy source:
/** 
 * @see org.openmrs.reporting.db.ReportObjectDAO#saveReportObject(org.openmrs.reporting.AbstractReportObject)
 */
public AbstractReportObject saveReportObject(AbstractReportObject reportObj) throws DAOException {
  ReportObjectWrapper wrappedReportObject;
  User user=Context.getAuthenticatedUser();
  Date now=new Date();
  if (reportObj.getReportObjectId() == null) {
    wrappedReportObject=new ReportObjectWrapper(reportObj);
    wrappedReportObject.setCreator(user);
    wrappedReportObject.setDateCreated(now);
  }
 else {
    wrappedReportObject=(ReportObjectWrapper)sessionFactory.getCurrentSession().get(ReportObjectWrapper.class,reportObj.getReportObjectId());
    wrappedReportObject.setReportObject(reportObj);
    wrappedReportObject.setChangedBy(user);
    wrappedReportObject.setDateChanged(now);
  }
  sessionFactory.getCurrentSession().saveOrUpdate(wrappedReportObject);
  reportObj.setReportObjectId(wrappedReportObject.getReportObjectId());
  return reportObj;
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.reporting.db.ReportObjectDAO#saveReportObject(org.openmrs.reporting.AbstractReportObject)
 */
public AbstractReportObject saveReportObject(AbstractReportObject reportObj) throws DAOException {
  ReportObjectWrapper wrappedReportObject;
  User user=Context.getAuthenticatedUser();
  Date now=new Date();
  if (reportObj.getReportObjectId() == null) {
    wrappedReportObject=new ReportObjectWrapper(reportObj);
    wrappedReportObject.setCreator(user);
    wrappedReportObject.setDateCreated(now);
    wrappedReportObject.setUuid(UUID.randomUUID().toString());
  }
 else {
    wrappedReportObject=(ReportObjectWrapper)sessionFactory.getCurrentSession().get(ReportObjectWrapper.class,reportObj.getReportObjectId());
    wrappedReportObject.setReportObject(reportObj);
    wrappedReportObject.setChangedBy(user);
    wrappedReportObject.setDateChanged(now);
    wrappedReportObject.setUuid(reportObj.getUuid());
  }
  sessionFactory.getCurrentSession().saveOrUpdate(wrappedReportObject);
  reportObj.setReportObjectId(wrappedReportObject.getReportObjectId());
  return reportObj;
}
Program: 84532
Project: 84532
Buggy source:
/** 
 * @param name The concept source name to set.
 */
@Element(data=true) public void setName(String name){
  this.name=name;
}

Fixed version (ground truth):
/** 
 * A descriptive name for this implementation (e.g. AMRS installation in Eldoret, Kenya)
 * @param name The concept source name to set.
 */
@Element(data=true) public void setName(String name){
  this.name=name;
}
Program: 84533
Project: 84533
Buggy source:
/** 
 * The implementation id corresponds to the hl7Code of the ConceptSource that this corresponds to
 * @param implementationId the implementationId to set
 */
@Attribute public void setImplementationId(String implementationId){
  this.implementationId=implementationId;
}

Fixed version (ground truth):
/** 
 * This is the unique id for this implementation. <br/> <br/> The implementation id corresponds to the hl7Code of the ConceptSource that this corresponds to. <br/> <br/> Must be limited to 20 characters and numbers. The characters "^" and "|" are not allowed.
 * @param implementationId the implementationId to set
 */
@Attribute public void setImplementationId(String implementationId){
  this.implementationId=implementationId;
}
Program: 84534
Project: 84534
Buggy source:
/** 
 * @return the passphrase
 */
@Element(data=true,required=false) public String getPassphrase(){
  return passphrase;
}

Fixed version (ground truth):
/** 
 * This text is a long text string that is used to validate who uses an implementation id. Multiple installations of openmrs can use the same implmentation id, but they must all know the passphrase. (Note that if an implementation id is shared, it is assumed that those installations are the same implementation).
 * @return the passphrase
 */
@Element(data=true,required=false) public String getPassphrase(){
  return passphrase;
}
Program: 84535
Project: 84535
Buggy source:
/** 
 * The implementation id corresponds to the hl7Code of the ConceptSource that this corresponds to
 * @return the implementationId
 */
@Attribute public String getImplementationId(){
  return implementationId;
}

Fixed version (ground truth):
/** 
 * This is the unique id for this implementation. <br/> <br/> The implementation id corresponds to the hl7Code of the ConceptSource that this corresponds to.<br/> <br/> Must be limited to 20 characters and numbers. The characters "^" and "|" are not allowed.
 * @param implementationId the implementationId to set
 * @return the implementationId
 */
@Attribute public String getImplementationId(){
  return implementationId;
}
Program: 84536
Project: 84536
Buggy source:
/** 
 * @return Returns the name.
 */
@Element(data=true) public String getName(){
  return name;
}

Fixed version (ground truth):
/** 
 * A descriptive name for this implementation (e.g. AMRS installation in Eldoret, Kenya)
 * @return Returns the name.
 */
@Element(data=true) public String getName(){
  return name;
}
Program: 84537
Project: 84537
Buggy source:
/** 
 * @param passphrase the passphrase to set
 */
@Element(data=true,required=false) public void setPassphrase(String passphrase){
  this.passphrase=passphrase;
}

Fixed version (ground truth):
/** 
 * This text is a long text string that is used to validate who uses an implementation id. Multiple installations of openmrs can use the same implmentation id, but they must all know the passphrase. (Note that if an implementation id is shared, it is assumed that those installations are the same implementation).
 * @param passphrase the passphrase to set
 */
@Element(data=true,required=false) public void setPassphrase(String passphrase){
  this.passphrase=passphrase;
}
Program: 84538
Project: 84538
Buggy source:
/** 
 * @param description The description to set.
 */
@Element(data=true) public void setDescription(String description){
  this.description=description;
}

Fixed version (ground truth):
/** 
 * Text describing this implementation. (e.g. Source for the AMPATH program in Kenya. Created by Paul Biondich)
 * @param description The description to set.
 */
@Element(data=true) public void setDescription(String description){
  this.description=description;
}
Program: 84539
Project: 84539
Buggy source:
/** 
 * @return Returns the description.
 */
@Element(data=true) public String getDescription(){
  return description;
}

Fixed version (ground truth):
/** 
 * Text describing this implementation. (e.g. Source for the AMPATH program in Kenya. Created by Paul Biondich)
 * @return Returns the description.
 */
@Element(data=true) public String getDescription(){
  return description;
}
Program: 84540
Project: 84540
Buggy source:
/** 
 * Set the given <code>implementationId</code> as this implementation's unique id
 * @param implementationId the ImplementationId to save
 * @throws APIException
 * @should create implementation id in database
 * @should overwrite implementation id in database if exists
 */
@Authorized(OpenmrsConstants.PRIV_MANAGE_IMPLEMENTATION_ID) public void setImplementationId(ImplementationId implementationId) throws APIException ;

Fixed version (ground truth):
/** 
 * Set the given <code>implementationId</code> as this implementation's unique id
 * @param implementationId the ImplementationId to save
 * @throws APIException if implementationId is empty or is invalid according to central id server
 * @should create implementation id in database
 * @should overwrite implementation id in database if exists
 * @should not fail if given implementationId is null
 * @should throw APIException if given empty implementationId object
 * @should throw APIException if given a caret in the implementationId code
 * @should throw APIException if given a pipe in the implementationId code
 * @should set uuid on implementation id global property
 */
@Authorized(OpenmrsConstants.PRIV_MANAGE_IMPLEMENTATION_ID) public void setImplementationId(ImplementationId implementationId) throws APIException ;
Program: 84542
Project: 84542
Buggy source:
/** 
 * @see org.openmrs.api.AdministrationService#getImplementationId()
 */
public ImplementationId getImplementationId() throws APIException {
  return dao.getImplementationId();
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.api.AdministrationService#getImplementationId()
 */
public ImplementationId getImplementationId() throws APIException {
  String property=getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_IMPLEMENTATION_ID);
  if (property == null)   return null;
  try {
    ImplementationId implId=OpenmrsUtil.getSerializer().read(ImplementationId.class,property);
    return implId;
  }
 catch (  Throwable t) {
    log.debug("String_Node_Str",t);
  }
  return null;
}
Program: 84546
Project: 84546
Buggy source:
/** 
 * @see {@link UserService#changeQuestionAnswer(String,String,String)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void changeQuestionAnswer_shouldMatchOnCorrectlyHashedStoredPassword() throws Exception {
  executeDataSet(XML_FILENAME);
  Context.logout();
  Context.authenticate("String_Node_Str","String_Node_Str");
  UserService us=Context.getUserService();
  us.changeQuestionAnswer("String_Node_Str","String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @see {@link UserService#changeQuestionAnswer(String,String,String)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void changeQuestionAnswer_shouldMatchOnCorrectlyHashedStoredPassword() throws Exception {
  executeDataSet(XML_FILENAME);
  Context.logout();
  Context.authenticate("String_Node_Str","String_Node_Str");
  UserService us=Context.getUserService();
  us.changeQuestionAnswer("String_Node_Str","String_Node_Str","String_Node_Str");
  Context.logout();
}
Program: 84547
Project: 84547
Buggy source:
/** 
 * @see {@link UserService#changeQuestionAnswer(String,String,String)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void changeQuestionAnswer_shouldMatchOnIncorrectlyHashedStoredPassword() throws Exception {
  executeDataSet(XML_FILENAME);
  Context.logout();
  Context.authenticate("String_Node_Str","String_Node_Str");
  UserService us=Context.getUserService();
  us.changeQuestionAnswer("String_Node_Str","String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @see {@link UserService#changeQuestionAnswer(String,String,String)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void changeQuestionAnswer_shouldMatchOnIncorrectlyHashedStoredPassword() throws Exception {
  executeDataSet(XML_FILENAME);
  Context.logout();
  Context.authenticate("String_Node_Str","String_Node_Str");
  UserService us=Context.getUserService();
  us.changeQuestionAnswer("String_Node_Str","String_Node_Str","String_Node_Str");
  Context.logout();
}
Program: 84548
Project: 84548
Buggy source:
/** 
 * @see {@link UserService#changePassword(String,String)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void changePassword_shouldMatchOnIncorrectlyHashedStoredPassword() throws Exception {
  executeDataSet(XML_FILENAME);
  Context.logout();
  Context.authenticate("String_Node_Str","String_Node_Str");
  UserService us=Context.getUserService();
  us.changePassword("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @see {@link UserService#changePassword(String,String)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void changePassword_shouldMatchOnIncorrectlyHashedStoredPassword() throws Exception {
  executeDataSet(XML_FILENAME);
  Context.logout();
  Context.authenticate("String_Node_Str","String_Node_Str");
  UserService us=Context.getUserService();
  us.changePassword("String_Node_Str","String_Node_Str");
  Context.logout();
}
Program: 84550
Project: 84550
Buggy source:
/** 
 * Convenience method to empty out the dwr-modules.xml file to fix any errors that might have occurred in it when loading or unloading modules.
 * @param servletContext
 */
private void clearDWRFile(ServletContext servletContext){
  String realPath=servletContext.getRealPath("String_Node_Str");
  String absPath=realPath + "String_Node_Str";
  File dwrFile=new File(absPath.replace("String_Node_Str",File.separator));
  if (dwrFile.exists()) {
    try {
      DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
      DocumentBuilder db=dbf.newDocumentBuilder();
      db.setEntityResolver(new EntityResolver(){
        public InputSource resolveEntity(        String publicId,        String systemId) throws SAXException, IOException {
          return new InputSource(new StringReader("String_Node_Str"));
        }
      }
);
      Document doc=db.parse(dwrFile);
      Element elem=doc.getDocumentElement();
      elem.setTextContent("String_Node_Str");
      OpenmrsUtil.saveDocument(doc,dwrFile);
    }
 catch (    IOException io) {
      log.warn("String_Node_Str",io);
    }
catch (    ParserConfigurationException parseError) {
      log.warn("String_Node_Str",parseError);
    }
catch (    SAXException sax) {
      log.warn("String_Node_Str",sax);
    }
catch (    Throwable t) {
      log.debug("String_Node_Str",t);
    }
  }
}

Fixed version (ground truth):
/** 
 * Convenience method to empty out the dwr-modules.xml file to fix any errors that might have occurred in it when loading or unloading modules.
 * @param servletContext
 */
private void clearDWRFile(ServletContext servletContext){
  String realPath=servletContext.getRealPath("String_Node_Str");
  String absPath=realPath + "String_Node_Str";
  File dwrFile=new File(absPath.replace("String_Node_Str",File.separator));
  if (dwrFile.exists()) {
    try {
      DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
      DocumentBuilder db=dbf.newDocumentBuilder();
      db.setEntityResolver(new EntityResolver(){
        public InputSource resolveEntity(        String publicId,        String systemId) throws SAXException, IOException {
          return new InputSource(new StringReader("String_Node_Str"));
        }
      }
);
      Document doc=db.parse(dwrFile);
      Element elem=doc.getDocumentElement();
      elem.setTextContent("String_Node_Str");
      OpenmrsUtil.saveDocument(doc,dwrFile);
    }
 catch (    Throwable t) {
      log.debug("String_Node_Str",t);
      dwrFile.delete();
      try {
        FileWriter writer=new FileWriter(dwrFile);
        writer.write("String_Node_Str");
        writer.close();
      }
 catch (      IOException io) {
        log.error("String_Node_Str" + dwrFile.getAbsolutePath() + "String_Node_Str",io);
      }
    }
  }
}
Program: 84551
Project: 84551
Buggy source:
/** 
 * Returns a subset of the passed set of encounters that match the passed encounter type id
 * @param encs: Superset of encounters
 * @param type: EncounterTypeId to match
 * @return : Subset of passed encounters that match EncounterTypeId
 */
public static Set<Encounter> filterEncountersByType(Set<Encounter> encs,Integer type){
  log.debug("String_Node_Str" + type);
  Set<Encounter> ret=new HashSet<Encounter>();
  if (encs != null) {
    for (Iterator<Encounter> i=encs.iterator(); i.hasNext(); ) {
      Encounter e=i.next();
      if (e.getEncounterType().getEncounterTypeId().intValue() == type.intValue()) {
        ret.add(e);
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Returns a subset of the passed set of encounters that match the passed encounter type id
 * @param encs: Superset of encounters
 * @param type: EncounterTypeId to match
 * @return : Subset of passed encounters that match EncounterTypeId
 */
public static Set<Encounter> filterEncountersByType(Collection<Encounter> encs,Integer type){
  log.debug("String_Node_Str" + type);
  Set<Encounter> ret=new HashSet<Encounter>();
  if (encs != null) {
    for (Iterator<Encounter> i=encs.iterator(); i.hasNext(); ) {
      Encounter e=i.next();
      if (e.getEncounterType().getEncounterTypeId().intValue() == type.intValue()) {
        ret.add(e);
      }
    }
  }
  return ret;
}
Program: 84552
Project: 84552
Buggy source:
/** 
 * Returns a subset of the passed set of observations that match the passed concept type id
 * @param obs: Superset of obs
 * @param concept: ConceptId to match
 * @return : Subset of passed obs that match ConceptId
 */
public static Set<Obs> filterObsByConcept(Set<Obs> obs,Integer concept){
  log.debug("String_Node_Str" + concept);
  Set<Obs> ret=new HashSet<Obs>();
  if (obs != null) {
    for (Iterator<Obs> i=obs.iterator(); i.hasNext(); ) {
      Obs o=i.next();
      if (o.getConcept().getConceptId().intValue() == concept.intValue()) {
        ret.add(o);
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Returns a subset of the passed set of observations that match the passed concept type id
 * @param obs: Superset of obs
 * @param concept: ConceptId to match
 * @return : Subset of passed obs that match ConceptId
 */
public static Set<Obs> filterObsByConcept(Collection<Obs> obs,Integer concept){
  log.debug("String_Node_Str" + concept);
  Set<Obs> ret=new HashSet<Obs>();
  if (obs != null) {
    for (Iterator<Obs> i=obs.iterator(); i.hasNext(); ) {
      Obs o=i.next();
      if (o.getConcept().getConceptId().intValue() == concept.intValue()) {
        ret.add(o);
      }
    }
  }
  return ret;
}
Program: 84553
Project: 84553
Buggy source:
/** 
 * @verifies {@link ObsService#saveObs(Obs,String)} test = should create new file from complexdata for new obs
 */
@Test public void saveObs_shouldCreateNewFileFromComplexDataForNewObs() throws Exception {
  executeDataSet(COMPLEX_OBS_XML);
  ObsService os=Context.getObsService();
  ConceptService cs=Context.getConceptService();
  AdministrationService as=Context.getAdministrationService();
  File complexObsDir=OpenmrsUtil.getDirectoryInApplicationDataDirectory(as.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR));
  File createdFile=new File(complexObsDir,"String_Node_Str");
  Assert.assertFalse(createdFile.exists());
  InputStream inputStream=new ByteArrayInputStream("String_Node_Str".getBytes());
  ComplexData complexData=new ComplexData("String_Node_Str",inputStream);
  Concept questionConcept=cs.getConcept(8474);
  Obs obsToSave=new Obs(new Person(1),questionConcept,new Date(),new Location(1));
  obsToSave.setComplexData(complexData);
  try {
    os.saveObs(obsToSave,null);
    Assert.assertTrue(createdFile.exists());
  }
  finally {
    createdFile.delete();
  }
}

Fixed version (ground truth):
/** 
 * @verifies {@link ObsService#saveObs(Obs,String)} test = should create new file from complexdata for new obs
 */
@Test public void saveObs_shouldCreateNewFileFromComplexDataForNewObs() throws Exception {
  executeDataSet(COMPLEX_OBS_XML);
  ObsService os=Context.getObsService();
  ConceptService cs=Context.getConceptService();
  AdministrationService as=Context.getAdministrationService();
  File complexObsDir=OpenmrsUtil.getDirectoryInApplicationDataDirectory(as.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR));
  File createdFile=new File(complexObsDir,"String_Node_Str");
  if (createdFile.exists())   createdFile.delete();
  InputStream inputStream=new ByteArrayInputStream("String_Node_Str".getBytes());
  ComplexData complexData=new ComplexData("String_Node_Str",inputStream);
  Concept questionConcept=cs.getConcept(8474);
  Obs obsToSave=new Obs(new Person(1),questionConcept,new Date(),new Location(1));
  obsToSave.setComplexData(complexData);
  try {
    os.saveObs(obsToSave,null);
    Assert.assertTrue(createdFile.exists());
  }
  finally {
    createdFile.delete();
  }
}
Program: 84556
Project: 84556
Buggy source:
/** 
 * @see org.springframework.validation.Validator#validate(java.lang.Object,org.springframework.validation.Errors)
 */
public void validate(Object commandObj,Errors errors){
  CommandObject command=(CommandObject)commandObj;
  ValidationUtils.rejectIfEmptyOrWhitespace(errors,"String_Node_Str","String_Node_Str");
  ValidationUtils.rejectIfEmptyOrWhitespace(errors,"String_Node_Str","String_Node_Str");
  for (  Parameter p : command.getParameters()) {
    if (!StringUtils.hasText(p.getName()) || !StringUtils.hasText(p.getLabel()) || p.getClazz() == null)     errors.rejectValue("String_Node_Str",null,"String_Node_Str");
  }
  for (  CohortReportRow row : command.getRows()) {
    if (!StringUtils.hasText(row.getName()))     errors.rejectValue("String_Node_Str",null,"String_Node_Str");
    try {
      CohortDefinition def=CohortUtil.parse(row.getQuery());
      if (def == null)       throw new Exception();
    }
 catch (    Exception ex) {
      errors.rejectValue("String_Node_Str",null,"String_Node_Str" + row.getQuery() + "String_Node_Str"+ ex.getMessage()+ "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * @see org.springframework.validation.Validator#validate(java.lang.Object,org.springframework.validation.Errors)
 */
public void validate(Object commandObj,Errors errors){
  CommandObject command=(CommandObject)commandObj;
  ValidationUtils.rejectIfEmptyOrWhitespace(errors,"String_Node_Str","String_Node_Str");
  ValidationUtils.rejectIfEmptyOrWhitespace(errors,"String_Node_Str","String_Node_Str");
  for (  Parameter p : command.getParameters()) {
    if (!StringUtils.hasText(p.getName()) || !StringUtils.hasText(p.getLabel()) || p.getClazz() == null)     errors.rejectValue("String_Node_Str",null,"String_Node_Str");
  }
  for (  CohortReportRow row : command.getRows()) {
    if (!StringUtils.hasText(row.getName()))     errors.rejectValue("String_Node_Str",null,"String_Node_Str");
    try {
      String query=row.getQuery();
      query=Context.getReportService().applyReportXmlMacros(query);
      CohortDefinition def=CohortUtil.parse(query);
      if (def == null)       throw new Exception();
    }
 catch (    Exception ex) {
      errors.rejectValue("String_Node_Str",null,"String_Node_Str" + row.getQuery() + "String_Node_Str"+ ex.getMessage()+ "String_Node_Str");
    }
  }
}
Program: 84559
Project: 84559
Buggy source:
/** 
 * This method shouldn't be used directly.  Use org.openmrs.api.context.Context#hasPrivilege so that anonymous/authenticated/proxy privileges are all included Return true if this user has the specified privilege
 * @param privilege
 * @return true/false
 */
public boolean hasPrivilege(String privilege){
  if (privilege == null || privilege.equals("String_Node_Str"))   return true;
  if (isSuperUser())   return true;
  Set<Role> tmproles=getAllRoles();
  for (Iterator<Role> i=tmproles.iterator(); i.hasNext(); ) {
    if (i.next().hasPrivilege(privilege))     return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * This method shouldn't be used directly.  Use org.openmrs.api.context.Context#hasPrivilege so that anonymous/authenticated/proxy privileges are all included Return true if this user has the specified privilege
 * @param privilege
 * @return true/false depending on whether user has specified privilege
 */
public boolean hasPrivilege(String privilege){
  if (privilege == null || privilege.equals("String_Node_Str"))   return true;
  if (isSuperUser())   return true;
  Set<Role> tmproles=getAllRoles();
  for (Iterator<Role> i=tmproles.iterator(); i.hasNext(); ) {
    if (i.next().hasPrivilege(privilege))     return true;
  }
  return false;
}
Program: 84560
Project: 84560
Buggy source:
/** 
 * @see org.openmrs.api.db.ConceptDAO#getAllConceptClasses(boolean)
 */
@SuppressWarnings("String_Node_Str") public List<ConceptClass> getAllConceptClasses(boolean includeRetired) throws DAOException {
  Criteria crit=sessionFactory.getCurrentSession().createCriteria(ConceptClass.class);
  if (includeRetired=false)   crit.add(Expression.eq("String_Node_Str",false));
  return crit.list();
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.api.db.ConceptDAO#getAllConceptClasses(boolean)
 */
@SuppressWarnings("String_Node_Str") public List<ConceptClass> getAllConceptClasses(boolean includeRetired) throws DAOException {
  Criteria crit=sessionFactory.getCurrentSession().createCriteria(ConceptClass.class);
  if (includeRetired == false)   crit.add(Expression.eq("String_Node_Str",false));
  return crit.list();
}
Program: 84561
Project: 84561
Buggy source:
/** 
 * Sends an email with system information and the given exception 
 * @param error
 */
public static void sendSchedulerError(Exception error){
  try {
    Boolean emailIsEnabled=Boolean.valueOf(Context.getAdministrationService().getGlobalProperty(SchedulerConstants.SCHEDULER_ADMIN_EMAIL_ENABLED_PROPERTY));
    if (emailIsEnabled) {
      String recipients=Context.getAdministrationService().getGlobalProperty(SchedulerConstants.SCHEDULER_ADMIN_EMAIL_PROPERTY);
      if (recipients != null) {
        String sender=SchedulerConstants.SCHEDULER_DEFAULT_FROM;
        String subject=SchedulerConstants.SCHEDULER_DEFAULT_SUBJECT + "String_Node_Str" + error.getClass().getName();
        String message=new String();
        message+="String_Node_Str";
        message+=SchedulerUtil.getExceptionAsString(error);
        message+="String_Node_Str";
        for (        Map.Entry<String,String> entry : Context.getAdministrationService().getSystemVariables().entrySet()) {
          message+=entry.getKey() + "String_Node_Str" + entry.getValue()+ "String_Node_Str";
        }
        log.info("String_Node_Str" + recipients + "String_Node_Str"+ sender+ "String_Node_Str"+ subject+ "String_Node_Str"+ message);
        Context.getMessageService().sendMessage(recipients,sender,subject,message);
      }
    }
  }
 catch (  Exception e) {
    log.warn("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Sends an email with system information and the given exception 
 * @param error
 */
public static void sendSchedulerError(Exception error){
  try {
    Boolean emailIsEnabled=Boolean.valueOf(Context.getAdministrationService().getGlobalProperty(SchedulerConstants.SCHEDULER_ADMIN_EMAIL_ENABLED_PROPERTY));
    if (emailIsEnabled) {
      String recipients=Context.getAdministrationService().getGlobalProperty(SchedulerConstants.SCHEDULER_ADMIN_EMAIL_PROPERTY);
      if (recipients != null) {
        String sender=SchedulerConstants.SCHEDULER_DEFAULT_FROM;
        String subject=SchedulerConstants.SCHEDULER_DEFAULT_SUBJECT + "String_Node_Str" + error.getClass().getName();
        String message=new String();
        message+="String_Node_Str";
        message+=SchedulerUtil.getExceptionAsString(error);
        message+="String_Node_Str";
        for (        Map.Entry<String,String> entry : Context.getAdministrationService().getSystemVariables().entrySet()) {
          message+=entry.getKey() + "String_Node_Str" + entry.getValue()+ "String_Node_Str";
        }
        log.debug("String_Node_Str" + recipients + "String_Node_Str"+ sender+ "String_Node_Str"+ subject+ "String_Node_Str"+ message);
        Context.getMessageService().sendMessage(recipients,sender,subject,message);
      }
    }
  }
 catch (  Exception e) {
    log.warn("String_Node_Str",e);
  }
}
Program: 84563
Project: 84563
Buggy source:
/** 
 * @see Object#toString() 
 */
public String toString(){
  return "String_Node_Str" + getPatientStateId() + "String_Node_Str"+ getPatientProgram()+ "String_Node_Str"+ getState()+ "String_Node_Str"+ getStartDate()+ "String_Node_Str"+ getEndDate();
}

Fixed version (ground truth):
/** 
 * @see Object#toString() 
 */
public String toString(){
  return "String_Node_Str" + getPatientStateId() + "String_Node_Str"+ getPatientProgram()+ "String_Node_Str"+ getState()+ "String_Node_Str"+ getStartDate()+ "String_Node_Str"+ getEndDate()+ "String_Node_Str"+ getDateCreated()+ "String_Node_Str"+ getDateChanged();
}
Program: 84564
Project: 84564
Buggy source:
/** 
 * Returns a   {@link List<ProgramWorkflowState>} including all possible next ProgramWorkflowStates, for the passed  {@link PatientProgram} ordered by {@link ConceptName}
 * @param fromState - {@link ProgramWorkflowState} to check transition from
 * @param toState - {@link ProgramWorkflowState} to check transition to
 * @return boolean - true if it is allowable to transition from <code>fromState</code> to <code>toState</code>
 */
public boolean isLegalTransition(ProgramWorkflowState fromState,ProgramWorkflowState toState){
  if (fromState == null) {
    return toState.getInitial();
  }
  if (fromState.equals(toState)) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns a   {@link List<ProgramWorkflowState>} including all possible next ProgramWorkflowStates, for the passed  {@link PatientProgram} ordered by {@link ConceptName}.
 * @param fromState {@link ProgramWorkflowState} to check transition from
 * @param toState {@link ProgramWorkflowState} to check transition to
 * @return boolean true if it is allowable to transition from <code>fromState</code> to <code>toState</code>
 */
public boolean isLegalTransition(ProgramWorkflowState fromState,ProgramWorkflowState toState){
  if (fromState == null) {
    return toState.getInitial();
  }
  if (fromState.equals(toState)) {
    return false;
  }
  return true;
}
Program: 84565
Project: 84565
Buggy source:
/** 
 * @see org.openmrs.api.ProgramWorkflowService#triggerStateConversion(org.openmrs.Patient,org.openmrs.Concept,java.util.Date)
 */
public void triggerStateConversion(Patient patient,Concept trigger,Date dateConverted){
  if (patient == null)   throw new APIException("String_Node_Str");
  if (trigger == null)   throw new APIException("String_Node_Str");
  if (dateConverted == null)   throw new APIException("String_Node_Str");
  for (  PatientProgram patientProgram : getPatientPrograms(patient,null,null,null,null,null,false)) {
    Set<ProgramWorkflow> workflows=patientProgram.getProgram().getWorkflows();
    for (    ProgramWorkflow workflow : workflows) {
      ProgramWorkflowState currentState=patientProgram.getCurrentState(workflow).getState();
      ProgramWorkflowState transitionState=workflow.getState(trigger);
      if (transitionState != null && workflow.isLegalTransition(currentState,transitionState)) {
        patientProgram.transitionToState(transitionState,dateConverted);
        log.info("String_Node_Str" + patientProgram + "String_Node_Str"+ currentState+ "String_Node_Str"+ transitionState+ "String_Node_Str"+ dateConverted);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.api.ProgramWorkflowService#triggerStateConversion(org.openmrs.Patient,org.openmrs.Concept,java.util.Date)
 */
public void triggerStateConversion(Patient patient,Concept trigger,Date dateConverted){
  if (patient == null)   throw new APIException("String_Node_Str");
  if (trigger == null)   throw new APIException("String_Node_Str");
  if (dateConverted == null)   throw new APIException("String_Node_Str");
  for (  PatientProgram patientProgram : getPatientPrograms(patient,null,null,null,null,null,false)) {
    Set<ProgramWorkflow> workflows=patientProgram.getProgram().getWorkflows();
    for (    ProgramWorkflow workflow : workflows) {
      PatientState patientState=patientProgram.getCurrentState(workflow);
      ProgramWorkflowState currentState=(patientState != null) ? patientState.getState() : null;
      ProgramWorkflowState transitionState=workflow.getState(trigger);
      log.debug("String_Node_Str" + currentState + "String_Node_Str");
      log.debug("String_Node_Str" + transitionState + "String_Node_Str");
      if (transitionState != null && workflow.isLegalTransition(currentState,transitionState)) {
        patientProgram.transitionToState(transitionState,dateConverted);
        log.debug("String_Node_Str" + patientProgram + "String_Node_Str"+ currentState+ "String_Node_Str"+ transitionState+ "String_Node_Str"+ dateConverted);
      }
    }
    Context.getProgramWorkflowService().savePatientProgram(patientProgram);
  }
}
Program: 84566
Project: 84566
Buggy source:
/** 
 * Setup the reference map object.  Should be called by the PersonFormController/UserFormController.referenceData(...)
 * @param person
 * @return
 */
@SuppressWarnings("String_Node_Str") protected Map setupReferenceData(Map map,Person person) throws Exception {
  String causeOfDeathOther="String_Node_Str";
  if (Context.isAuthenticated()) {
    log.warn("String_Node_Str");
  }
  map.put("String_Node_Str",causeOfDeathOther);
  return map;
}

Fixed version (ground truth):
/** 
 * Setup the reference map object.  Should be called by the PersonFormController/UserFormController.referenceData(...)
 * @param person
 * @return
 */
@SuppressWarnings("String_Node_Str") protected Map setupReferenceData(Map map,Person person) throws Exception {
  String causeOfDeathOther="String_Node_Str";
  if (Context.isAuthenticated()) {
  }
  map.put("String_Node_Str",causeOfDeathOther);
  return map;
}
Program: 84568
Project: 84568
Buggy source:
/** 
 * @see org.openmrs.api.PatientService#getIdentifierValidator(java.lang.String)
 */
@SuppressWarnings("String_Node_Str") public IdentifierValidator getIdentifierValidator(String pivClassName){
  try {
    return getIdentifierValidator(((Class<IdentifierValidator>)Class.forName(pivClassName)));
  }
 catch (  ClassNotFoundException e) {
    log.error("String_Node_Str" + pivClassName,e);
    return getDefaultIdentifierValidator();
  }
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.api.PatientService#getIdentifierValidator(java.lang.String)
 */
@SuppressWarnings("String_Node_Str") public IdentifierValidator getIdentifierValidator(String pivClassName){
  try {
    return getIdentifierValidator(((Class<IdentifierValidator>)Context.loadClass(pivClassName)));
  }
 catch (  ClassNotFoundException e) {
    log.error("String_Node_Str" + pivClassName,e);
    return getDefaultIdentifierValidator();
  }
}
Program: 84569
Project: 84569
Buggy source:
/** 
 * @see org.openmrs.reporting.db.ReportObjectDAO#getReportObjectsByType(java.lang.String)
 */
@SuppressWarnings("String_Node_Str") public List<AbstractReportObject> getReportObjectsByType(String reportObjectType) throws DAOException {
  List<AbstractReportObject> reportObjects=new Vector<AbstractReportObject>();
  Query query=sessionFactory.getCurrentSession().createQuery("String_Node_Str");
  query.setString("String_Node_Str",reportObjectType);
  List<ReportObjectWrapper> wrappedObjects=query.list();
  for (  ReportObjectWrapper wrappedObject : wrappedObjects) {
    AbstractReportObject reportObject=wrappedObject.getReportObject();
    if (reportObject.getReportObjectId() == null) {
      reportObject.setReportObjectId(wrappedObject.getReportObjectId());
    }
    reportObjects.add(reportObject);
  }
  return reportObjects;
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.reporting.db.ReportObjectDAO#getReportObjectsByType(java.lang.String)
 */
@SuppressWarnings("String_Node_Str") public List<AbstractReportObject> getReportObjectsByType(String reportObjectType) throws DAOException {
  List<AbstractReportObject> reportObjects=new Vector<AbstractReportObject>();
  Query query=sessionFactory.getCurrentSession().createQuery("String_Node_Str");
  query.setString("String_Node_Str",reportObjectType);
  List<ReportObjectWrapper> wrappedObjects=query.list();
  for (  ReportObjectWrapper wrappedObject : wrappedObjects) {
    AbstractReportObject reportObject=wrappedObject.getReportObject();
    if (reportObject != null) {
      if (reportObject.getReportObjectId() == null) {
        reportObject.setReportObjectId(wrappedObject.getReportObjectId());
      }
      reportObjects.add(reportObject);
    }
  }
  return reportObjects;
}
Program: 84572
Project: 84572
Buggy source:
/** 
 * This is called prior to displaying a form for the first time.  It tells Spring the form/command object to load into the request
 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
 */
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
  Obs obs=null;
  if (Context.isAuthenticated()) {
    ObsService os=Context.getObsService();
    EncounterService es=Context.getEncounterService();
    String obsId=request.getParameter("String_Node_Str");
    String encounterId=request.getParameter("String_Node_Str");
    if (obsId != null)     obs=os.getObs(Integer.valueOf(obsId));
 else     if (encounterId != null) {
      Encounter e=es.getEncounter(Integer.valueOf(encounterId));
      obs=new Obs();
      obs.setEncounter(e);
      obs.setPerson(e.getPatient());
      obs.setLocation(e.getLocation());
      obs.setObsDatetime(e.getEncounterDatetime());
    }
  }
  if (obs == null)   obs=new Obs();
  return obs;
}

Fixed version (ground truth):
/** 
 * This is called prior to displaying a form for the first time.  It tells Spring the form/command object to load into the request
 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
 */
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
  Obs obs=null;
  if (Context.isAuthenticated()) {
    ObsService os=Context.getObsService();
    EncounterService es=Context.getEncounterService();
    String obsId=request.getParameter("String_Node_Str");
    String encounterId=request.getParameter("String_Node_Str");
    if (obsId != null)     obs=os.getObs(Integer.valueOf(obsId));
 else     if (StringUtils.hasText(encounterId)) {
      Encounter e=es.getEncounter(Integer.valueOf(encounterId));
      obs=new Obs();
      obs.setEncounter(e);
      obs.setPerson(e.getPatient());
      obs.setLocation(e.getLocation());
      obs.setObsDatetime(e.getEncounterDatetime());
    }
  }
  if (obs == null)   obs=new Obs();
  return obs;
}
Program: 84573
Project: 84573
Buggy source:
/** 
 * @see org.openmrs.api.PersonService#parsePersonName(java.lang.String)
 */
public PersonName parsePersonName(String name) throws APIException {
  String firstName=name;
  String middleName="String_Node_Str";
  String lastName="String_Node_Str";
  if (name.contains("String_Node_Str")) {
    String[] names=name.split("String_Node_Str");
    String[] firstNames=names[1].split("String_Node_Str");
    if (firstNames.length == 2) {
      lastName=names[0];
      firstName=firstNames[0];
      middleName=firstNames[1];
    }
 else {
      firstName=names[1];
      lastName=names[2];
    }
  }
 else   if (name.contains("String_Node_Str")) {
    String[] names=name.split("String_Node_Str");
    if (names.length == 3) {
      firstName=names[0];
      middleName=names[1];
      lastName=names[2];
    }
 else {
      firstName=names[0];
      lastName=names[1];
    }
  }
  return new PersonName(firstName,middleName,lastName);
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.api.PersonService#parsePersonName(java.lang.String)
 */
public PersonName parsePersonName(String name) throws APIException {
  String firstName=name;
  String middleName="String_Node_Str";
  String lastName="String_Node_Str";
  if (name.contains("String_Node_Str")) {
    String[] names=name.split("String_Node_Str");
    String[] firstNames=names[1].split("String_Node_Str");
    if (firstNames.length == 2) {
      lastName=names[0];
      firstName=firstNames[0];
      middleName=firstNames[1];
    }
 else {
      firstName=names[1];
      lastName=names[0];
    }
  }
 else   if (name.contains("String_Node_Str")) {
    String[] names=name.split("String_Node_Str");
    if (names.length == 3) {
      firstName=names[0];
      middleName=names[1];
      lastName=names[2];
    }
 else {
      firstName=names[0];
      lastName=names[1];
    }
  }
  return new PersonName(firstName,middleName,lastName);
}