Пример #1
0
  public static final AccountTypeWS getWS(
      Integer id,
      Integer entityId,
      String invoiceDesign,
      Date dateCreated,
      BigDecimal creditNotificationLimit1,
      BigDecimal creditNotificationLimit2,
      BigDecimal creditLimit,
      InvoiceDeliveryMethodDTO invoiceDeliveryMethod,
      Integer currencyId,
      Integer languageId,
      String description,
      MainSubscriptionWS mainSubscription,
      Set<AccountInformationTypeDTO> informationTypes,
      Set<PaymentMethodTypeDTO> paymentMethodTypes,
      Integer preferredNotificationAitId) {

    AccountTypeWS ws = new AccountTypeWS();
    ws.setId(id);
    ws.setEntityId(entityId);
    ws.setInvoiceDesign(invoiceDesign);
    ws.setDateCreated(dateCreated);
    ws.setCreditNotificationLimit1(
        creditNotificationLimit1 != null ? creditNotificationLimit1.toString() : null);
    ws.setCreditNotificationLimit2(
        creditNotificationLimit2 != null ? creditNotificationLimit2.toString() : null);
    ws.setCreditLimit(creditLimit != null ? creditLimit.toString() : null);
    ws.setInvoiceDeliveryMethodId(
        invoiceDeliveryMethod != null ? invoiceDeliveryMethod.getId() : null);
    ws.setCurrencyId(currencyId);
    ws.setLanguageId(languageId);
    ws.setMainSubscription(mainSubscription);

    if (description != null) {
      ws.setName(description, Constants.LANGUAGE_ENGLISH_ID);
    }

    if (null != informationTypes && informationTypes.size() > 0) {
      List<Integer> informationTypeIds = new ArrayList<Integer>();
      for (AccountInformationTypeDTO ait : informationTypes) {
        informationTypeIds.add(ait.getId());
      }
      if (!informationTypeIds.isEmpty()) {
        ws.setInformationTypeIds(
            informationTypeIds.toArray(new Integer[informationTypeIds.size()]));
      }
    }

    if (null != paymentMethodTypes && paymentMethodTypes.size() > 0) {
      List<Integer> paymentMethodTypeIds = new ArrayList<Integer>(0);
      for (PaymentMethodTypeDTO paymentMethodType : paymentMethodTypes) {
        paymentMethodTypeIds.add(paymentMethodType.getId());
      }
      ws.setPaymentMethodTypeIds(
          paymentMethodTypeIds.toArray(new Integer[paymentMethodTypeIds.size()]));
    }

    ws.setpreferredNotificationAitId(preferredNotificationAitId);
    return ws;
  }
Пример #2
0
  public boolean isAccountTypeUnique(Integer entityId, String name, boolean isNew) {

    List<AccountTypeDTO> accountTypeDTOList = new AccountTypeDAS().findAll(entityId);
    List<String> descriptionList = new ArrayList<String>();
    for (AccountTypeDTO accountType1 : accountTypeDTOList) {

      descriptionList.add(accountType1.getDescription());
    }

    if (isNew) {
      return !descriptionList.contains(name);
    } else {
      return Collections.frequency(descriptionList, name) < 2;
    }
  }