Program: 35577
Project: 35577
Buggy source:
/** 
 * Callback executed on save button action.
 */
private void onSaveAction(){
  final String htmlName=ClientUtils.removeLastSuffix(view.getNameField().getValue(),HTML_TAG_NEW_LINE);
  if (!FormPanel.valid(view.getCommonForm(),view.getSpecificForm())) {
    return;
  }
  if (htmlName != null && htmlName.isEmpty()) {
    N10N.warn(I18N.CONSTANTS.form_validation_ko());
    return;
  }
  final ElementTypeEnum type=EnumModel.getEnum(view.getTypeField().getValue());
  final LayoutGroupDTO group=view.getLayoutGroupField().getValue();
  final Integer order=ClientUtils.getInteger(view.getOrderField().getValue().intValue());
  final Boolean mandatory=view.getMandatoryField().getValue();
  final PrivacyGroupDTO privacyGroup=view.getPrivacyGroupField().getValue();
  final Boolean amendable=view.getAmendableField().getValue();
  final Boolean exportable=view.getExportableField().getValue();
  final Boolean banner=view.getBannerField().getValue();
  final Integer bannerPosition=ClientUtils.getSimpleValue(view.getBannerPositionField());
  final TextAreaType textAreaType=EnumModel.getEnum(view.getTextAreaTypeField().getValue());
  final Integer length=ClientUtils.getInteger(view.getLengthField().getValue());
  final Boolean decimal=view.getDecimalField().getValue();
  final Integer maxLimit=ClientUtils.getInteger(view.getMaxLimitField().getValue());
  final Integer minLimit=ClientUtils.getInteger(view.getMinLimitField().getValue());
  final Long maxLimitDate=ClientUtils.getTimestamp(view.getMinDateField().getValue());
  final Long minLimitDate=ClientUtils.getTimestamp(view.getMaxDateField().getValue());
  final ReportModelDTO reportModel=view.getReportModelField().getValue();
  final Boolean multiple=view.getMultipleChoicesField().getValue();
  final CategoryTypeDTO category=view.getCategoryTypeField().getValue();
  final Map<String,Object> newFieldProperties=new HashMap<String,Object>();
  newFieldProperties.put(AdminUtil.PROP_FX_NAME,htmlName);
  newFieldProperties.put(AdminUtil.PROP_FX_TYPE,(flexibleElement instanceof BudgetElementDTO) ? ElementTypeEnum.DEFAULT : type);
  newFieldProperties.put(AdminUtil.PROP_FX_GROUP,group);
  newFieldProperties.put(AdminUtil.PROP_FX_ORDER_IN_GROUP,order);
  newFieldProperties.put(AdminUtil.PROP_FX_IN_BANNER,banner);
  newFieldProperties.put(AdminUtil.PROP_FX_POS_IN_BANNER,bannerPosition);
  newFieldProperties.put(AdminUtil.PROP_FX_IS_COMPULSARY,mandatory);
  newFieldProperties.put(AdminUtil.PROP_FX_PRIVACY_GROUP,privacyGroup);
  newFieldProperties.put(AdminUtil.PROP_FX_AMENDABLE,amendable);
  newFieldProperties.put(AdminUtil.PROP_FX_EXPORTABLE,exportable);
  newFieldProperties.put(AdminUtil.PROP_FX_TEXT_TYPE,textAreaType != null ? textAreaType.getCode() : null);
  newFieldProperties.put(AdminUtil.PROP_FX_LENGTH,length);
  newFieldProperties.put(AdminUtil.PROP_FX_MAX_LIMIT,maxLimit);
  newFieldProperties.put(AdminUtil.PROP_FX_MIN_LIMIT,minLimit);
  if (textAreaType == TextAreaType.DATE) {
    newFieldProperties.put(AdminUtil.PROP_FX_MAX_LIMIT,maxLimitDate);
    newFieldProperties.put(AdminUtil.PROP_FX_MIN_LIMIT,minLimitDate);
  }
  if (type == ElementTypeEnum.TEXT_AREA && decimal != null) {
    newFieldProperties.put(AdminUtil.PROP_FX_DECIMAL,decimal);
  }
  newFieldProperties.put(AdminUtil.PROP_FX_REPORT_MODEL,reportModel);
  newFieldProperties.put(AdminUtil.PROP_FX_Q_MULTIPLE,multiple);
  if (category != null && !DEFAULT_CATEGORY_TYPE.equals(category)) {
    newFieldProperties.put(AdminUtil.PROP_FX_Q_CATEGORY,category);
  }
  if (ClientUtils.isNotEmpty(customChoices)) {
    newFieldProperties.put(AdminUtil.PROP_FX_Q_CHOICES,new ArrayList<String>(customChoices));
  }
  if (ClientUtils.isNotEmpty(disabledCustomChoices)) {
    newFieldProperties.put(AdminUtil.PROP_FX_Q_CHOICES_DISABLED,disabledCustomChoices);
  }
  List<BudgetSubFieldDTO> budgetSubFieldsToUpdate=new ArrayList<BudgetSubFieldDTO>();
  if (view.getBudgetFields().getRowCount() > 0) {
    for (int i=1; i < view.getBudgetFields().getRowCount(); i++) {
      if (view.getBudgetFields().getWidget(i,0) != null) {
        Object budgetFieldData=((Text)view.getBudgetFields().getWidget(i,0)).getData("String_Node_Str");
        if (budgetFieldData != null) {
          ((BudgetSubFieldDTO)budgetFieldData).setFieldOrder(i);
          budgetSubFieldsToUpdate.add((BudgetSubFieldDTO)budgetFieldData);
        }
      }
    }
    newFieldProperties.put(AdminUtil.PROP_FX_B_BUDGETSUBFIELDS,budgetSubFieldsToUpdate);
    newFieldProperties.put(AdminUtil.PROP_FX_B_BUDGET_RATIO_DIVIDEND,view.getUpBudgetSubFieldCombo().getValue());
    newFieldProperties.put(AdminUtil.PROP_FX_B_BUDGET_RATIO_DIVISOR,view.getDownBudgetSubFieldCombo().getValue());
  }
  final StringBuilder message=new StringBuilder();
  message.append("String_Node_Str");
  for (  Map.Entry<String,Object> newP : newFieldProperties.entrySet()) {
    message.append(newP.getKey()).append('=').append(newP.getValue()).append("String_Node_Str");
  }
  if (Log.isDebugEnabled()) {
    Log.debug(message.append(')').toString());
  }
  if (flexibleElement != null) {
    message.setLength(0);
    message.append("String_Node_Str");
    for (    final Entry<String,Object> old : oldFieldProperties.entrySet()) {
      message.append(old.getKey()).append('=').append(old.getValue()).append("String_Node_Str");
      if ((old.getValue() != null && old.getValue().equals(newFieldProperties.get(old.getKey()))) || (old.getValue() == null && newFieldProperties.get(old.getKey()) == null)) {
        newFieldProperties.remove(old.getKey());
      }
    }
    if (Log.isDebugEnabled()) {
      Log.debug(message.append(')').toString());
    }
  }
  message.setLength(0);
  message.append("String_Node_Str");
  for (  final Entry<String,Object> newP : newFieldProperties.entrySet()) {
    message.append(newP.getKey()).append('=').append(newP.getValue()).append("String_Node_Str");
  }
  if (Log.isDebugEnabled()) {
    Log.debug(message.append(')').toString());
  }
  if (newFieldProperties.get(AdminUtil.PROP_FX_ORDER_IN_GROUP) != null) {
    newFieldProperties.put(AdminUtil.PROP_FX_GROUP,group);
  }
  newFieldProperties.put(AdminUtil.PROP_FX_FLEXIBLE_ELEMENT,(flexibleElement != null) ? flexibleElement : new TextAreaElementDTO());
  newFieldProperties.put(AdminUtil.ADMIN_PROJECT_MODEL,currentModel);
  newFieldProperties.put(AdminUtil.ADMIN_ORG_UNIT_MODEL,currentModel);
  newFieldProperties.put(AdminUtil.PROP_FX_OLD_FIELDS,oldFieldProperties);
  dispatch.execute(new CreateEntity(currentModel.getEntityName(),newFieldProperties),new CommandResultHandler<CreateResult>(){
    @Override public void onCommandFailure(    final Throwable caught){
      N10N.error(I18N.CONSTANTS.adminFlexibleCreationBox(),I18N.MESSAGES.adminStandardCreationFailure(I18N.CONSTANTS.adminStandardFlexibleName() + "String_Node_Str" + htmlName+ "String_Node_Str"));
    }
    @Override public void onCommandSuccess(    final CreateResult result){
      if (result == null) {
        N10N.warn(I18N.CONSTANTS.adminFlexibleCreationBox(),I18N.MESSAGES.adminStandardCreationNull(I18N.CONSTANTS.adminStandardFlexibleName() + "String_Node_Str" + htmlName+ "String_Node_Str"));
        return;
      }
      final boolean update=flexibleElement != null;
      final IsModel updatedModel=(IsModel)result.getEntity();
      FlexibleElementDTO updatedOrCreatedFlexibleElement=null;
      if (update) {
        for (        final FlexibleElementDTO updatedFlexibleElement : updatedModel.getAllElements()) {
          if (updatedFlexibleElement.getId().equals(flexibleElement.getId())) {
            updatedOrCreatedFlexibleElement=updatedFlexibleElement;
          }
        }
        N10N.infoNotif(I18N.CONSTANTS.adminFlexibleCreationBox(),I18N.MESSAGES.adminStandardUpdateSuccess(I18N.CONSTANTS.adminStandardFlexibleName() + "String_Node_Str" + htmlName+ "String_Node_Str"));
      }
 else {
        final List<Integer> oldFlexibleIds=new ArrayList<Integer>();
        for (        final FlexibleElementDTO oldFlexibleElement : currentModel.getAllElements()) {
          oldFlexibleIds.add(oldFlexibleElement.getId());
        }
        for (        final FlexibleElementDTO newFlexibleElement : updatedModel.getAllElements()) {
          if (!oldFlexibleIds.contains(newFlexibleElement.getId())) {
            updatedOrCreatedFlexibleElement=newFlexibleElement;
          }
        }
        N10N.infoNotif(I18N.CONSTANTS.adminFlexibleCreationBox(),I18N.MESSAGES.adminStandardCreationSuccess(I18N.CONSTANTS.adminStandardFlexibleName() + "String_Node_Str" + htmlName+ "String_Node_Str"));
      }
      eventBus.fireEvent(new UpdateEvent(UpdateEvent.FLEXIBLE_ELEMENT_UPDATE,updatedModel,update,updatedOrCreatedFlexibleElement));
      hideView();
    }
  }
,view.getSaveButton());
}

