nus-yam/ex-repair huggingface dataset:
Program: 35591
Project: 35591
Buggy source:
private void addListeners(){
  addStatusListListener();
  view.getSaveButton().addListener(Events.OnClick,new Listener<ButtonEvent>(){
    @Override public void handleEvent(    ButtonEvent be){
      updateModel();
      dataChanged=false;
    }
  }
);
  Listener<BaseEvent> dataChangedListener=new Listener<BaseEvent>(){
    @Override public void handleEvent(    BaseEvent be){
      dataChanged=true;
    }
  }
;
  view.getCanContainProjectsCheckBox().addListener(Events.OnClick,dataChangedListener);
  view.getHasBudgetCheckBox().addListener(Events.OnClick,dataChangedListener);
  view.getTitleField().addListener(Events.Change,dataChangedListener);
  view.getNameField().addListener(Events.Change,dataChangedListener);
  view.getProjectTypeRadioGroup().addListener(Events.Change,dataChangedListener);
}

Fixed version (ground truth):
private void addListeners(){
  addStatusListListener();
  view.getSaveButton().addListener(Events.OnClick,new Listener<ButtonEvent>(){
    @Override public void handleEvent(    ButtonEvent be){
      dataChanged=false;
      updateModel();
    }
  }
);
  Listener<BaseEvent> dataChangedListener=new Listener<BaseEvent>(){
    @Override public void handleEvent(    BaseEvent be){
      dataChanged=true;
    }
  }
;
  view.getCanContainProjectsCheckBox().addListener(Events.OnClick,dataChangedListener);
  view.getHasBudgetCheckBox().addListener(Events.OnClick,dataChangedListener);
  view.getTitleField().addListener(Events.Change,dataChangedListener);
  view.getNameField().addListener(Events.Change,dataChangedListener);
  for (  Field<?> radio : view.getProjectTypeRadioGroup().getAll()) {
    radio.addListener(Events.OnClick,dataChangedListener);
  }
}
Program: 35592
Project: 35592
Buggy source:
@Override public void onUIAction(String actionId){
  if (UIActions.save.equals(actionId)) {
    save();
  }
 else   if (UIActions.discardChanges.equals(actionId)) {
    discard();
  }
}

Fixed version (ground truth):
@Override public void onUIAction(String actionId){
  if (UIActions.save.equals(actionId)) {
    save();
    this.updated=false;
  }
 else   if (UIActions.discardChanges.equals(actionId)) {
    discard();
    this.updated=false;
  }
}
Program: 35593
Project: 35593
Buggy source:
@Override public void handleEvent(NavigationEvent be){
  if (be.getParentObject() instanceof TabBar && be.getNavigationError() == NavigationError.NONE && be.getParentEvent().getNavigationError() == NavigationError.WORK_NOT_SAVED) {
    if (tabBar.getLastAction() == TabAction.REMOVE) {
      final Tab currentTab=tabModel.get(tabBar.getSelectedIndex());
      tabModel.remove(currentTab);
    }
 else     if (tabBar.getLastAction() == TabAction.NAVIGATE) {
      final Tab targetTab=tabModel.get(be.getPlace());
      NavigationError navigationError=tabBar.displayTab(targetTab);
      if (navigationError == NavigationError.NONE) {
        tabBar.setSelectedIndex(tabModel.indexOf(targetTab));
      }
    }
  }
 else   if (be.getParentObject() == logoutButton && be.getNavigationError() == NavigationError.NONE && be.getParentEvent().getNavigationError() == NavigationError.WORK_NOT_SAVED) {
    logOut();
  }
 else {
    final PageState state=be.getPlace();
    activePageState=state;
    final String title;
    if (state instanceof TabPage)     title=((TabPage)state).getTabTitle();
 else     title=I18N.CONSTANTS.title();
    final Tab targetTab=tabModel.add(title,be.getPlace(),true);
    if (state instanceof HasTab)     ((HasTab)state).setTab(targetTab);
  }
}

Fixed version (ground truth):
@Override public void handleEvent(ProjectEvent pe){
  final Tab currentTab=tabModel.get(tabBar.getSelectedIndex());
  tabModel.remove(currentTab);
}
Program: 35595
Project: 35595
Buggy source:
private void deleteIndicatorGroup(IndicatorGroup selected){
  List<ModelData> children=treeStore.getChildren(selected);
  treeStore.remove(selected);
  for (  ModelData child : children) {
    treeStore.add(child,false);
    treeStore.getRecord(child).set("String_Node_Str",null);
  }
}

Fixed version (ground truth):
private void deleteIndicatorGroup(IndicatorGroup selected){
  List<ModelData> children=treeStore.getChildren(selected);
  treeStore.remove(selected);
  treeStore.getRecord(selected).set("String_Node_Str",true);
  for (  ModelData child : children) {
    treeStore.add(child,false);
    treeStore.getRecord(child).set("String_Node_Str",null);
  }
}
Program: 35596
Project: 35596
Buggy source:
@Override protected void doLoad(){
  service.execute(GetIndicators.forDatabase(currentDatabaseId),null,new AsyncCallback<IndicatorListResult>(){
    @Override public void onFailure(    Throwable caught){
    }
    @Override public void onSuccess(    IndicatorListResult result){
      treeStore.removeAll();
      if (!result.getUngroupedIndicators().isEmpty()) {
        treeStore.add((List)result.getUngroupedIndicators(),false);
      }
      for (      IndicatorGroup group : result.getGroups()) {
        treeStore.add(group,false);
        for (        IndicatorDTO indicator : group.getIndicators()) {
          treeStore.add(group,indicator,false);
        }
      }
      onLoaded();
    }
  }
);
}

