nus-yam/ex-repair huggingface dataset:
Program: 35501
Project: 35501
Buggy source:
/** 
 * Update the value displayed in the given budget ratio field.
 * @param field Field to update.
 */
private void updateComponentValue(final StringField field){
  final FlexibleElementDTO plannedBudgetElement=getPlannedBudget();
  final FlexibleElementDTO spentBudgetElement=getSpentBudget();
  final BatchCommand batchCommand=new BatchCommand();
  batchCommand.add(new GetValue(currentContainerDTO.getId(),plannedBudgetElement.getId(),plannedBudgetElement.getEntityName()));
  batchCommand.add(new GetValue(currentContainerDTO.getId(),spentBudgetElement.getId(),spentBudgetElement.getEntityName()));
  dispatch.execute(batchCommand,new CommandResultHandler<ListResult<Result>>(){
    @Override protected void onCommandSuccess(    ListResult<Result> results){
      final ValueResult plannedBudgetResult=(ValueResult)results.getList().get(0);
      final ValueResult spentBudgetResult=(ValueResult)results.getList().get(1);
      final ComputedValue plannedValue=ComputedValues.from(plannedBudgetResult);
      final ComputedValue spentValue=ComputedValues.from(spentBudgetResult);
      if (plannedValue.get() == null || spentValue.get() == null) {
        field.setValue("String_Node_Str");
      }
 else {
        field.setValue(NumberUtils.ratioAsString(spentValue.get(),plannedValue.get()));
      }
    }
  }
,field);
}

Fixed version (ground truth):
/** 
 * Update the value displayed in the given budget ratio field.
 * @param field Field to update.
 */
private void updateComponentValue(final StringField field){
  final FlexibleElementDTO plannedBudgetElement=getPlannedBudget();
  final FlexibleElementDTO spentBudgetElement=getSpentBudget();
  if (plannedBudgetElement == null || spentBudgetElement == null) {
    return;
  }
  final BatchCommand batchCommand=new BatchCommand();
  batchCommand.add(new GetValue(currentContainerDTO.getId(),plannedBudgetElement.getId(),plannedBudgetElement.getEntityName()));
  batchCommand.add(new GetValue(currentContainerDTO.getId(),spentBudgetElement.getId(),spentBudgetElement.getEntityName()));
  dispatch.execute(batchCommand,new CommandResultHandler<ListResult<Result>>(){
    @Override protected void onCommandSuccess(    ListResult<Result> results){
      final ValueResult plannedBudgetResult=(ValueResult)results.getList().get(0);
      final ValueResult spentBudgetResult=(ValueResult)results.getList().get(1);
      final ComputedValue plannedValue=ComputedValues.from(plannedBudgetResult);
      final ComputedValue spentValue=ComputedValues.from(spentBudgetResult);
      if (plannedValue.get() == null || spentValue.get() == null) {
        field.setValue("String_Node_Str");
      }
 else {
        field.setValue(NumberUtils.ratioAsString(spentValue.get(),plannedValue.get()));
      }
    }
  }
,field);
}
Program: 35502
Project: 35502
Buggy source:
private void onCellEdited(final PivotGridCellEvent event){
  if (ProfileUtils.isGranted(authentication,GlobalPermissionEnum.EDIT_INDICATOR)) {
    setUpdated(true);
    setDirty(true);
    if (event.getCell() != null) {
      if (event.getCell().getCount() > 1) {
        N10N.confirmation(I18N.CONSTANTS.confirmUpdate(),I18N.CONSTANTS.confirmUpdateOfAggregatedCell(),new ConfirmCallback(){
          @Override public void onAction(){
            event.getRecord().set(event.getProperty(),event.getCell().getValue());
          }
        }
);
      }
    }
  }
}

Fixed version (ground truth):
private void onCellEdited(final PivotGridCellEvent event){
  if (ProfileUtils.isGranted(authentication,GlobalPermissionEnum.EDIT_INDICATOR)) {
    setUpdated(true);
    setDirty(true);
    if (event.getCell() != null) {
      event.getRecord().set(event.getProperty(),event.getCell().getValue());
    }
  }
}
Program: 35504
Project: 35504
Buggy source:
@Transactional protected void performChanges(final UpdateMonthlyReports cmd,Map<Month,ReportingPeriod> periods,Site site){
  for (  UpdateMonthlyReports.Change change : cmd.getChanges()) {
    ReportingPeriod period=periods.get(change.month);
    if (period == null) {
      period=new ReportingPeriod(site);
      Calendar calendar=Calendar.getInstance();
      calendar.set(Calendar.YEAR,change.month.getYear());
      calendar.set(Calendar.MONTH,change.month.getMonth() - 1);
      calendar.set(Calendar.DATE,5);
      period.setDate1(calendar.getTime());
      calendar.set(Calendar.DATE,calendar.getActualMaximum(Calendar.DATE) - 5);
      period.setDate2(calendar.getTime());
      em().persist(period);
      periods.put(change.month,period);
    }
 else {
      boolean wasValid=ReportingPeriodValidation.validate(period);
      if (!wasValid) {
        em().merge(period);
      }
    }
    updateIndicatorValue(em(),period,change.indicatorId,change.value,false);
  }
}