Fixed version (ground truth):
/** 
 * Callback executed on save button action.
 */
private void onSaveAction(){
  final String htmlName=ClientUtils.removeLastSuffix(view.getNameField().getValue(),HTML_TAG_NEW_LINE);
  if (!FormPanel.valid(view.getCommonForm(),view.getSpecificForm())) {
    return;
  }
  if (htmlName != null && htmlName.isEmpty()) {
    N10N.warn(I18N.CONSTANTS.form_validation_ko());
    return;
  }
  final ElementTypeEnum type=EnumModel.getEnum(view.getTypeField().getValue());
  final LayoutGroupDTO group=view.getLayoutGroupField().getValue();
  final Integer order=ClientUtils.getInteger(view.getOrderField().getValue().intValue());
  final Boolean mandatory=view.getMandatoryField().getValue();
  final PrivacyGroupDTO privacyGroup=view.getPrivacyGroupField().getValue();
  final Boolean amendable=view.getAmendableField().getValue();
  final Boolean exportable=view.getExportableField().getValue();
  final Boolean banner=view.getBannerField().getValue();
  final Integer bannerPosition=ClientUtils.getSimpleValue(view.getBannerPositionField());
  final TextAreaType textAreaType=EnumModel.getEnum(view.getTextAreaTypeField().getValue());
  final Integer length=ClientUtils.getInteger(view.getLengthField().getValue());
  final Boolean decimal=view.getDecimalField().getValue();
  final Integer maxLimit=ClientUtils.getInteger(view.getMaxLimitField().getValue());
  final Integer minLimit=ClientUtils.getInteger(view.getMinLimitField().getValue());
  final Long minLimitDate=ClientUtils.getTimestamp(view.getMinDateField().getValue());
  final Long maxLimitDate=ClientUtils.getTimestamp(view.getMaxDateField().getValue());
  final ReportModelDTO reportModel=view.getReportModelField().getValue();
  final Boolean multiple=view.getMultipleChoicesField().getValue();
  final CategoryTypeDTO category=view.getCategoryTypeField().getValue();
  final Map<String,Object> newFieldProperties=new HashMap<String,Object>();
  newFieldProperties.put(AdminUtil.PROP_FX_NAME,htmlName);
  newFieldProperties.put(AdminUtil.PROP_FX_TYPE,(flexibleElement instanceof BudgetElementDTO) ? ElementTypeEnum.DEFAULT : type);
  newFieldProperties.put(AdminUtil.PROP_FX_GROUP,group);
  newFieldProperties.put(AdminUtil.PROP_FX_ORDER_IN_GROUP,order);
  newFieldProperties.put(AdminUtil.PROP_FX_IN_BANNER,banner);
  newFieldProperties.put(AdminUtil.PROP_FX_POS_IN_BANNER,bannerPosition);
  newFieldProperties.put(AdminUtil.PROP_FX_IS_COMPULSARY,mandatory);
  newFieldProperties.put(AdminUtil.PROP_FX_PRIVACY_GROUP,privacyGroup);
  newFieldProperties.put(AdminUtil.PROP_FX_AMENDABLE,amendable);
  newFieldProperties.put(AdminUtil.PROP_FX_EXPORTABLE,exportable);
  newFieldProperties.put(AdminUtil.PROP_FX_TEXT_TYPE,textAreaType != null ? textAreaType.getCode() : null);
  newFieldProperties.put(AdminUtil.PROP_FX_LENGTH,length);
  newFieldProperties.put(AdminUtil.PROP_FX_MAX_LIMIT,maxLimit);
  newFieldProperties.put(AdminUtil.PROP_FX_MIN_LIMIT,minLimit);
  if (textAreaType == TextAreaType.DATE) {
    newFieldProperties.put(AdminUtil.PROP_FX_MAX_LIMIT,maxLimitDate);
    newFieldProperties.put(AdminUtil.PROP_FX_MIN_LIMIT,minLimitDate);
  }
  if (type == ElementTypeEnum.TEXT_AREA && decimal != null) {
    newFieldProperties.put(AdminUtil.PROP_FX_DECIMAL,decimal);
  }
  newFieldProperties.put(AdminUtil.PROP_FX_REPORT_MODEL,reportModel);
  newFieldProperties.put(AdminUtil.PROP_FX_Q_MULTIPLE,multiple);
  if (category != null && !DEFAULT_CATEGORY_TYPE.equals(category)) {
    newFieldProperties.put(AdminUtil.PROP_FX_Q_CATEGORY,category);
  }
  if (ClientUtils.isNotEmpty(customChoices)) {
    newFieldProperties.put(AdminUtil.PROP_FX_Q_CHOICES,new ArrayList<String>(customChoices));
  }
  if (ClientUtils.isNotEmpty(disabledCustomChoices)) {
    newFieldProperties.put(AdminUtil.PROP_FX_Q_CHOICES_DISABLED,disabledCustomChoices);
  }
  List<BudgetSubFieldDTO> budgetSubFieldsToUpdate=new ArrayList<BudgetSubFieldDTO>();
  if (view.getBudgetFields().getRowCount() > 0) {
    for (int i=1; i < view.getBudgetFields().getRowCount(); i++) {
      if (view.getBudgetFields().getWidget(i,0) != null) {
        Object budgetFieldData=((Text)view.getBudgetFields().getWidget(i,0)).getData("String_Node_Str");
        if (budgetFieldData != null) {
          ((BudgetSubFieldDTO)budgetFieldData).setFieldOrder(i);
          budgetSubFieldsToUpdate.add((BudgetSubFieldDTO)budgetFieldData);
        }
      }
    }
    newFieldProperties.put(AdminUtil.PROP_FX_B_BUDGETSUBFIELDS,budgetSubFieldsToUpdate);
    newFieldProperties.put(AdminUtil.PROP_FX_B_BUDGET_RATIO_DIVIDEND,view.getUpBudgetSubFieldCombo().getValue());
    newFieldProperties.put(AdminUtil.PROP_FX_B_BUDGET_RATIO_DIVISOR,view.getDownBudgetSubFieldCombo().getValue());
  }
  final StringBuilder message=new StringBuilder();
  message.append("String_Node_Str");
  for (  Map.Entry<String,Object> newP : newFieldProperties.entrySet()) {
    message.append(newP.getKey()).append('=').append(newP.getValue()).append("String_Node_Str");
  }
  if (Log.isDebugEnabled()) {
    Log.debug(message.append(')').toString());
  }
  if (flexibleElement != null) {
    message.setLength(0);
    message.append("String_Node_Str");
    for (    final Entry<String,Object> old : oldFieldProperties.entrySet()) {
      message.append(old.getKey()).append('=').append(old.getValue()).append("String_Node_Str");
      if ((old.getValue() != null && old.getValue().equals(newFieldProperties.get(old.getKey()))) || (old.getValue() == null && newFieldProperties.get(old.getKey()) == null)) {
        newFieldProperties.remove(old.getKey());
      }
    }
    if (Log.isDebugEnabled()) {
      Log.debug(message.append(')').toString());
    }
  }
  message.setLength(0);
  message.append("String_Node_Str");
  for (  final Entry<String,Object> newP : newFieldProperties.entrySet()) {
    message.append(newP.getKey()).append('=').append(newP.getValue()).append("String_Node_Str");
  }
  if (Log.isDebugEnabled()) {
    Log.debug(message.append(')').toString());
  }
  if (newFieldProperties.get(AdminUtil.PROP_FX_ORDER_IN_GROUP) != null) {
    newFieldProperties.put(AdminUtil.PROP_FX_GROUP,group);
  }
  newFieldProperties.put(AdminUtil.PROP_FX_FLEXIBLE_ELEMENT,(flexibleElement != null) ? flexibleElement : new TextAreaElementDTO());
  newFieldProperties.put(AdminUtil.ADMIN_PROJECT_MODEL,currentModel);
  newFieldProperties.put(AdminUtil.ADMIN_ORG_UNIT_MODEL,currentModel);
  newFieldProperties.put(AdminUtil.PROP_FX_OLD_FIELDS,oldFieldProperties);
  dispatch.execute(new CreateEntity(currentModel.getEntityName(),newFieldProperties),new CommandResultHandler<CreateResult>(){
    @Override public void onCommandFailure(    final Throwable caught){
      N10N.error(I18N.CONSTANTS.adminFlexibleCreationBox(),I18N.MESSAGES.adminStandardCreationFailure(I18N.CONSTANTS.adminStandardFlexibleName() + "String_Node_Str" + htmlName+ "String_Node_Str"));
    }
    @Override public void onCommandSuccess(    final CreateResult result){
      if (result == null) {
        N10N.warn(I18N.CONSTANTS.adminFlexibleCreationBox(),I18N.MESSAGES.adminStandardCreationNull(I18N.CONSTANTS.adminStandardFlexibleName() + "String_Node_Str" + htmlName+ "String_Node_Str"));
        return;
      }
      final boolean update=flexibleElement != null;
      final IsModel updatedModel=(IsModel)result.getEntity();
      FlexibleElementDTO updatedOrCreatedFlexibleElement=null;
      if (update) {
        for (        final FlexibleElementDTO updatedFlexibleElement : updatedModel.getAllElements()) {
          if (updatedFlexibleElement.getId().equals(flexibleElement.getId())) {
            updatedOrCreatedFlexibleElement=updatedFlexibleElement;
          }
        }
        N10N.infoNotif(I18N.CONSTANTS.adminFlexibleCreationBox(),I18N.MESSAGES.adminStandardUpdateSuccess(I18N.CONSTANTS.adminStandardFlexibleName() + "String_Node_Str" + htmlName+ "String_Node_Str"));
      }
 else {
        final List<Integer> oldFlexibleIds=new ArrayList<Integer>();
        for (        final FlexibleElementDTO oldFlexibleElement : currentModel.getAllElements()) {
          oldFlexibleIds.add(oldFlexibleElement.getId());
        }
        for (        final FlexibleElementDTO newFlexibleElement : updatedModel.getAllElements()) {
          if (!oldFlexibleIds.contains(newFlexibleElement.getId())) {
            updatedOrCreatedFlexibleElement=newFlexibleElement;
          }
        }
        N10N.infoNotif(I18N.CONSTANTS.adminFlexibleCreationBox(),I18N.MESSAGES.adminStandardCreationSuccess(I18N.CONSTANTS.adminStandardFlexibleName() + "String_Node_Str" + htmlName+ "String_Node_Str"));
      }
      eventBus.fireEvent(new UpdateEvent(UpdateEvent.FLEXIBLE_ELEMENT_UPDATE,updatedModel,update,updatedOrCreatedFlexibleElement));
      hideView();
    }
  }
,view.getSaveButton());
}