Beispiel #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;
  }
Beispiel #2
0
  public static final AccountTypeDTO getDTO(AccountTypeWS ws, Integer entityId) {

    AccountTypeDTO accountTypeDTO = new AccountTypeDTO();
    if (ws.getId() != null && ws.getId() > 0) {
      accountTypeDTO.setId(ws.getId());
    }

    accountTypeDTO.setCompany(new CompanyDTO(entityId));

    accountTypeDTO.setCreditLimit(ws.getCreditLimitAsDecimal());
    accountTypeDTO.setCreditNotificationLimit1(ws.getCreditNotificationLimit1AsDecimal());
    accountTypeDTO.setCreditNotificationLimit2(ws.getCreditNotificationLimit2AsDecimal());
    accountTypeDTO.setInvoiceDesign(ws.getInvoiceDesign());
    accountTypeDTO.setBillingCycle(
        UserBL.convertMainSubscriptionFromWS(ws.getMainSubscription(), entityId));
    accountTypeDTO.setLanguage(new LanguageDAS().find(ws.getLanguageId()));
    accountTypeDTO.setCurrency(new CurrencyDAS().find(ws.getCurrencyId()));
    accountTypeDTO.setInvoiceDeliveryMethod(
        new InvoiceDeliveryMethodDTO(ws.getInvoiceDeliveryMethodId()));
    accountTypeDTO.setPreferredNotificationAitId(ws.getpreferredNotificationAitId());
    // set payment method types
    if (ws.getPaymentMethodTypeIds() != null) {
      Set<PaymentMethodTypeDTO> paymentMethodTypes = new HashSet<PaymentMethodTypeDTO>(0);
      PaymentMethodTypeDAS das = new PaymentMethodTypeDAS();

      for (Integer paymentMethodTypeId : ws.getPaymentMethodTypeIds()) {
        paymentMethodTypes.add(das.find(paymentMethodTypeId));
      }
      accountTypeDTO.setPaymentMethodTypes(paymentMethodTypes);
    }
    List<PaymentMethodTypeDTO> globalPaymentMethods =
        new PaymentMethodTypeDAS().findByAllAccountType(entityId);
    for (PaymentMethodTypeDTO globalPaymentMethod : globalPaymentMethods) {
      accountTypeDTO.getPaymentMethodTypes().add(globalPaymentMethod);
    }
    return accountTypeDTO;
  }