@Override public Object transform(final Object at) { final AccountType accountType = (AccountType) at; final Map<String, Object> map = new HashMap<String, Object>(); final TransferTypeQuery ttQuery = new TransferTypeQuery(); ttQuery.setPageForCount(); ttQuery.setContext(TransactionContext.PAYMENT); ttQuery.setFromOwner(from); ttQuery.setToOwner(to); ttQuery.setToAccountType(accountType); ttQuery.setSchedulable(true); if (from instanceof Member) { final Member member = elementService.load(((Member) from).getId(), Element.Relationships.GROUP); ttQuery.setGroup(member.getGroup()); } final int count = PageHelper.getTotalCount(transferTypeService.search(ttQuery)); map.put("id", accountType.getId()); map.put("name", accountType.getName()); map.put("currency", accountType.getCurrency()); map.put("allowsScheduledPayments", count > 0); return map; }
@SuppressWarnings("unchecked") @Override protected void prepareForm(final ActionContext context) throws Exception { final HttpServletRequest request = context.getRequest(); if (!context.isBroker()) { throw new ValidationException(); } final Member broker = (Member) context.getElement(); final BrokerGroup brokerGroup = (BrokerGroup) broker.getGroup(); // Get broker commission transaction fees (from member) related to the broker group, including // the not enabled ones final TransactionFeeQuery transactionFeeQuery = new TransactionFeeQuery(); transactionFeeQuery.setEntityType(BrokerCommission.class); transactionFeeQuery.setGeneratedTransferTypeFromNature(AccountType.Nature.MEMBER); transactionFeeQuery.setBrokerGroup(brokerGroup); transactionFeeQuery.setReturnDisabled(true); final List<BrokerCommission> groupCommissions = (List<BrokerCommission>) transactionFeeService.search(transactionFeeQuery); // Get current default broker commissions final List<DefaultBrokerCommission> currentDefaults = commissionService.loadDefaultBrokerCommissions( broker, DefaultBrokerCommission.Relationships.BROKER_COMMISSION); // Prepare list to JSP final List<DefaultBrokerCommission> defaultBrokerCommissions = buildCommissions(groupCommissions, currentDefaults); request.setAttribute("broker", broker); request.setAttribute("defaultBrokerCommissions", defaultBrokerCommissions); RequestHelper.storeEnum(request, BrokerCommission.When.class, "whens"); RequestHelper.storeEnum(request, Amount.Type.class, "amountTypes"); }