コード例 #1
0
  @Override
  protected ActionForward handleSubmit(final ActionContext context) throws Exception {
    final SendInvoiceForm form = context.getForm();
    final boolean fromProfile = !form.isToSystem() && !form.isSelectMember();

    try {
      final Invoice invoice = invoiceService.send(resolveInvoice(context));
      context.sendMessage("invoice.sent");
      ActionForward forward = null;
      final Map<String, Object> params = new HashMap<String, Object>();
      if (fromProfile) {
        forward = context.findForward("profile");
        params.put("memberId", invoice.getToMember().getId());
      } else {
        forward = context.findForward("newInvoice");
      }
      final Member fromMember = invoice.getFromMember();
      if (fromMember != null && !fromMember.equals(context.getMember())) {
        // From another member
        params.put("from", form.getFrom());
      } else if (fromProfile) {
        params.put("to", form.getTo());
      }
      if (form.isToSystem()) {
        params.put("toSystem", true);
      } else if (form.isSelectMember()) {
        params.put("selectMember", true);
      }
      return ActionHelper.redirectWithParams(context.getRequest(), forward, params);
    } catch (final SendingInvoiceWithMultipleTransferTypesWithCustomFields e) {
      return context.sendError("invoice.error.sendingWithMultipleTransferTypesWithCustomFields");
    }
  }
コード例 #2
0
 @Override
 protected ActionForward handleSubmit(final ActionContext context) throws Exception {
   final EditCreditLimitForm form = context.getForm();
   final CreditLimitDTO creditLimit = getDataBinder().readFromString(form);
   accountService.setCreditLimit(getMember(form), creditLimit);
   context.sendMessage("creditLimit.modified");
   return ActionHelper.redirectWithParam(
       context.getRequest(), context.getSuccessForward(), "memberId", form.getMemberId());
 }
コード例 #3
0
 @Override
 protected ActionForward executeAction(final ActionContext context) throws Exception {
   final EditCardTypeForm form = context.getForm();
   try {
     cardTypeService.remove(form.getCardTypeId());
     context.sendMessage("cardType.removed");
   } catch (final Exception e) {
     context.sendMessage("cardType.error.removing");
   }
   return ActionHelper.redirectWithParam(
       context.getRequest(), context.getSuccessForward(), "cardTypeId", form.getCardTypeId());
   // return context.findForward("success");
 }
コード例 #4
0
  @Override
  protected ActionForward handleSubmit(final ActionContext context) throws Exception {
    final EditCustomFieldPossibleValueForm form = context.getForm();
    final Collection<CustomFieldPossibleValue> resolveAllValues = resolveAllValues(context);
    Boolean isInsert = null;
    CustomField field = null;
    CustomFieldPossibleValue parentValue = null;
    Nature nature = getNature(form);
    final BaseCustomFieldService<CustomField> service = resolveService(nature);
    try {
      for (final CustomFieldPossibleValue possibleValue : resolveAllValues) {
        if (isInsert == null) {
          isInsert = possibleValue.getId() == null;
          field = service.load(possibleValue.getField().getId());
          parentValue = possibleValue.getParent();
        }
        service.save(possibleValue);
      }
      context.sendMessage(
          isInsert ? "customField.possibleValue.inserted" : "customField.possibleValue.modified");

      final Map<String, Object> params = new HashMap<String, Object>();
      params.put("nature", nature);
      params.put("fieldId", field.getId());

      switch (field.getNature()) {
        case MEMBER_RECORD:
          final MemberRecordCustomField memberRecordField = (MemberRecordCustomField) field;
          final Long memberRecordTypeId = memberRecordField.getMemberRecordType().getId();
          params.put("memberRecordTypeId", memberRecordTypeId);
          break;
        case PAYMENT:
          final PaymentCustomField paymentField = (PaymentCustomField) field;
          final TransferType transferType = paymentField.getTransferType();
          params.put("transferTypeId", transferType.getId());
          params.put("accountTypeId", transferType.getFrom().getId());
          break;
      }

      if (parentValue != null) {
        params.put("parentValueId", parentValue.getId());
      }
      return ActionHelper.redirectWithParams(
          context.getRequest(), context.getSuccessForward(), params);
    } catch (final DaoException e) {
      return context.sendError("customField.possibleValue.error.saving");
    }
  }
コード例 #5
0
  @Override
  protected ActionForward executeAction(final ActionContext context) throws Exception {
    final RemoveCustomFieldPossibleValueForm form = context.getForm();
    final long id = form.getPossibleValueId();
    if (id <= 0) {
      throw new ValidationException();
    }
    final Nature nature = getNature(form);
    final Map<String, Object> params = new HashMap<String, Object>();
    String key;
    try {
      final BaseCustomFieldService<CustomField> service = resolveService(nature);
      final CustomFieldPossibleValue possibleValue = service.loadPossibleValue(id);
      final CustomField customField = possibleValue.getField();
      switch (customField.getNature()) {
        case PAYMENT:
          final PaymentCustomField paymentField = (PaymentCustomField) customField;
          params.put("transferTypeId", paymentField.getTransferType().getId());
          break;
        case MEMBER_RECORD:
          final MemberRecordCustomField memberRecordField = (MemberRecordCustomField) customField;
          params.put("memberRecordTypeId", memberRecordField.getMemberRecordType().getId());
        default:
          service.removePossibleValue(id);
          break;
      }
      key = "customField.possibleValue.removed";
    } catch (final DaoException e) {
      key = "customField.possibleValue.error.removing";
    }
    params.put("fieldId", form.getFieldId());
    params.put("nature", nature);
    context.sendMessage(key);

    return ActionHelper.redirectWithParams(
        context.getRequest(), context.getSuccessForward(), params);
  }
コード例 #6
0
  @Override
  protected ActionForward handleSubmit(final ActionContext context) throws Exception {
    Transfer transfer = resolveTransfer(context);

    // Validate the transaction password if needed
    if (shouldValidateTransactionPassword(context, transfer)) {
      final ScheduledPaymentForm form = context.getForm();
      context.checkTransactionPassword(form.getTransactionPassword());
    }

    // Perform the actual payment
    try {
      transfer = scheduledPaymentService.processTransfer(transfer);
    } catch (final CreditsException e) {
      return context.sendError(actionHelper.resolveErrorKey(e), actionHelper.resolveParameters(e));
    } catch (final UnexpectedEntityException e) {
      return context.sendError("payment.error.invalidTransferType");
    }
    return ActionHelper.redirectWithParam(
        context.getRequest(),
        context.getSuccessForward(),
        "paymentId",
        transfer.getScheduledPayment().getId());
  }