コード例 #1
0
  /*
   * Create a list of default broker commission based on a list of DTOs. The DTOs are based on data coming from the JSP
   */
  private List<DefaultBrokerCommission> dtoListToEntityList(
      final Member broker, final List<DefaultBrokerCommissionDTO> dtoList) {
    final List<DefaultBrokerCommission> defaultBrokerCommissions =
        new ArrayList<DefaultBrokerCommission>();
    for (final DefaultBrokerCommissionDTO dto : dtoList) {
      final Amount amount = new Amount();
      amount.setType(dto.getType());
      amount.setValue(dto.getValue());

      final DefaultBrokerCommission defaultBrokerCommission = new DefaultBrokerCommission();
      defaultBrokerCommission.setId(dto.getId());
      defaultBrokerCommission.setBrokerCommission(dto.getBrokerCommission());
      defaultBrokerCommission.setBroker(broker);
      defaultBrokerCommission.setAmount(amount);
      defaultBrokerCommission.setCount(dto.getCount());
      defaultBrokerCommission.setWhen(dto.getWhen());

      defaultBrokerCommissions.add(defaultBrokerCommission);
    }
    return defaultBrokerCommissions;
  }
コード例 #2
0
 /*
  * For each broker commission related to the broker group, get the current default broker commission, or create a new one, if it does not exist.
  */
 private List<DefaultBrokerCommission> buildCommissions(
     final List<BrokerCommission> groupCommissions,
     final List<DefaultBrokerCommission> currentDefaults) {
   final List<DefaultBrokerCommission> defaultBrokerCommissions =
       new ArrayList<DefaultBrokerCommission>();
   for (final BrokerCommission groupCommission : groupCommissions) {
     DefaultBrokerCommission defaultBrokerCommission = null;
     for (final DefaultBrokerCommission currentDefault : currentDefaults) {
       if (currentDefault.getBrokerCommission().equals(groupCommission)) {
         defaultBrokerCommission = currentDefault;
         break;
       }
     }
     if (defaultBrokerCommission == null) {
       defaultBrokerCommission = new DefaultBrokerCommission();
       defaultBrokerCommission.setBrokerCommission(groupCommission);
       defaultBrokerCommission.setAmount(groupCommission.getAmount());
       defaultBrokerCommission.setWhen(groupCommission.getWhen());
       defaultBrokerCommission.setCount(groupCommission.getCount());
     }
     defaultBrokerCommissions.add(defaultBrokerCommission);
   }
   return defaultBrokerCommissions;
 }