Fixed version (ground truth):
@Transactional protected void performChanges(final UpdateMonthlyReports cmd,Map<Month,ReportingPeriod> periods,Site site){
  for (  UpdateMonthlyReports.Change change : cmd.getChanges()) {
    ReportingPeriod period=periods.get(change.month);
    if (period == null) {
      period=new ReportingPeriod(site);
      final Calendar calendar=Calendar.getInstance();
      calendar.clear();
      calendar.set(Calendar.YEAR,change.month.getYear());
      calendar.set(Calendar.MONTH,change.month.getMonth() - 1);
      calendar.set(Calendar.DATE,5);
      period.setDate1(calendar.getTime());
      calendar.set(Calendar.DATE,calendar.getActualMaximum(Calendar.DATE) - 5);
      period.setDate2(calendar.getTime());
      em().persist(period);
      periods.put(change.month,period);
    }
 else {
      final boolean wasValid=ReportingPeriodValidation.validate(period);
      if (!wasValid) {
        em().merge(period);
      }
    }
    updateIndicatorValue(em(),period,change.indicatorId,change.value,false);
  }
}
Program: 35505
Project: 35505
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public VoidResult execute(final UpdateMonthlyReports cmd,final UserExecutionContext context) throws CommandException {
  Site site=em().find(Site.class,cmd.getSiteId());
  Map<Month,ReportingPeriod> periods=new HashMap<Month,ReportingPeriod>();
  for (  ReportingPeriod period : site.getReportingPeriods()) {
    periods.put(Handlers.monthFromRange(period.getDate1(),period.getDate2()),period);
  }
  performChanges(cmd,periods,site);
  return new VoidResult();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public VoidResult execute(final UpdateMonthlyReports cmd,final UserExecutionContext context) throws CommandException {
  Site site=em().find(Site.class,cmd.getSiteId());
  final Map<Month,ReportingPeriod> periods=new HashMap<>();
  for (  ReportingPeriod period : site.getReportingPeriods()) {
    final ReportingPeriod oldPeriod=periods.put(Handlers.monthFromRange(period.getDate1(),period.getDate2()),period);
    if (oldPeriod != null) {
      removeUnusedPeriod(oldPeriod);
    }
  }
  performChanges(cmd,periods,site);
  return new VoidResult();
}
Program: 35506
Project: 35506
Buggy source:
public static Month monthFromRange(Date date1,Date date2){
  final Calendar c1=Calendar.getInstance();
  c1.setTime(date1);
  if (c1.get(Calendar.DAY_OF_MONTH) != 1) {
    return null;
  }
  final Calendar c2=Calendar.getInstance();
  c2.setTime(date2);
  if (c2.get(Calendar.DAY_OF_MONTH) != c2.getActualMaximum(Calendar.DAY_OF_MONTH)) {
    return null;
  }
  if (c2.get(Calendar.MONTH) != c1.get(Calendar.MONTH) || c2.get(Calendar.YEAR) != c2.get(Calendar.YEAR)) {
    return null;
  }
  return new Month(c1.get(Calendar.YEAR),c1.get(Calendar.MONTH) + 1);
}

Fixed version (ground truth):
public static Month monthFromRange(Date date1,Date date2){
  final Calendar c1=Calendar.getInstance();
  c1.setTime(date1);
  if (c1.get(Calendar.DAY_OF_MONTH) != 5) {
    return null;
  }
  final Calendar c2=Calendar.getInstance();
  c2.setTime(date2);
  if (c2.get(Calendar.DAY_OF_MONTH) != c2.getActualMaximum(Calendar.DAY_OF_MONTH) - 5) {
    return null;
  }
  if (c2.get(Calendar.MONTH) != c1.get(Calendar.MONTH) || c2.get(Calendar.YEAR) != c2.get(Calendar.YEAR)) {
    return null;
  }
  return new Month(c1.get(Calendar.YEAR),c1.get(Calendar.MONTH) + 1);
}
Program: 35507
Project: 35507
Buggy source:
private void getProjectsByIndex(final String index,final int id,final RequestManager<List<ProjectDTO>> requestManager,final Transaction<Store> transaction){
  final ObjectStore projectStore=transaction.getObjectStore(getRequiredStore());
  final OpenCursorRequest request=projectStore.index(index).openKeyCursor(IDBKeyRange.only(id));
  final int cursorRequest=requestManager.prepareRequest();
  request.addCallback(new AsyncCallback<Request>(){
    @Override public void onFailure(    Throwable caught){
      requestManager.setRequestFailure(cursorRequest,caught);
    }
    @Override public void onSuccess(    Request result){
      final Cursor cursor=request.getResult();
      if (cursor != null) {
        final ProjectJS projectJS=cursor.getValue();
        final ProjectDTO projectDTO=projectJS.toDTO();
        loadProjectDTO(projectJS,true,requestManager,projectDTO,transaction);
      }
 else {
        requestManager.setRequestSuccess(cursorRequest);
      }
    }
  }
);
}

Fixed version (ground truth):
private void getProjectsByIndex(final String index,final int id,final AsyncCallback<List<ProjectDTO>> callback,final Transaction<Store> transaction){
  final List<ProjectDTO> projects=new ArrayList<ProjectDTO>();
  final RequestManager<List<ProjectDTO>> requestManager=new RequestManager<List<ProjectDTO>>(projects,callback);
  final ObjectStore projectStore=transaction.getObjectStore(getRequiredStore());
  final OpenCursorRequest request=projectStore.index(index).openKeyCursor(IDBKeyRange.only(id));
  final int cursorRequest=requestManager.prepareRequest();
  request.addCallback(new AsyncCallback<Request>(){
    @Override public void onFailure(    Throwable caught){
      requestManager.setRequestFailure(cursorRequest,caught);
    }
    @Override public void onSuccess(    Request result){
      final Cursor cursor=request.getResult();
      if (cursor != null) {
        final ProjectJS projectJS=cursor.getValue();
        if (projectJS != null) {
          final ProjectDTO projectDTO=projectJS.toDTO();
          projects.add(projectDTO);
          loadProjectDTO(projectJS,true,requestManager,projectDTO,transaction);
        }
 else {
          get(cursor.getPrimaryKey(),new RequestManagerCallback<List<ProjectDTO>,ProjectDTO>(requestManager){
            @Override public void onRequestSuccess(            final ProjectDTO project){
              if (project != null) {
                projects.add(project);
              }
            }
          }
,transaction);
        }
        cursor.next();
      }
 else {
        requestManager.setRequestSuccess(cursorRequest);
      }
    }
  }
);
  requestManager.ready();
}
Program: 35508
Project: 35508
Buggy source:
/** 
 * Returns the 2 projects associated with the given project funding id.
 * @param id Identifier of the project funding.
 * @param callback Handler to call when the search is done.
 */
public void getByProjectFundingId(final int id,final AsyncCallback<List<ProjectDTO>> callback){
  openTransaction(Transaction.Mode.READ_ONLY,new OpenTransactionHandler<Store>(){
    @Override public void onTransaction(    final Transaction<Store> transaction){
      final List<ProjectDTO> projects=new ArrayList<ProjectDTO>();
      final RequestManager<List<ProjectDTO>> requestManager=new RequestManager<List<ProjectDTO>>(projects,callback);
      getProjectsByIndex(Indexes.PROJECT_FUNDEDS,id,requestManager,transaction);
      getProjectsByIndex(Indexes.PROJECT_FUNDINGS,id,requestManager,transaction);
      requestManager.ready();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Returns the 2 projects associated with the given project funding id.
 * @param id Identifier of the project funding.
 * @param callback Handler to call when the search is done.
 */
public void getByProjectFundingId(final int id,final AsyncCallback<List<ProjectDTO>> callback){
  openTransaction(Transaction.Mode.READ_ONLY,new OpenTransactionHandler<Store>(){
    @Override public void onTransaction(    final Transaction<Store> transaction){
      getProjectsByIndex(Indexes.PROJECT_PROJECTFUNDINGS,id,callback,transaction);
    }
  }
);
}
Program: 35509
Project: 35509
Buggy source:
public Object getKey(){
  return nativeCursor.getKey();
}

Fixed version (ground truth):
public int getKey(){
  return nativeCursor.getKeyInteger();
}
Program: 35510
Project: 35510
Buggy source:
/** 
 * Creates a new <code>ComputationJS</code> object with the given element.
 * @param computationElement Computation element to map.
 * @return A new <code>ComputationJS</code>.
 */
public static ExtendedComputationElementJS toJavaScript(final ComputationElementDTO computationElement){
  final JsArrayString dependencies=Values.createJavaScriptArray(JsArrayString.class);
  boolean contribution=false;
  final Computation computation=Computations.parse(computationElement.getRule(),Collections.<FlexibleElementDTO>emptyList());
  for (  final Dependency dependency : computation.getDependencies()) {
    if (dependency instanceof CollectionDependency) {
      dependencies.push(((CollectionDependency)dependency).flexibleElementString());
    }
    if (dependency instanceof ContributionDependency) {
      contribution=true;
    }
  }
  final ExtendedComputationElementJS computationJS=Values.createJavaScriptObject();
  computationJS.setId(computationElement.getId());
  computationJS.setLabel(computationElement.getLabel());
  computationJS.setCode(computationElement.getCode());
  computationJS.setRule(computationElement.getRule());
  computationJS.setContribution(contribution);
  computationJS.setDependencies(dependencies);
  computationJS.setProjectModel(computationElement.getProjectModel());
  return computationJS;
}

Fixed version (ground truth):
/** 
 * Creates a new <code>ComputationJS</code> object with the given element.
 * @param computationElement Computation element to map.
 * @return A new <code>ComputationJS</code>.
 */
public static ExtendedComputationElementJS toJavaScript(final ComputationElementDTO computationElement){
  final JsArrayString dependencies=Values.createJavaScriptArray(JsArrayString.class);
  int contribution=0;
  final Computation computation=Computations.parse(computationElement.getRule(),Collections.<FlexibleElementDTO>emptyList());
  for (  final Dependency dependency : computation.getDependencies()) {
    if (dependency instanceof CollectionDependency) {
      dependencies.push(((CollectionDependency)dependency).flexibleElementString());
    }
    if (dependency instanceof ContributionDependency) {
      contribution=1;
    }
  }
  final ExtendedComputationElementJS computationJS=Values.createJavaScriptObject();
  computationJS.setId(computationElement.getId());
  computationJS.setLabel(computationElement.getLabel());
  computationJS.setCode(computationElement.getCode());
  computationJS.setRule(computationElement.getRule());
  computationJS.setContribution(contribution);
  computationJS.setDependencies(dependencies);
  computationJS.setProjectModel(computationElement.getProjectModel());
  return computationJS;
}
Program: 35511
Project: 35511
Buggy source:
public native void setContribution(boolean contribution);

Fixed version (ground truth):
public native void setContribution(int contribution);
Program: 35513
Project: 35513
Buggy source:
/** 
 * Returns the 2 projects associated with the given project funding id.
 * @param id Identifier of the project funding.
 * @param callback Handler to call when the search is done.
 */
public void getByProjectFundingId(final int id,final AsyncCallback<List<ProjectDTO>> callback){
  openTransaction(Transaction.Mode.READ_ONLY,new OpenTransactionHandler<Store>(){
    @Override public void onTransaction(    final Transaction<Store> transaction){
      final List<ProjectDTO> projects=new ArrayList<ProjectDTO>();
      final RequestManager<List<ProjectDTO>> requestManager=new RequestManager<>(projects,callback);
      getProjectsByIndex(Indexes.PROJECT_FUNDEDS,id,requestManager,transaction);
      getProjectsByIndex(Indexes.PROJECT_FUNDINGS,id,requestManager,transaction);
      requestManager.ready();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Returns the 2 projects associated with the given project funding id.
 * @param id Identifier of the project funding.
 * @param callback Handler to call when the search is done.
 */
public void getByProjectFundingId(final int id,final AsyncCallback<List<ProjectDTO>> callback){
  openTransaction(Transaction.Mode.READ_ONLY,new OpenTransactionHandler<Store>(){
    @Override public void onTransaction(    final Transaction<Store> transaction){
      final List<ProjectDTO> projects=new ArrayList<ProjectDTO>();
      final RequestManager<List<ProjectDTO>> requestManager=new RequestManager<List<ProjectDTO>>(projects,callback);
      getProjectsByIndex(Indexes.PROJECT_FUNDEDS,id,requestManager,transaction);
      getProjectsByIndex(Indexes.PROJECT_FUNDINGS,id,requestManager,transaction);
      requestManager.ready();
    }
  }
);
}
Program: 35515
Project: 35515
Buggy source:
/** 
 * Add a value change handler to the given element if it is a dependency of a computation.
 * @param element Element to listen.
 * @param component Component associated to the given element.
 * @param modifications Value change list.
 */
public void listenToValueChangesOfElement(final FlexibleElementDTO element,final Component component,final List<ValueEvent> modifications){
  if (element instanceof ComputationElementDTO) {
    components.put(element,(Field<String>)component);
    elementsWithHandlers.put(element.getId(),(ComputationElementDTO)element);
    initialUpdateIfCurrentValueIsEmpty((ComputationElementDTO)element,(StringField)component);
  }
  final List<ComputationElementDTO> computationElements=dependencies.get(element);
  if (computationElements != null) {
    element.addValueHandler(new ValueHandler(){
      @Override public void onValueChange(      ValueEvent event){
        updateComputations(computationElements,modifications);
      }
    }
);
  }
}

Fixed version (ground truth):
/** 
 * Add a value change handler to the given element if it is a dependency of a computation.
 * @param element Element to listen.
 * @param component Component associated to the given element.
 * @param modifications Value change list.
 */
public void listenToValueChangesOfElement(final FlexibleElementDTO element,final Component component,final List<ValueEvent> modifications){
  if (element instanceof ComputationElementDTO) {
    components.put(element,(Field<String>)component);
    elementsWithHandlers.put(element.getId(),(ComputationElementDTO)element);
    initialUpdateIfCurrentValueIsEmpty((ComputationElementDTO)element,(Field<String>)component);
  }
  final List<ComputationElementDTO> computationElements=dependencies.get(element);
  if (computationElements != null) {
    element.addValueHandler(new ValueHandler(){
      @Override public void onValueChange(      ValueEvent event){
        updateComputations(computationElements,modifications);
      }
    }
);
  }
}
Program: 35516
Project: 35516
Buggy source:
/** 
 * List the dependencies of the given element.
 * @param computationElement Computation element to prepare.
 * @param model Model of the current container.
 */
private void prepareForComputationElement(final ComputationElementDTO computationElement,final IsModel model){
  final Computation computation=computationElement.getComputationForModel(model);
  computations.put(computationElement,computation);
  for (  final Dependency dependency : computation.getDependencies()) {
    List<ComputationElementDTO> list=dependencies.get(dependency);
    if (list == null) {
      list=new ArrayList<ComputationElementDTO>();
      if (dependency instanceof SingleDependency) {
        dependencies.put(((SingleDependency)dependency).getFlexibleElement(),list);
      }
 else {
        throw new UnsupportedOperationException("String_Node_Str");
      }
    }
    list.add(computationElement);
  }
}

Fixed version (ground truth):
/** 
 * List the dependencies of the given element.
 * @param computationElement Computation element to prepare.
 * @param model Model of the current container.
 */
private void prepareForComputationElement(final ComputationElementDTO computationElement,final IsModel model){
  final Computation computation=computationElement.getComputationForModel(model);
  computations.put(computationElement,computation);
  for (  final Dependency dependency : computation.getDependencies()) {
    List<ComputationElementDTO> list=dependencies.get(dependency);
    if (list == null) {
      list=new ArrayList<ComputationElementDTO>();
      if (dependency instanceof SingleDependency) {
        dependencies.put(((SingleDependency)dependency).getFlexibleElement(),list);
      }
    }
    list.add(computationElement);
  }
}
Program: 35517
Project: 35517
Buggy source:
/** 
 * Compute the value of the given element if no value has been provided.
 * @param computationElement Computation element to update.
 * @param component Component associated to the given element.
 */
private void initialUpdateIfCurrentValueIsEmpty(final ComputationElementDTO computationElement,final StringField field){
  if (field.getValue() == null || field.getValue().isEmpty()) {
    updateComputation(computationElement,new ArrayList<ValueEvent>(),false);
  }
}

Fixed version (ground truth):
/** 
 * Compute the value of the given element if no value has been provided.
 * @param computationElement Computation element to update.
 * @param component Component associated to the given element.
 */
private void initialUpdateIfCurrentValueIsEmpty(final ComputationElementDTO computationElement,final Field<String> field){
  if (field.getValue() == null || field.getValue().isEmpty()) {
    updateComputation(computationElement,new ArrayList<ValueEvent>(),false);
  }
}
Program: 35518
Project: 35518
Buggy source:
/** 
 * Search for the project model containing the given computation element.
 * @param computationElement Computation element to use for the search.
 * @return The parent project model or <code>null</code> if the computationelement is not attached to a project model.
 */
public ProjectModel getParentProjectModel(final ComputationElement computationElement){
  final TypedQuery<ProjectModel> modelQuery=em().createQuery("String_Node_Str",ProjectModel.class);
  modelQuery.setParameter("String_Node_Str",computationElement);
  return modelQuery.getSingleResult();
}

Fixed version (ground truth):
/** 
 * Search for the project model containing the given computation element.
 * @param computationElement Computation element to use for the search.
 * @return The parent project model or <code>null</code> if the computationelement is not attached to a project model.
 */
public ProjectModel getParentProjectModel(final ComputationElement computationElement){
  final TypedQuery<ProjectModel> phaseModelsQuery=em().createQuery("String_Node_Str",ProjectModel.class);
  phaseModelsQuery.setParameter("String_Node_Str",computationElement);
  final List<ProjectModel> modelsInPhaseModels=phaseModelsQuery.getResultList();
  if (!modelsInPhaseModels.isEmpty()) {
    return modelsInPhaseModels.get(0);
  }
  final TypedQuery<ProjectModel> detailsQuery=em().createQuery("String_Node_Str",ProjectModel.class);
  detailsQuery.setParameter("String_Node_Str",computationElement);
  final List<ProjectModel> modelsInDetails=detailsQuery.getResultList();
  if (!modelsInDetails.isEmpty()) {
    return modelsInDetails.get(0);
  }
  return null;
}
Program: 35519
Project: 35519
Buggy source:
/** 
 * Update the computation elements referencing the contribution of the given projects.
 * @param fundingProject Project funding the `fundedProject`.
 * @param fundedProject Project founded by `fundingProject`.
 * @param user User changing the value of the contribution.
 */
private void updateComputationsReferencingModelsOfProjects(final Project fundingProject,final Project fundedProject,final User user){
  final List<ComputationElement> impactedComputations=getComputationsReferencingModels(fundingProject.getProjectModel(),fundedProject.getProjectModel());
  for (  final ComputationElement computationElement : impactedComputations) {
    final ProjectModel parentModel=computationService.getParentProjectModel(computationElement);
    if (parentModel != null) {
      if (parentModel.equals(fundedProject.getProjectModel())) {
        computationService.updateComputationValueForProject(computationElement,fundedProject,user);
      }
      if (parentModel.equals(fundingProject.getProjectModel())) {
        computationService.updateComputationValueForProject(computationElement,fundingProject,user);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Update the computation elements referencing the contribution of the given projects.
 * @param fundingProject Project funding the `fundedProject`.
 * @param fundedProject Project founded by `fundingProject`.
 * @param user User changing the value of the contribution.
 */
private void updateComputationsReferencingModelsOfProjects(final Project fundingProject,final Project fundedProject,final User user){
  final Collection<ComputationElement> impactedComputations=computationService.getComputationElementsReferencingContributions();
  for (  final ComputationElement computationElement : impactedComputations) {
    final ProjectModel parentModel=computationService.getParentProjectModel(computationElement);
    if (parentModel != null) {
      final Integer parentModelId=parentModel.getId();
      if (parentModelId.equals(fundedProject.getProjectModel().getId())) {
        computationService.updateComputationValueForProject(computationElement,fundedProject,user);
      }
      if (parentModelId.equals(fundingProject.getProjectModel().getId())) {
        computationService.updateComputationValueForProject(computationElement,fundingProject,user);
      }
    }
  }
}
Program: 35520
Project: 35520
Buggy source:
/** 
 * Add a value change handler to the given element if it is a dependency of a computation.
 * @param element Element to listen.
 * @param component Component associated to the given element.
 * @param modifications Value change list.
 */
public void listenToValueChangesOfElement(final FlexibleElementDTO element,final Component component,final List<ValueEvent> modifications){
  if (element instanceof ComputationElementDTO) {
    components.put(element,(Field<String>)component);
    elementsWithHandlers.put(element.getId(),(ComputationElementDTO)element);
    initialUpdateIfCurrentValueIsEmpty((ComputationElementDTO)element,(Field<String>)component);
  }
  final List<ComputationElementDTO> computationElements=dependencies.get(element);
  if (computationElements != null) {
    element.addValueHandler(new ValueHandler(){
      @Override public void onValueChange(      ValueEvent event){
        updateComputations(computationElements,modifications);
      }
    }
);
  }
}

Fixed version (ground truth):
/** 
 * Add a value change handler to the given element if it is a dependency of a computation.
 * @param element Element to listen.
 * @param component Component associated to the given element.
 * @param modifications Value change list.
 */
public void listenToValueChangesOfElement(final FlexibleElementDTO element,final Component component,final List<ValueEvent> modifications){
  if (component == null) {
    Log.trace("String_Node_Str" + element.getId() + "String_Node_Str");
    return;
  }
  if (element instanceof ComputationElementDTO) {
    @SuppressWarnings("String_Node_Str") final Field<String> field=(Field<String>)component;
    components.put(element,field);
    elementsWithHandlers.put(element.getId(),(ComputationElementDTO)element);
    initialUpdateIfCurrentValueIsEmpty((ComputationElementDTO)element,field);
  }
  final List<ComputationElementDTO> computationElements=dependencies.get(element);
  if (computationElements != null) {
    element.addValueHandler(new ValueHandler(){
      @Override public void onValueChange(      ValueEvent event){
        updateComputations(computationElements,modifications);
      }
    }
);
  }
}
Program: 35521
Project: 35521
Buggy source:
private Integer getOrgUnitId(){
  Integer orgUnitId=null;
  if (currentContainerDTO instanceof OrgUnitDTO) {
    orgUnitId=((OrgUnitDTO)currentContainerDTO).getOrgUnitId();
  }
 else   if (currentContainerDTO instanceof ProjectDTO) {
    orgUnitId=((ProjectDTO)currentContainerDTO).getOrgUnitId();
  }
  return orgUnitId;
}

Fixed version (ground truth):
private Integer getOrgUnitId(){
  Integer orgUnitId=null;
  if (currentContainerDTO instanceof DefaultFlexibleElementContainer) {
    orgUnitId=((DefaultFlexibleElementContainer)currentContainerDTO).getOrgUnitId();
  }
  return orgUnitId;
}
Program: 35522
Project: 35522
Buggy source:
/** 
 * Returns the permission   {@link PrivacyGroupPermissionEnum} for the given authentication and the given privacy group.
 * @param authentication The authentication.
 * @param group The privacy group.
 * @return The permission for the authentication and this privacy group.
 */
public static PrivacyGroupPermissionEnum getPermissionForOrgUnit(final Authentication authentication,final Integer orgUnitId,final PrivacyGroupDTO group){
  if (authentication == null) {
    return PrivacyGroupPermissionEnum.NONE;
  }
  Map<Integer,ProfileDTO> aggregatedProfiles=authentication.getAggregatedProfiles();
  if (aggregatedProfiles == null) {
    return PrivacyGroupPermissionEnum.NONE;
  }
  return getPermission(aggregatedProfiles.get(orgUnitId),group);
}

Fixed version (ground truth):
/** 
 * Returns the permission   {@link PrivacyGroupPermissionEnum} for the given authentication and the given privacy group.
 * @param authentication The authentication.
 * @param group The privacy group.
 * @return The permission for the authentication and this privacy group.
 */
public static PrivacyGroupPermissionEnum getPermissionForOrgUnit(final Authentication authentication,final Integer orgUnitId,final PrivacyGroupDTO group){
  if (authentication == null) {
    return PrivacyGroupPermissionEnum.NONE;
  }
  if (orgUnitId == null) {
    return PrivacyGroupPermissionEnum.WRITE;
  }
  Map<Integer,ProfileDTO> aggregatedProfiles=authentication.getAggregatedProfiles();
  if (aggregatedProfiles == null) {
    return PrivacyGroupPermissionEnum.NONE;
  }
  return getPermission(aggregatedProfiles.get(orgUnitId),group);
}
Program: 35523
Project: 35523
Buggy source:
public native boolean setOnline(boolean online);

Fixed version (ground truth):
public native void setOnline(boolean online);
Program: 35524
Project: 35524
Buggy source:
/** 
 * Shows the given message into the popup.<br/> <br/> There is only one instance of the popup, the previous message may be erased.
 * @param title The title.
 * @param html The message.
 * @param yesCallback The callback for the yes action.
 * @param noCallback The callback for the no action.
 */
static void show(final String title,final String html,ConfirmCallback yesCallback,ConfirmCallback noCallback){
  clear();
  Confirm.yesCallback=yesCallback;
  Confirm.noCallback=noCallback;
  popup.setTitle(ClientUtils.isNotBlank(title) ? title : MessageType.getTitle(MessageType.QUESTION));
  popup.setPageMessage(html,MessageType.QUESTION);
  if (!visible) {
    popup.center();
    visible=true;
  }
}

Fixed version (ground truth):
/** 
 * Shows the given message into the popup. There is only one instance of the popup, the previous message may be erased.
 * @param title The title.
 * @param html The message.
 * @param yesCallback The callback for the yes action.
 * @param noCallback The callback for the no action.
 */
static void show(final String title,final String html,ConfirmCallback yesCallback,ConfirmCallback noCallback){
  clear();
  Confirm.yesCallback=yesCallback;
  Confirm.noCallback=noCallback;
  popup.setTitle(ClientUtils.isNotBlank(title) ? title : MessageType.getTitle(MessageType.QUESTION));
  popup.setPageMessage(html,MessageType.QUESTION);
  if (!visible) {
    popup.center();
    visible=true;
  }
}
Program: 35525
Project: 35525
Buggy source:
/** 
 * Hides the presenter's popup view.<br/> If the presenter's view is not a   {@link ViewPopupInterface} implementation, the method does nothing.
 */
protected final void hideView(){
  if (isPopupView()) {
    ((ViewPopupInterface)view).hide();
  }
}

Fixed version (ground truth):
/** 
 * Hides the presenter's popup view. If the presenter's view is not a   {@link ViewPopupInterface} implementation, the method does nothing.
 */
protected final void hideView(){
  if (isPopupView()) {
    ((ViewPopupInterface)view).hide();
  }
}
Program: 35526
Project: 35526
Buggy source:
/** 
 * Checks if a message needs to be displayed in the application header. If it does, the message is sent to the application presenter's view.<br/> <br/> Also check if the   {@code page} is still in progress from retrieved server properties. If this is the case, awarning message is displayed.
 * @param page The accessed page.
 */
private void displayApplicationMessage(final Page page){
}

Fixed version (ground truth):
/** 
 * Checks if a message needs to be displayed in the application header. If it does, the message is sent to the application presenter's view. Also check if the   {@code page} is still in progress from retrieved server properties. If this is the case, awarning message is displayed.
 * @param page The accessed page.
 */
private void displayApplicationMessage(final Page page){
}
Program: 35527
Project: 35527
Buggy source:
/** 
 * Displays the given message at the top of the current page. If the message is   {@code null} or {@code empty}, the message will be hidden.<br/> <br/> <strong>The page message must be initialized in the   {@link #onPageRequest} method.</strong>
 * @param message The message as HTML.
 */
protected final void displayPageMessage(final String message,MessageType type){
  if (isPopupView()) {
    ((ViewPopupInterface)view).setPageMessage(message,type);
  }
 else {
    injector.getApplicationPresenter().setPageMessage(message,type);
  }
}

Fixed version (ground truth):
/** 
 * Displays the given message at the top of the current page. If the message is   {@code null} or {@code empty}, the message will be hidden. <strong>The page message must be initialized in the   {@link #onPageRequest} method.</strong>
 * @param message The message as HTML.
 */
protected final void displayPageMessage(final String message,MessageType type){
  if (isPopupView()) {
    ((ViewPopupInterface)view).setPageMessage(message,type);
  }
 else {
    injector.getApplicationPresenter().setPageMessage(message,type);
  }
}
Program: 35528
Project: 35528
Buggy source:
/** 
 * init calendar.
 * @param year
 * @return 
 */
private static Calendar initCalendar(int year){
  Calendar cal=Calendar.getInstance();
  cal.set(Calendar.YEAR,year);
  cal.set(Calendar.MONTH,0);
  cal.set(Calendar.DAY_OF_MONTH,1);
  return cal;
}

Fixed version (ground truth):
/** 
 * init calendar.
 * @param year
 * @return
 */
private static Calendar initCalendar(int year){
  final Calendar cal=Calendar.getInstance();
  cal.set(Calendar.YEAR,year);
  cal.set(Calendar.MONTH,0);
  cal.set(Calendar.DAY_OF_MONTH,1);
  return cal;
}
Program: 35529
Project: 35529
Buggy source:
public static void main(String[] args){
}

Fixed version (ground truth):
public static void main(String[] args){
  LOGGER.info("String_Node_Str");
  Integer projectId;
  Integer count;
  final Injector injector=Guice.createInjector(new ConfigurationModule(),new PersistenceModule(),new MapperModule(),new I18nServerModule());
  if (args != null && args.length > 1 && StringUtils.isNumeric(args[0]) && StringUtils.isNumeric(args[1])) {
    count=Integer.valueOf(args[1]);
    projectId=Integer.valueOf(args[0]);
  }
 else {
    LOGGER.error("String_Node_Str");
    LOGGER.info("String_Node_Str");
    return;
  }
  injector.getInstance(PersistService.class).start();
  final ProjectDAO projectDAO=injector.getInstance(ProjectDAO.class);
  final Project project=projectDAO.findById(projectId);
  if (project != null) {
    final EntityManager em=injector.getProvider(EntityManager.class).get();
    em.getTransaction().begin();
    LOGGER.info("String_Node_Str" + count + "String_Node_Str");
    try {
      final Calendar cal=count < 365 ? initCalendar(2016) : initCalendar(2015);
      for (int i=0; i < count; i++) {
        cal.add(Calendar.DAY_OF_MONTH,1);
        PersonalEvent personEvent=personalEventFactory(cal.getTime(),project.getCalendarId(),i);
        em.merge(personEvent);
      }
      em.getTransaction().commit();
    }
 catch (    Exception e) {
      LOGGER.error("String_Node_Str",e);
      em.getTransaction().rollback();
    }
 finally {
      injector.getInstance(PersistService.class).stop();
    }
    LOGGER.info("String_Node_Str");
  }
 else {
    LOGGER.error("String_Node_Str" + projectId + "String_Node_Str");
    injector.getInstance(PersistService.class).stop();
    LOGGER.info("String_Node_Str");
  }
}
Program: 35530
Project: 35530
Buggy source:
/** 
 * Instanciate  and initialize PersonalEvent.
 * @param startDate
 * @param parentCalendarId
 * @param i
 * @return 
 */
public static PersonalEvent personalEventFactory(Date startDate,Integer parentCalendarId,int i){
  PersonalEvent personalEvent=new PersonalEvent();
  personalEvent.setDateCreated(new Date());
  personalEvent.setDescription("String_Node_Str" + i);
  personalEvent.setSummary("String_Node_Str" + i);
  personalEvent.setStartDate(startDate);
  Calendar cal=Calendar.getInstance();
  cal.setTime(startDate);
  cal.set(Calendar.HOUR_OF_DAY,Calendar.HOUR_OF_DAY + 1);
  personalEvent.setEndDate(cal.getTime());
  personalEvent.setCalendarId(parentCalendarId);
  return personalEvent;
}

Fixed version (ground truth):
/** 
 * Instanciate and initialize PersonalEvent.
 * @param startDate
 * @param parentCalendarId
 * @param i
 * @return
 */
public static PersonalEvent personalEventFactory(Date startDate,Integer parentCalendarId,int i){
  final PersonalEvent personalEvent=new PersonalEvent();
  personalEvent.setDateCreated(new Date());
  personalEvent.setDescription("String_Node_Str" + i);
  personalEvent.setSummary("String_Node_Str" + i);
  personalEvent.setStartDate(startDate);
  final Calendar cal=Calendar.getInstance();
  cal.setTime(startDate);
  cal.set(Calendar.HOUR_OF_DAY,Calendar.HOUR_OF_DAY + 1);
  personalEvent.setEndDate(cal.getTime());
  personalEvent.setCalendarId(parentCalendarId);
  return personalEvent;
}
Program: 35531
Project: 35531
Buggy source:
/** 
 * Returns the <em>error</em> value for the given   {@code key}. <pre> error("my.key") -> "???my.key???" </pre>
 * @param key The key for which no value can be found.
 * @return The <em>error</em> value for the given {@code key}.
 */
public static final String error(final String key){
  return ERROR_TAG + key + ERROR_TAG;
}

Fixed version (ground truth):
/** 
 * Returns the <em>error</em> value for the given   {@code key}. <pre> error("my.key") → "???my.key???" </pre>
 * @param key The key for which no value can be found.
 * @return The <em>error</em> value for the given {@code key}.
 */
public static final String error(final String key){
  return ERROR_TAG + key + ERROR_TAG;
}
Program: 35532
Project: 35532
Buggy source:
/** 
 * Builds a property name which   {@code parts} are separated by a dot character.<pre> n(null) -> "" n("") -> "" n("my", "Key", " rocks ") -> "my.Key.rocks" n("my", "Key", "rocks.like.hell") -> "my.Key.rocks.like.hell" </pre>
 * @param parts The property name parts.
 * @return The property name.
 */
public static final String n(final String... parts){
  final StringBuilder builder=new StringBuilder();
  if (parts == null) {
    return builder.toString();
  }
  for (  final String part : parts) {
    if (builder.length() > 0 && ClientUtils.isNotBlank(part)) {
      builder.append('.');
    }
    builder.append(ClientUtils.trimToEmpty(part));
  }
  return builder.toString();
}

Fixed version (ground truth):
/** 
 * Builds a property name which   {@code parts} are separated by a dot character.<pre> n(null) → "" n("") → "" n("my", "Key", " rocks ") → "my.Key.rocks" n("my", "Key", "rocks.like.hell") → "my.Key.rocks.like.hell" </pre>
 * @param parts The property name parts.
 * @return The property name.
 */
public static final String n(final String... parts){
  final StringBuilder builder=new StringBuilder();
  if (parts == null) {
    return builder.toString();
  }
  for (  final String part : parts) {
    if (builder.length() > 0 && ClientUtils.isNotBlank(part)) {
      builder.append('.');
    }
    builder.append(ClientUtils.trimToEmpty(part));
  }
  return builder.toString();
}
Program: 35533
Project: 35533
Buggy source:
/** 
 * Returns if the given   {@code key} is an error key produced by {@link #error(String)} method.<pre> isErrorKey("my.key") -> false isErrorKey("???my.key???") -> true </pre>
 * @param key The key value.
 * @return {@code true} if the given {@code key} is an error key, {@code false} otherwise.
 */
public static final boolean isErrorKey(final String key){
  return key != null && key.startsWith(ERROR_TAG) && key.endsWith(ERROR_TAG);
}

Fixed version (ground truth):
/** 
 * Returns if the given   {@code key} is an error key produced by {@link #error(String)} method.<pre> isErrorKey("my.key") → false isErrorKey("???my.key???") → true </pre>
 * @param key The key value.
 * @return {@code true} if the given {@code key} is an error key, {@code false} otherwise.
 */
public static final boolean isErrorKey(final String key){
  return key != null && key.startsWith(ERROR_TAG) && key.endsWith(ERROR_TAG);
}
Program: 35534
Project: 35534
Buggy source:
/** 
 * Method executed once <b>all</b> executed commands are complete (success or error).<br/> <em>Can be overridden by custom implementation (default implementation does nothing).</em>
 */
protected void onComplete(){
}

Fixed version (ground truth):
/** 
 * Method executed once <b>all</b> executed commands are complete (success or error). <em>Can be overridden by custom implementation (default implementation does nothing).</em>
 */
protected void onComplete(){
}
Program: 35535
Project: 35535
Buggy source:
/** 
 * Returns if the given   {@link Page} instance is associated to a popup view.<br/>If the page is  {@code null} or is not registered into page manager, the method returns {@code false}.
 * @param page The page instance.
 * @return {@code true} if the given {@link Page} instance is associated to a popup view, {@code false} otherwise.
 */
public boolean isPopupView(final Page page){
  if (page == null || pages.get(page.getToken()) == null) {
    return false;
  }
  return pages.get(page.getToken()).right;
}

Fixed version (ground truth):
/** 
 * Returns if the given   {@link Page} instance is associated to a popup view.If the page is  {@code null} or is not registered into page manager, the method returns {@code false}.
 * @param page The page instance.
 * @return {@code true} if the given {@link Page} instance is associated to a popup view, {@code false} otherwise.
 */
public boolean isPopupView(final Page page){
  if (page == null || pages.get(page.getToken()) == null) {
    return false;
  }
  return pages.get(page.getToken()).right;
}
Program: 35536
Project: 35536
Buggy source:
/** 
 * Adds a new browser history entry only if the requested page exists among the   {@code pages} map attribute.<br/>Does nothing if given  {@code pageRequest} references a pop-up view or a <em>skip history</em> page.
 * @param request Page request.
 */
private void newPlace(final PageRequest request){
  final Page page=request.getPage();
  if (page != null && (page.skipHistory() || isPopupView(page))) {
    return;
  }
  History.newItem(request.toString(),false);
}

Fixed version (ground truth):
/** 
 * Adds a new browser history entry only if the requested page exists among the   {@code pages} map attribute.Does nothing if given  {@code pageRequest} references a pop-up view or a <em>skip history</em> page.
 * @param request Page request.
 */
private void newPlace(final PageRequest request){
  final Page page=request.getPage();
  if (page != null && (page.skipHistory() || isPopupView(page))) {
    return;
  }
  History.newItem(request.toString(),false);
}
Program: 35537
Project: 35537
Buggy source:
/** 
 * Updates zones.<br/> Does nothing if given   {@code pageRequest} references a pop-up view.
 * @param pageRequest The page request (containing access rights).
 */
private void updateZones(final PageRequest pageRequest){
  final Page page=pageRequest.getPage();
  if (page != null && isPopupView(page)) {
    return;
  }
  eventBus.updateZone(Zone.ORG_BANNER);
  eventBus.updateZone(Zone.AUTH_BANNER);
  eventBus.updateZone(Zone.OFFLINE_BANNER);
  eventBus.updateZoneRequest(Zone.MENU_BANNER.requestWith(RequestParameter.REQUEST,pageRequest));
}

Fixed version (ground truth):
/** 
 * Updates zones. Does nothing if given   {@code pageRequest} references a pop-up view.
 * @param pageRequest The page request (containing access rights).
 */
private void updateZones(final PageRequest pageRequest){
  final Page page=pageRequest.getPage();
  if (page != null && isPopupView(page)) {
    return;
  }
  eventBus.updateZone(Zone.ORG_BANNER);
  eventBus.updateZone(Zone.AUTH_BANNER);
  eventBus.updateZone(Zone.OFFLINE_BANNER);
  eventBus.updateZoneRequest(Zone.MENU_BANNER.requestWith(RequestParameter.REQUEST,pageRequest));
}
Program: 35538
Project: 35538
Buggy source:
/** 
 * Returns the current authentication.<br/> If no user is currently authenticated, the method returns an empty   {@link Authentication} instance (with{@code null} token).
 * @return The current authentication or empty authentication (never returns {@code null}).
 */
@Override public Authentication get(){
  if (isAnonymous()) {
    clearAuthentication();
  }
  return authentication;
}

Fixed version (ground truth):
/** 
 * Returns the current authentication. If no user is currently authenticated, the method returns an empty   {@link Authentication} instance (with{@code null} token).
 * @return The current authentication or empty authentication (never returns {@code null}).
 */
@Override public Authentication get(){
  if (isAnonymous()) {
    clearAuthentication();
  }
  return authentication;
}
Program: 35539
Project: 35539
Buggy source:
/** 
 * Shows the given message into the popup.<br/> <br/> There is only one instance of the popup, the previous message may be erased.
 * @param title The title.
 * @param html The message.
 * @param yesCallback The callback for the yes action.
 * @param noCallback The callback for the no action.
 */
static void show(final String title,final String html,ConfirmCallback yesCallback,ConfirmCallback noCallback){
  clear();
  Confirm.yesCallback=yesCallback;
  Confirm.noCallback=noCallback;
  popup.setTitle(ClientUtils.isNotBlank(title) ? title : MessageType.getTitle(MessageType.QUESTION));
  popup.setPageMessage(html,MessageType.QUESTION);
  if (!visible) {
    popup.center();
    visible=true;
  }
}

Fixed version (ground truth):
/** 
 * Shows the given message into the popup. There is only one instance of the popup, the previous message may be erased.
 * @param title The title.
 * @param html The message.
 * @param yesCallback The callback for the yes action.
 * @param noCallback The callback for the no action.
 */
static void show(final String title,final String html,ConfirmCallback yesCallback,ConfirmCallback noCallback){
  clear();
  Confirm.yesCallback=yesCallback;
  Confirm.noCallback=noCallback;
  popup.setTitle(ClientUtils.isNotBlank(title) ? title : MessageType.getTitle(MessageType.QUESTION));
  popup.setPageMessage(html,MessageType.QUESTION);
  if (!visible) {
    popup.center();
    visible=true;
  }
}