Fixed version (ground truth):
@Override protected void doLoad(){
  service.execute(GetIndicators.forDatabase(currentDatabaseId),null,new AsyncCallback<IndicatorListResult>(){
    @Override public void onFailure(    Throwable caught){
    }
    @Override public void onSuccess(    IndicatorListResult result){
      treeStore.removeAll();
      for (      IndicatorGroup group : result.getGroups()) {
        treeStore.add(group,false);
        for (        IndicatorDTO indicator : group.getIndicators()) {
          treeStore.add(group,indicator,false);
        }
      }
      if (!result.getUngroupedIndicators().isEmpty()) {
        treeStore.add((List)result.getUngroupedIndicators(),false);
      }
      onLoaded();
    }
  }
);
}
Program: 35598
Project: 35598
Buggy source:
private void applyProperties(Activity activity,PropertyMap changes){
  if (changes.containsKey("String_Node_Str")) {
    activity.setName((String)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setAssessment((Boolean)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setLocationType(em.getReference(LocationType.class,((LocationTypeDTO)changes.get("String_Node_Str")).getId()));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setCategory((String)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setMapIcon((String)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setReportingFrequency((Integer)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setSortOrder((Integer)changes.get("String_Node_Str"));
  }
  activity.getDatabase().setLastSchemaUpdate(new Date());
}

Fixed version (ground truth):
private void applyProperties(Activity activity,PropertyMap changes){
  if (changes.containsKey("String_Node_Str")) {
    activity.setName((String)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setAssessment((Boolean)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setLocationType(em.getReference(LocationType.class,((LocationTypeDTO)changes.get("String_Node_Str")).getId()));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setCategory((String)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setMapIcon((String)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setReportingFrequency((Integer)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.setSortOrder((Integer)changes.get("String_Node_Str"));
  }
  if (changes.containsKey("String_Node_Str")) {
    activity.delete();
  }
  activity.getDatabase().setLastSchemaUpdate(new Date());
}
Program: 35599
Project: 35599
Buggy source:
@Override @Transactional public void retrievePassword(String email,String language) throws EmailException {
  final EntityManager entityManager=injector.getInstance(EntityManager.class);
  final Query query=entityManager.createQuery("String_Node_Str");
  query.setParameter("String_Node_Str",email);
  final User thisUser=(User)query.getSingleResult();
  final String password=generatePassword();
  final String hashedPassword=BCrypt.hashpw(password,BCrypt.gensalt());
  final SimpleEmail mail=new SimpleEmail();
  final Locale locale=getLocale(language);
  final ResourceBundle bundle=ResourceBundle.getBundle("String_Node_Str",locale);
  mail.setSubject(bundle.getString("String_Node_Str"));
  mail.setMsg(MessageFormat.format(bundle.getString("String_Node_Str"),password));
  mail.addTo(email,User.getUserCompleteName(thisUser));
  thisUser.setHashedPassword(hashedPassword);
  entityManager.merge(thisUser);
  final MailSender mailSender=injector.getInstance(MailSender.class);
  mailSender.send(mail);
}

Fixed version (ground truth):
@Override @Transactional public void retrievePassword(String email,String language) throws EmailException {
  final EntityManager entityManager=injector.getInstance(EntityManager.class);
  final Query query=entityManager.createQuery("String_Node_Str");
  query.setParameter("String_Node_Str",email);
  final User thisUser=(User)query.getSingleResult();
  final String password=PasswordHelper.generatePassword();
  final String hashedPassword=BCrypt.hashpw(password,BCrypt.gensalt());
  final SimpleEmail mail=new SimpleEmail();
  final Locale locale=getLocale(language);
  final ResourceBundle bundle=ResourceBundle.getBundle("String_Node_Str",locale);
  mail.setSubject(bundle.getString("String_Node_Str"));
  mail.setMsg(MessageFormat.format(bundle.getString("String_Node_Str"),password));
  mail.addTo(email,User.getUserCompleteName(thisUser));
  thisUser.setHashedPassword(hashedPassword);
  entityManager.merge(thisUser);
  final MailSender mailSender=injector.getInstance(MailSender.class);
  mailSender.send(mail);
}
Program: 35600
Project: 35600
Buggy source:
public Invitation(User newUser,User invitingUser,String hostUrl){
  this.newUser=newUser;
  this.invitingUser=invitingUser;
  this.hostUrl=hostUrl;
}

Fixed version (ground truth):
public Invitation(User newUser,User invitingUser,String hostUrl,String newUserPassword){
  this.newUser=newUser;
  this.invitingUser=invitingUser;
  this.hostUrl=hostUrl;
  this.newUserPassword=newUserPassword;
}
Program: 35601
Project: 35601
Buggy source:
@Trace @LogException public void send(Invitation model,Locale locale,boolean sendBySigmah) throws EmailException, TemplateException, IOException {
  final ResourceBundle mailMessages=getResourceBundle(locale);
  SimpleEmail mail=new SimpleEmail();
  mail.addTo(model.getNewUser().getEmail(),model.getNewUser().getName());
  MessageFormat formatter=new MessageFormat(mailMessages.getString("String_Node_Str"),locale);
  mail.setSubject(formatter.format(null));
  final Object[] messageArguments={User.getUserCompleteName(model.getNewUser()),User.getUserCompleteName(model.getInvitingUser()),model.getInvitingUser().getEmail(),model.getHostUrl()};
  formatter=new MessageFormat(mailMessages.getString("String_Node_Str"),locale);
  String messageSubject=formatter.format(messageArguments);
  mail.setMsg(messageSubject);
  sender.send(mail);
}

Fixed version (ground truth):
@Trace @LogException public void send(Invitation model,Locale locale,boolean sendBySigmah) throws EmailException, TemplateException, IOException {
  final ResourceBundle mailMessages=getResourceBundle(locale);
  SimpleEmail mail=new SimpleEmail();
  mail.addTo(model.getNewUser().getEmail(),model.getNewUser().getName());
  MessageFormat formatter=new MessageFormat(mailMessages.getString("String_Node_Str"),locale);
  mail.setSubject(formatter.format(null));
  final Object[] messageArguments={User.getUserCompleteName(model.getNewUser()),User.getUserCompleteName(model.getInvitingUser()),model.getInvitingUser().getEmail(),model.getHostUrl(),model.getNewUser().getEmail(),model.getNewUserPassword()};
  formatter=new MessageFormat(mailMessages.getString("String_Node_Str"),locale);
  String messageSubject=formatter.format(messageArguments);
  mail.setMsg(messageSubject);
  sender.send(mail);
}
Program: 35602
Project: 35602
Buggy source:
@LogException @Override public void send(Email email) throws EmailException {
  email.setHostName(properties.getProperty(HOST_NAME_KEY,DEFAULT_HOST_NAME));
  email.setSmtpPort(properties.getProperty(PORT_KEY,DEFAULT_PORT));
  email.setFrom(properties.getProperty(FROM_ADDRESS_KEY,DEFAULT_ADDRESS),properties.getProperty(FROM_NAME_KEY,DEFAULT_NAME));
  final String authUsername=properties.getProperty(FROM_AUTH_USERNAME_KEY,StringUtils.EMPTY);
  final String authPassword=properties.getProperty(FROM_AUTH_PASSWORD_KEY,StringUtils.EMPTY);
  if (!StringUtils.EMPTY.equals(authUsername) && !StringUtils.EMPTY.equals(authPassword)) {
    email.setAuthenticator(new DefaultAuthenticator(authUsername,authPassword));
  }
  email.send();
}

Fixed version (ground truth):
@LogException @Override public void send(Email email) throws EmailException {
  email.setHostName(properties.getProperty(HOST_NAME_KEY,DEFAULT_HOST_NAME));
  email.setSmtpPort(Integer.parseInt(properties.getProperty(PORT_KEY,DEFAULT_PORT)));
  email.setFrom(properties.getProperty(FROM_ADDRESS_KEY,DEFAULT_ADDRESS),properties.getProperty(FROM_NAME_KEY,DEFAULT_NAME));
  final String authUsername=properties.getProperty(FROM_AUTH_USERNAME_KEY,StringUtils.EMPTY);
  final String authPassword=properties.getProperty(FROM_AUTH_PASSWORD_KEY,StringUtils.EMPTY);
  if (!StringUtils.EMPTY.equals(authUsername) && !StringUtils.EMPTY.equals(authPassword)) {
    email.setAuthenticator(new DefaultAuthenticator(authUsername,authPassword));
  }
  email.send();
}
Program: 35605
Project: 35605
Buggy source:
@Inject public AdminOrgUnitModelsPresenter(Dispatcher dispatcher,UserLocalCache cache,final Authentication authentication,EventBus eventBus,final AdminPageState currentState){
  this.currentState=currentState;
  this.cache=cache;
  this.dispatcher=dispatcher;
  this.authentication=authentication;
  this.view=new AdminOrgUnitModelsView(dispatcher,cache,eventBus);
}

Fixed version (ground truth):
@Inject public AdminOrgUnitModelsPresenter(Dispatcher dispatcher,UserLocalCache cache,final Authentication authentication,EventBus eventBus,final AdminPageState currentState){
  this.currentState=currentState;
  this.dispatcher=dispatcher;
  this.view=new AdminOrgUnitModelsView(dispatcher,cache,eventBus);
}
Program: 35606
Project: 35606
Buggy source:
@Inject public AdminOrgUnitModelsView(Dispatcher dispatcher,UserLocalCache cache,EventBus eventBus){
  this.dispatcher=dispatcher;
  this.cache=cache;
  this.eventBus=eventBus;
  mainPanel=new ContentPanel(new FitLayout());
  mainPanel.setHeaderVisible(false);
  mainPanel.setBorders(false);
  mainPanel.setBodyBorder(false);
  modelsStore=new AdminModelsStore();
  grid=buildModelsListGrid();
  grid.setAutoHeight(true);
  grid.getView().setForceFit(true);
  mainPanel.setTopComponent(initToolBar());
  mainPanel.setScrollMode(Style.Scroll.AUTO);
  mainPanel.add(grid);
}

Fixed version (ground truth):
@Inject public AdminOrgUnitModelsView(Dispatcher dispatcher,UserLocalCache cache,EventBus eventBus){
  this.dispatcher=dispatcher;
  this.eventBus=eventBus;
  mainPanel=new ContentPanel(new FitLayout());
  mainPanel.setHeaderVisible(false);
  mainPanel.setBorders(false);
  mainPanel.setBodyBorder(false);
  modelsStore=new AdminModelsStore();
  grid=buildModelsListGrid();
  grid.setAutoHeight(true);
  grid.getView().setForceFit(true);
  mainPanel.setTopComponent(initToolBar());
  mainPanel.setScrollMode(Style.Scroll.AUTO);
  mainPanel.add(grid);
}
Program: 35608
Project: 35608
Buggy source:
private ArrayList<OrgUnitModelDTO> queryModels(Query query){
  final ArrayList<OrgUnitModelDTO> orgUnitModelDTOList=new ArrayList<OrgUnitModelDTO>();
  @SuppressWarnings("String_Node_Str") final List<OrgUnitModel> models=(List<OrgUnitModel>)query.getResultList();
  if (models != null) {
    for (    final OrgUnitModel model : models) {
      orgUnitModelDTOList.add(mapper.map(model,OrgUnitModelDTO.class));
    }
  }
  return orgUnitModelDTOList;
}

Fixed version (ground truth):
private ArrayList<OrgUnitModelDTO> queryModels(Query query,int topModelId){
  final ArrayList<OrgUnitModelDTO> orgUnitModelDTOList=new ArrayList<OrgUnitModelDTO>();
  @SuppressWarnings("String_Node_Str") final List<OrgUnitModel> models=(List<OrgUnitModel>)query.getResultList();
  if (models != null) {
    for (    final OrgUnitModel model : models) {
      final OrgUnitModelDTO dto=mapper.map(model,OrgUnitModelDTO.class);
      dto.setTopOrgUnitModel(model.getId() == topModelId);
      orgUnitModelDTOList.add(dto);
    }
  }
  return orgUnitModelDTOList;
}
Program: 35609
Project: 35609
Buggy source:
@Override public CommandResult execute(GetOrgUnitModels cmd,User user) throws CommandException {
  final ArrayList<OrgUnitModelDTO> orgUnitModelDTOList;
  final ProjectModelStatus[] status=cmd.getStatus();
  Query query;
  if (status == null) {
    query=em.createQuery("String_Node_Str");
    query.setParameter("String_Node_Str",user.getOrganization().getId());
    orgUnitModelDTOList=queryModels(query);
  }
 else {
    orgUnitModelDTOList=new ArrayList<OrgUnitModelDTO>();
    for (    final ProjectModelStatus s : status) {
      query=em.createQuery("String_Node_Str");
      query.setParameter("String_Node_Str",user.getOrganization().getId());
      query.setParameter("String_Node_Str",s);
      orgUnitModelDTOList.addAll(queryModels(query));
    }
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + orgUnitModelDTOList.size() + "String_Node_Str");
  }
  return new OrgUnitModelListResult(orgUnitModelDTOList);
}

Fixed version (ground truth):
@Override public CommandResult execute(GetOrgUnitModels cmd,User user) throws CommandException {
  final ArrayList<OrgUnitModelDTO> orgUnitModelDTOList;
  final ProjectModelStatus[] status=cmd.getStatus();
  final int topModelId=user.getOrganization().getRoot().getOrgUnitModel().getId();
  Query query;
  if (status == null) {
    query=em.createQuery("String_Node_Str");
    query.setParameter("String_Node_Str",user.getOrganization().getId());
    orgUnitModelDTOList=queryModels(query,topModelId);
  }
 else {
    orgUnitModelDTOList=new ArrayList<OrgUnitModelDTO>();
    for (    final ProjectModelStatus s : status) {
      query=em.createQuery("String_Node_Str");
      query.setParameter("String_Node_Str",user.getOrganization().getId());
      query.setParameter("String_Node_Str",s);
      orgUnitModelDTOList.addAll(queryModels(query,topModelId));
    }
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + orgUnitModelDTOList.size() + "String_Node_Str");
  }
  return new OrgUnitModelListResult(orgUnitModelDTOList);
}
Program: 35611
Project: 35611
Buggy source:
@Override public int getId(){
  return (Integer)get("String_Node_Str");
}

Fixed version (ground truth):
@Override public int getId(){
  return (Integer)(get("String_Node_Str") != null ? get("String_Node_Str") : -1);
}
Program: 35613
Project: 35613
Buggy source:
/** 
 * Save the flexible elements of imported project model.
 * @param projectModel the imported project model
 * @param em the entity manager
 */
private void saveProjectFlexibleElement(ProjectModel projectModel,EntityManager em,HashMap<Object,Object> modelesReset,HashSet<Object> modelesImport){
  if (projectModel.getProjectBanner() != null && projectModel.getProjectBanner().getLayout() != null) {
    final List<LayoutGroup> bannerLayoutGroups=projectModel.getProjectBanner().getLayout().getGroups();
    saveLayoutGroups(bannerLayoutGroups,em,modelesReset,modelesImport);
  }
  if (projectModel.getProjectDetails() != null && projectModel.getProjectDetails().getLayout() != null) {
    final List<LayoutGroup> detailLayoutGroups=projectModel.getProjectDetails().getLayout().getGroups();
    saveLayoutGroups(detailLayoutGroups,em,modelesReset,modelesImport);
  }
  List<PhaseModel> phases=projectModel.getPhases();
  if (phases != null) {
    projectModel.setPhases(null);
    em.persist(projectModel);
    for (    PhaseModel phase : phases) {
      phase.setParentProjectModel(projectModel);
      if (phase.getLayout() != null) {
        final List<LayoutGroup> phaseLayoutGroups=phase.getLayout().getGroups();
        saveLayoutGroups(phaseLayoutGroups,em,modelesReset,modelesImport);
      }
      if (phase.getDefinition() != null) {
        em.persist(phase.getDefinition());
      }
      em.persist(phase);
    }
    projectModel.setPhases(phases);
  }
}

Fixed version (ground truth):
/** 
 * Save the flexible elements of imported project model.
 * @param projectModel the imported project model
 * @param em the entity manager
 */
private void saveProjectFlexibleElement(ProjectModel projectModel,EntityManager em,HashMap<Object,Object> modelesReset,HashSet<Object> modelesImport,Authentication authentication){
  if (projectModel.getProjectBanner() != null && projectModel.getProjectBanner().getLayout() != null) {
    final List<LayoutGroup> bannerLayoutGroups=projectModel.getProjectBanner().getLayout().getGroups();
    saveLayoutGroups(bannerLayoutGroups,em,modelesReset,modelesImport,authentication);
  }
  if (projectModel.getProjectDetails() != null && projectModel.getProjectDetails().getLayout() != null) {
    final List<LayoutGroup> detailLayoutGroups=projectModel.getProjectDetails().getLayout().getGroups();
    saveLayoutGroups(detailLayoutGroups,em,modelesReset,modelesImport,authentication);
  }
  List<PhaseModel> phases=projectModel.getPhases();
  if (phases != null) {
    projectModel.setPhases(null);
    em.persist(projectModel);
    for (    PhaseModel phase : phases) {
      phase.setParentProjectModel(projectModel);
      if (phase.getLayout() != null) {
        final List<LayoutGroup> phaseLayoutGroups=phase.getLayout().getGroups();
        saveLayoutGroups(phaseLayoutGroups,em,modelesReset,modelesImport,authentication);
      }
      if (phase.getDefinition() != null) {
        em.persist(phase.getDefinition());
      }
      em.persist(phase);
    }
    projectModel.setPhases(phases);
  }
}
Program: 35616
Project: 35616
Buggy source:
/** 
 * Save the quality criterion passed in argument.
 * @param qualityCriterion the quality criterion to save
 * @param em the entity manager
 */
private void saveKeyQuestionQualityCriterion(QualityCriterion qualityCriterion,EntityManager em){
  List<QualityCriterion> qualityCriterions=qualityCriterion.getSubCriteria();
  QualityFramework qualityFramework=qualityCriterion.getQualityFramework();
  if (qualityCriterions != null || qualityFramework != null) {
    qualityCriterion.setSubCriteria(null);
    qualityCriterion.setQualityFramework(null);
    em.persist(qualityCriterion);
    for (    QualityCriterion criterion : qualityCriterions) {
      saveKeyQuestionQualityCriterion(criterion,em);
    }
    qualityCriterion.setSubCriteria(qualityCriterions);
    em.persist(qualityFramework);
    qualityCriterion.setQualityFramework(qualityFramework);
    em.merge(qualityCriterion);
  }
 else {
    em.persist(qualityCriterion);
  }
}

Fixed version (ground truth):
/** 
 * Save the quality criterion passed in argument.
 * @param qualityCriterion the quality criterion to save
 * @param em the entity manager
 */
private static void saveKeyQuestionQualityCriterion(QualityCriterion qualityCriterion,EntityManager em){
  List<QualityCriterion> qualityCriterions=qualityCriterion.getSubCriteria();
  QualityFramework qualityFramework=qualityCriterion.getQualityFramework();
  if (qualityCriterions != null || qualityFramework != null) {
    qualityCriterion.setSubCriteria(null);
    qualityCriterion.setQualityFramework(null);
    em.persist(qualityCriterion);
    for (    QualityCriterion criterion : qualityCriterions) {
      saveKeyQuestionQualityCriterion(criterion,em);
    }
    qualityCriterion.setSubCriteria(qualityCriterions);
    em.persist(qualityFramework);
    qualityCriterion.setQualityFramework(qualityFramework);
    em.merge(qualityCriterion);
  }
 else {
    em.persist(qualityCriterion);
  }
}
Program: 35617
Project: 35617
Buggy source:
/** 
 * Save the key questions of a section
 * @param section the section
 * @param keyQuestions the key questions of the sections
 * @param em the entity manager
 */
private void saveSectionKeyQuestion(ProjectReportModelSection section,List<KeyQuestion> keyQuestions,EntityManager em){
  for (  KeyQuestion keyQuestion : keyQuestions) {
    keyQuestion.setSectionId(section.getId());
    if (keyQuestion.getQualityCriterion() != null) {
      saveKeyQuestionQualityCriterion(keyQuestion.getQualityCriterion(),em);
    }
    em.persist(keyQuestion);
  }
  section.setKeyQuestions(keyQuestions);
}

Fixed version (ground truth):
/** 
 * Save the key questions of a section
 * @param section the section
 * @param keyQuestions the key questions of the sections
 * @param em the entity manager
 */
private static void saveSectionKeyQuestion(ProjectReportModelSection section,List<KeyQuestion> keyQuestions,EntityManager em){
  for (  KeyQuestion keyQuestion : keyQuestions) {
    keyQuestion.setSectionId(section.getId());
    if (keyQuestion.getQualityCriterion() != null) {
      saveKeyQuestionQualityCriterion(keyQuestion.getQualityCriterion(),em);
    }
    em.persist(keyQuestion);
  }
  section.setKeyQuestions(keyQuestions);
}
Program: 35618
Project: 35618
Buggy source:
/** 
 * Save the section whith its sub sections and key questions
 * @param section the section to save
 * @param subSections the subsections to save.
 * @param keyQuestions the key question to save.         
 * @param em the entity manager
 */
private void saveSectionSubSectionKeyQuestions(ProjectReportModelSection section,List<ProjectReportModelSection> subSections,List<KeyQuestion> keyQuestions,EntityManager em){
  if (keyQuestions != null) {
    saveSectionKeyQuestion(section,keyQuestions,em);
  }
  if (subSections != null) {
    for (    ProjectReportModelSection subSection : subSections) {
      subSection.setParentSectionModelId(section.getId());
      List<ProjectReportModelSection> subSubSections=subSection.getSubSections();
      List<KeyQuestion> questions=subSection.getKeyQuestions();
      if (subSubSections != null || keyQuestions != null) {
        subSection.setSubSections(null);
        subSection.setKeyQuestions(null);
        em.persist(subSection);
        saveSectionSubSectionKeyQuestions(subSection,subSubSections,questions,em);
        subSection.setSubSections(subSubSections);
        if (subSection != null) {
          em.merge(subSection);
        }
      }
 else {
        if (subSection != null) {
          em.persist(subSection);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Save the section whith its sub sections and key questions
 * @param section the section to save
 * @param subSections the subsections to save.
 * @param keyQuestions the key question to save.         
 * @param em the entity manager
 */
private static void saveSectionSubSectionKeyQuestions(ProjectReportModelSection section,List<ProjectReportModelSection> subSections,List<KeyQuestion> keyQuestions,EntityManager em){
  if (keyQuestions != null) {
    saveSectionKeyQuestion(section,keyQuestions,em);
  }
  if (subSections != null) {
    for (    ProjectReportModelSection subSection : subSections) {
      subSection.setParentSectionModelId(section.getId());
      List<ProjectReportModelSection> subSubSections=subSection.getSubSections();
      List<KeyQuestion> questions=subSection.getKeyQuestions();
      if (subSubSections != null || keyQuestions != null) {
        subSection.setSubSections(null);
        subSection.setKeyQuestions(null);
        em.persist(subSection);
        saveSectionSubSectionKeyQuestions(subSection,subSubSections,questions,em);
        subSection.setSubSections(subSubSections);
        if (subSection != null) {
          em.merge(subSection);
        }
      }
 else {
        if (subSection != null) {
          em.persist(subSection);
        }
      }
    }
  }
}
Program: 35619
Project: 35619
Buggy source:
/** 
 * Save elements of imported project report model
 * @param projectReportModel the imported project report model
 * @param em the entity manager
 */
private void saveProjectReportModelElement(ProjectReportModel projectReportModel,EntityManager em){
  List<ProjectReportModelSection> sections=projectReportModel.getSections();
  if (sections != null) {
    projectReportModel.setSections(null);
    em.persist(projectReportModel);
    for (    ProjectReportModelSection section : sections) {
      section.setProjectModelId(projectReportModel.getId());
      List<ProjectReportModelSection> subSections=section.getSubSections();
      List<KeyQuestion> keyQuestions=section.getKeyQuestions();
      if (subSections != null || keyQuestions != null) {
        section.setSubSections(null);
        section.setKeyQuestions(null);
        em.persist(section);
        saveSectionSubSectionKeyQuestions(section,subSections,keyQuestions,em);
        section.setSubSections(subSections);
        em.merge(section);
      }
 else {
        em.persist(section);
      }
    }
    projectReportModel.setSections(sections);
  }
}

Fixed version (ground truth):
/** 
 * Save elements of imported project report model
 * @param projectReportModel the imported project report model
 * @param em the entity manager
 */
public static void saveProjectReportModelElement(ProjectReportModel projectReportModel,EntityManager em){
  List<ProjectReportModelSection> sections=projectReportModel.getSections();
  if (sections != null) {
    projectReportModel.setSections(null);
    em.persist(projectReportModel);
    for (    ProjectReportModelSection section : sections) {
      section.setProjectModelId(projectReportModel.getId());
      List<ProjectReportModelSection> subSections=section.getSubSections();
      List<KeyQuestion> keyQuestions=section.getKeyQuestions();
      if (subSections != null || keyQuestions != null) {
        section.setSubSections(null);
        section.setKeyQuestions(null);
        em.persist(section);
        saveSectionSubSectionKeyQuestions(section,subSections,keyQuestions,em);
        section.setSubSections(subSections);
        em.merge(section);
      }
 else {
        em.persist(section);
      }
    }
    projectReportModel.setSections(sections);
  }
}
Program: 35620
Project: 35620
Buggy source:
@Override public CommandResult execute(GetReportElements cmd,User user) throws CommandException {
  final Query reportElementsQuery=em.createQuery("String_Node_Str");
  final Query reportListElementsQuery=em.createQuery("String_Node_Str");
  @SuppressWarnings("String_Node_Str") List<ReportElement> reportElements=reportElementsQuery.getResultList();
  @SuppressWarnings("String_Node_Str") List<ReportListElement> reportListElements=reportListElementsQuery.getResultList();
  List<ReportElementDTO> reportElementsDTOs=new ArrayList<ReportElementDTO>();
  List<ReportListElementDTO> reportListElementsDTOs=new ArrayList<ReportListElementDTO>();
  for (  ReportElement r : reportElements) {
    ReportElementDTO reportElementDTO=mapper.map(r,ReportElementDTO.class);
    reportElementDTO.setModelId(r.getModelId());
    reportElementsDTOs.add(reportElementDTO);
    log.debug("String_Node_Str" + reportElementDTO.getModelId());
  }
  for (  ReportListElement r : reportListElements) {
    ReportListElementDTO reportListElementDTO=mapper.map(r,ReportListElementDTO.class);
    reportListElementDTO.setModelId(r.getModelId());
    reportListElementsDTOs.add(reportListElementDTO);
    log.debug("String_Node_Str" + reportListElementDTO.getModelId());
  }
  return new ReportElementsResult(reportElementsDTOs,reportListElementsDTOs);
}

Fixed version (ground truth):
@Override public CommandResult execute(GetReportElements cmd,User user) throws CommandException {
  final Query reportElementsQuery=em.createQuery("String_Node_Str");
  final Query reportListElementsQuery=em.createQuery("String_Node_Str");
  @SuppressWarnings("String_Node_Str") List<ReportElement> reportElements=reportElementsQuery.getResultList();
  @SuppressWarnings("String_Node_Str") List<ReportListElement> reportListElements=reportListElementsQuery.getResultList();
  List<ReportElementDTO> reportElementsDTOs=new ArrayList<ReportElementDTO>();
  List<ReportListElementDTO> reportListElementsDTOs=new ArrayList<ReportListElementDTO>();
  for (  ReportElement r : reportElements) {
    ReportElementDTO reportElementDTO=mapper.map(r,ReportElementDTO.class);
    reportElementDTO.setModelId(r.getModel().getId());
    reportElementsDTOs.add(reportElementDTO);
    log.debug("String_Node_Str" + reportElementDTO.getModelId());
  }
  for (  ReportListElement r : reportListElements) {
    ReportListElementDTO reportListElementDTO=mapper.map(r,ReportListElementDTO.class);
    reportListElementDTO.setModelId(r.getModel().getId());
    reportListElementsDTOs.add(reportListElementDTO);
    log.debug("String_Node_Str" + reportListElementDTO.getModelId());
  }
  return new ReportElementsResult(reportElementsDTOs,reportListElementsDTOs);
}
Program: 35625
Project: 35625
Buggy source:
@UiHandler("String_Node_Str") void onClick(ClickEvent e){
  final IndicatorDTO newIndicator=new IndicatorDTO();
  newIndicator.setCollectIntervention(true);
  newIndicator.setAggregation(IndicatorDTO.AGGREGATE_SUM);
  newIndicator.setDatabaseId(databaseId);
  newIndicator.setCategory((element.getFormattedCode() + "String_Node_Str" + element.getDescription()).trim());
  showDialog(newIndicator,new FormDialogCallback(){
    @Override public void onValidated(    FormDialogTether dlg){
      dlg.hide();
      element.getIndicators().add(newIndicator);
      indicatorList.getStore().add(newIndicator);
    }
  }
);
}

Fixed version (ground truth):
@UiHandler("String_Node_Str") void onClick(ClickEvent e){
  final IndicatorDTO newIndicator=new IndicatorDTO();
  newIndicator.setCollectIntervention(true);
  newIndicator.setAggregation(IndicatorDTO.AGGREGATE_SUM);
  newIndicator.setDatabaseId(databaseId);
  newIndicator.setCategory((element.getFormattedCode() + "String_Node_Str" + element.getDescription()).trim());
  showDialog(newIndicator,new FormDialogCallback(){
    @Override public void onValidated(    FormDialogTether dlg){
      dispatcher.execute(new CreateEntity(newIndicator),dialog,new AsyncCallback<CreateResult>(){
        @Override public void onFailure(        Throwable caught){
        }
        @Override public void onSuccess(        CreateResult result){
          newIndicator.setId(result.getNewId());
          dialog.hide();
          element.getIndicators().add(newIndicator);
          indicatorList.getStore().add(newIndicator);
          ValueChangeEvent.fire(IndicatorListWidget.this,null);
        }
      }
);
    }
  }
);
}
Program: 35626
Project: 35626
Buggy source:
private void onIndicatorClicked(IndicatorDTO model){
  showDialog(model,new FormDialogCallback(){
    @Override public void onValidated(    FormDialogTether dlg){
      dlg.hide();
      indicatorList.refresh();
    }
  }
);
}

Fixed version (ground truth):
private void onIndicatorClicked(final IndicatorDTO model){
  showDialog(model,new FormDialogCallback(){
    @Override public void onValidated(    FormDialogTether dlg){
      dispatcher.execute(new UpdateEntity(model,model.getProperties()),dialog,new AsyncCallback<VoidResult>(){
        @Override public void onFailure(        Throwable caught){
        }
        @Override public void onSuccess(        VoidResult result){
          dialog.hide();
          indicatorList.refresh();
          ValueChangeEvent.fire(IndicatorListWidget.this,null);
        }
      }
);
    }
  }
);
}
Program: 35627
Project: 35627
Buggy source:
private void showDialog(IndicatorDTO indicator,FormDialogCallback callback){
  final IndicatorForm form=new IndicatorForm(dispatcher);
  form.getBinding().bind(indicator);
  form.setIdVisible(false);
  form.setGroupVisible(false);
  final FormDialogImpl<IndicatorForm> dialog=new FormDialogImpl<IndicatorForm>(form);
  dialog.setHeading(indicator.getName() == null ? I18N.CONSTANTS.newIndicator() : indicator.getName());
  dialog.setWidth(form.getPreferredDialogWidth());
  dialog.setHeight(form.getPreferredDialogHeight());
  dialog.setScrollMode(Scroll.AUTOY);
  dialog.show(callback);
}

Fixed version (ground truth):
private void showDialog(IndicatorDTO indicator,FormDialogCallback callback){
  final IndicatorForm form=new IndicatorForm(dispatcher);
  form.getBinding().bind(indicator);
  form.setIdVisible(false);
  form.setGroupVisible(false);
  dialog=new FormDialogImpl<IndicatorForm>(form);
  dialog.setHeading(indicator.getName() == null ? I18N.CONSTANTS.newIndicator() : indicator.getName());
  dialog.setWidth(form.getPreferredDialogWidth());
  dialog.setHeight(form.getPreferredDialogHeight());
  dialog.setScrollMode(Scroll.AUTOY);
  dialog.show(callback);
}
Program: 35628
Project: 35628
Buggy source:
@Override public void handleEvent(IndicatorEvent event){
  onIndicatorChanged(event);
}

Fixed version (ground truth):
@Override public void handleEvent(IndicatorEvent event){
  onIndicatorChangedExternally(event);
}
Program: 35629
Project: 35629
Buggy source:
public IndicatorListWidget(EventBus eventBus,Dispatcher dispatcher,int databaseId,LogFrameElementDTO element){
  this.dispatcher=dispatcher;
  this.databaseId=databaseId;
  this.element=element;
  initWidget(uiBinder.createAndBindUi(this));
  store=new ListStore<IndicatorDTO>();
  store.add(element.getIndicators());
  indicatorList.setTemplate("String_Node_Str" + style.indicator() + "String_Node_Str"+ "String_Node_Str"+ style.indicatorLabel()+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ style.sourceOfVerification()+ "String_Node_Str"+ I18N.CONSTANTS.sourceOfVerification()+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  indicatorList.setStore(store);
  indicatorList.setBorders(false);
  indicatorList.setOverStyle(style.indicatorOver());
  indicatorList.setSelectStyle(style.indicatorSelected());
  indicatorList.setItemSelector("String_Node_Str" + style.indicator());
  indicatorList.addListener(Events.Select,new Listener<ListViewEvent<IndicatorDTO>>(){
    @Override public void handleEvent(    ListViewEvent<IndicatorDTO> be){
      onIndicatorClicked(be.getModel());
    }
  }
);
  new ListViewDragSource(indicatorList).setGroup(DRAG_AND_DROP_GROUP);
  new ListViewDropTarget(indicatorList).setGroup(DRAG_AND_DROP_GROUP);
  eventBus.addListener(IndicatorEvent.CHANGED,new Listener<IndicatorEvent>(){
    @Override public void handleEvent(    IndicatorEvent event){
      onIndicatorChanged(event);
    }
  }
);
}

Fixed version (ground truth):
public IndicatorListWidget(EventBus eventBus,Dispatcher dispatcher,int databaseId,LogFrameElementDTO element){
  this.dispatcher=dispatcher;
  this.databaseId=databaseId;
  this.element=element;
  initWidget(uiBinder.createAndBindUi(this));
  store=new ListStore<IndicatorDTO>();
  store.add(element.getIndicators());
  indicatorList.setTemplate("String_Node_Str" + style.indicator() + "String_Node_Str"+ "String_Node_Str"+ style.indicatorLabel()+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ style.sourceOfVerification()+ "String_Node_Str"+ I18N.CONSTANTS.sourceOfVerification()+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  indicatorList.setStore(store);
  indicatorList.setBorders(false);
  indicatorList.setOverStyle(style.indicatorOver());
  indicatorList.setSelectStyle(style.indicatorSelected());
  indicatorList.setItemSelector("String_Node_Str" + style.indicator());
  indicatorList.addListener(Events.Select,new Listener<ListViewEvent<IndicatorDTO>>(){
    @Override public void handleEvent(    ListViewEvent<IndicatorDTO> be){
      onIndicatorClicked(be.getModel());
    }
  }
);
  new ListViewDragSource(indicatorList).setGroup(DRAG_AND_DROP_GROUP);
  new ListViewDropTarget(indicatorList).setGroup(DRAG_AND_DROP_GROUP);
  eventBus.addListener(IndicatorEvent.CHANGED,new Listener<IndicatorEvent>(){
    @Override public void handleEvent(    IndicatorEvent event){
      onIndicatorChangedExternally(event);
    }
  }
);
}
Program: 35630
Project: 35630
Buggy source:
@Override public void onValidated(FormDialogTether dlg){
  dlg.hide();
  indicatorList.refresh();
}

Fixed version (ground truth):
@Override public void onValidated(FormDialogTether dlg){
  dispatcher.execute(new UpdateEntity(model,model.getProperties()),dialog,new AsyncCallback<VoidResult>(){
    @Override public void onFailure(    Throwable caught){
    }
    @Override public void onSuccess(    VoidResult result){
      dialog.hide();
      indicatorList.refresh();
      ValueChangeEvent.fire(IndicatorListWidget.this,null);
    }
  }
);
}
Program: 35631
Project: 35631
Buggy source:
@ManyToMany @JoinTable(name="String_Node_Str",joinColumns={@JoinColumn(name="String_Node_Str",nullable=false,updatable=false)},inverseJoinColumns={@JoinColumn(name="String_Node_Str",nullable=false,updatable=false)}) public Set<Indicator> getDataSources(){
  return dataSources;
}

Fixed version (ground truth):
@ManyToMany(cascade=CascadeType.ALL) @JoinTable(name="String_Node_Str",joinColumns={@JoinColumn(name="String_Node_Str",nullable=false,updatable=false)},inverseJoinColumns={@JoinColumn(name="String_Node_Str",nullable=false,updatable=false)}) public Set<Indicator> getDataSources(){
  return dataSources;
}
Program: 35632
Project: 35632
Buggy source:
public void addFunded(ProjectFundingDTO funded){
  if (funded == null) {
    return;
  }
  List<ProjectFundingDTO> fundeds=getFunding();
  if (fundeds == null) {
    fundeds=new ArrayList<ProjectFundingDTO>();
  }
  fundeds.remove(funded);
  fundeds.add(funded);
  setFunded(fundeds);
}

Fixed version (ground truth):
public void addFunded(ProjectFundingDTO funded){
  if (funded == null) {
    return;
  }
  List<ProjectFundingDTO> fundeds=getFunded();
  if (fundeds == null) {
    fundeds=new ArrayList<ProjectFundingDTO>();
  }
  fundeds.remove(funded);
  fundeds.add(funded);
  setFunded(fundeds);
}
Program: 35634
Project: 35634
Buggy source:
private void refreshTree(){
  cache.getOrganizationCache().get(new AsyncCallback<OrgUnitDTOLight>(){
    @Override public void onFailure(    Throwable e){
    }
    @Override public void onSuccess(    OrgUnitDTOLight result){
      if (result != null) {
        view.getStore().removeAll();
        view.getStore().add(result,true);
        view.getTree().expandAll();
      }
    }
  }
);
}

Fixed version (ground truth):
private void refreshTree(){
  cache.getOrganizationCache().get(new AsyncCallback<OrgUnitDTOLight>(){
    @Override public void onFailure(    Throwable e){
    }
    @Override public void onSuccess(    OrgUnitDTOLight result){
      if (result != null) {
        view.getStore().removeAll();
        view.getStore().add(result,true);
        new Timer(){
          @Override public void run(){
            view.getTree().expandAll();
          }
        }
.schedule(2000);
      }
    }
  }
);
}
Program: 35635
Project: 35635
Buggy source:
@Override public void onSuccess(OrgUnitDTOLight result){
  if (result != null) {
    view.getStore().removeAll();
    view.getStore().add(result,true);
    view.getTree().expandAll();
  }
}

Fixed version (ground truth):
@Override public void onSuccess(OrgUnitDTOLight result){
  if (result != null) {
    view.getStore().removeAll();
    view.getStore().add(result,true);
    new Timer(){
      @Override public void run(){
        view.getTree().expandAll();
      }
    }
.schedule(2000);
  }
}
Program: 35637
Project: 35637
Buggy source:
@Override public CommandResult execute(GetOrgUnitModelCopy cmd,User user) throws CommandException {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + cmd.getOrgUnitModelId() + "String_Node_Str");
  }
  Integer existentOrgUnitModelId=Integer.valueOf(String.valueOf(cmd.getOrgUnitModelId()));
  final OrgUnitModel existentOrgUnitModel=em.find(OrgUnitModel.class,existentOrgUnitModelId);
  if (existentOrgUnitModel == null) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + cmd.getOrgUnitModelId() + "String_Node_Str");
    }
    return null;
  }
 else {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + cmd.getOrgUnitModelId());
    }
    OrgUnitModel copyOrgUnitModel=Realizer.realize(existentOrgUnitModel);
    copyOrgUnitModel.resetImport();
    copyOrgUnitModel.setStatus(ProjectModelStatus.DRAFT);
    saveFlexibleElement(copyOrgUnitModel,em);
    copyOrgUnitModel.setName(cmd.getNewModelName());
    em.persist(copyOrgUnitModel);
    return mapper.map(copyOrgUnitModel,OrgUnitModelDTO.class);
  }
}

Fixed version (ground truth):
@Override public CommandResult execute(GetOrgUnitModelCopy cmd,User user) throws CommandException {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + cmd.getOrgUnitModelId() + "String_Node_Str");
  }
  Integer existentOrgUnitModelId=Integer.valueOf(String.valueOf(cmd.getOrgUnitModelId()));
  final OrgUnitModel existentOrgUnitModel=em.find(OrgUnitModel.class,existentOrgUnitModelId);
  if (existentOrgUnitModel == null) {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + cmd.getOrgUnitModelId() + "String_Node_Str");
    }
    return null;
  }
 else {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + cmd.getOrgUnitModelId());
    }
    OrgUnitModel copyOrgUnitModel=Realizer.realize(existentOrgUnitModel);
    copyOrgUnitModel.resetImport();
    copyOrgUnitModel.setStatus(ProjectModelStatus.DRAFT);
    saveFlexibleElement(copyOrgUnitModel,em);
    copyOrgUnitModel.setName(cmd.getNewModelName());
    copyOrgUnitModel.setOrganization(existentOrgUnitModel.getOrganization());
    em.persist(copyOrgUnitModel);
    return mapper.map(copyOrgUnitModel,OrgUnitModelDTO.class);
  }
}
Program: 35639
Project: 35639
Buggy source:
private OrgUnitModel createOrgUnitModel(OrgUnitModel oM,PropertyMap properties,User user){
  if (oM == null)   oM=new OrgUnitModel();
  String oMName=null;
  if (properties.get(AdminUtil.PROP_OM_NAME) != null)   oMName=(String)properties.get(AdminUtil.PROP_OM_NAME);
  String oMTitle=null;
  if (properties.get(AdminUtil.PROP_OM_TITLE) != null)   oMTitle=(String)properties.get(AdminUtil.PROP_OM_TITLE);
  Boolean hasBudget=null;
  if (properties.get(AdminUtil.PROP_OM_HAS_BUDGET) != null)   hasBudget=(Boolean)properties.get(AdminUtil.PROP_OM_HAS_BUDGET);
  Boolean containsProjects=null;
  if (properties.get(AdminUtil.PROP_OM_CONTAINS_PROJECTS) != null)   containsProjects=(Boolean)properties.get(AdminUtil.PROP_OM_CONTAINS_PROJECTS);
  oM.setName(oMName);
  oM.setStatus(ProjectModelStatus.DRAFT);
  oM.setTitle(oMTitle);
  oM.setHasBudget(hasBudget);
  oM.setOrganization(user.getOrganization());
  oM.setCanContainProjects(containsProjects);
  return oM;
}

Fixed version (ground truth):
private OrgUnitModel createOrgUnitModel(OrgUnitModel oM,PropertyMap properties,User user){
  if (oM == null)   oM=new OrgUnitModel();
  String oMName=null;
  if (properties.get(AdminUtil.PROP_OM_NAME) != null)   oMName=(String)properties.get(AdminUtil.PROP_OM_NAME);
  String oMTitle=null;
  if (properties.get(AdminUtil.PROP_OM_TITLE) != null)   oMTitle=(String)properties.get(AdminUtil.PROP_OM_TITLE);
  Boolean hasBudget=null;
  if (properties.get(AdminUtil.PROP_OM_HAS_BUDGET) != null)   hasBudget=(Boolean)properties.get(AdminUtil.PROP_OM_HAS_BUDGET);
  Boolean containsProjects=null;
  if (properties.get(AdminUtil.PROP_OM_CONTAINS_PROJECTS) != null)   containsProjects=(Boolean)properties.get(AdminUtil.PROP_OM_CONTAINS_PROJECTS);
  oM.setName(oMName);
  oM.setTitle(oMTitle);
  oM.setHasBudget(hasBudget);
  oM.setOrganization(user.getOrganization());
  oM.setCanContainProjects(containsProjects);
  if (properties.get(AdminUtil.PROP_OM_STATUS) != null) {
    oM.setStatus((ProjectModelStatus)properties.get(AdminUtil.PROP_OM_STATUS));
  }
 else {
    oM.setStatus(ProjectModelStatus.DRAFT);
  }
  return oM;
}