Ejemplo n.º 1
0
  /** @return */
  private String[][] getAddressColumns(final int[] columnWidth) {

    String[][] columns;
    if (customer != null) {
      Address address;
      final String[] filter = getAddressFilter();
      final Collection<Business> list = AddressController.getAddresses(filter);
      columns = new String[list.size()][];
      final Iterator<Business> it = list.iterator();
      int i = 0;
      while (it.hasNext()) {
        address = (Address) it.next();
        columns[i] =
            new String[] {
              address.getIdAddress(),
              CodeController.getOneCodeDetail(CodeEnum.ADDRESS_TYPE.getType(), address.getAddType())
                  .getCodeDesc(),
              address.getAddStreet(),
              address.getAddNumber(),
              address.getAddBox(),
              address.getAddZip(),
              address.getAddCity(),
              CodeController.getOneCodeDetail(CodeEnum.COUNTRY.getType(), address.getAddCountry())
                  .getCodeDesc()
            };
        calculateColumnWidth(columns[i], columnWidth);

        i++;
      }
    } else {
      columns = null;
    }
    return columns;
  }
Ejemplo n.º 2
0
  /**
   * Handles input in the WaitingForPhoneNumber state.
   *
   * @param message The string message.
   * @param channel The channel from which the input was received.
   */
  private void handleWaitingForCustInfo(String message, NewOrderInChan channel) {

    // Only one channel to get input.
    switch ((NewOrderInChan) channel) {
      case ICMenuOption:
        // Do nothing
        break;

      case ICCustomerPhone:

        // Check if the string is a valid phone number.  If so, set
        // it as the new phone number.
        if (Customer.isValidPhoneNumber(message)) {

          _currentOrder.getCustomer().setPhoneNumber(message);
        }
        break;

      case ICCustomerName:

        // Set the new string as the name.
        _currentOrder.getCustomer().setName(message);
        break;

      case ICCustomerAddress:

        // Check that the address is valid.
        Address addr = Address.getAddressForAlias(message);
        if (null == addr) {

          // Do nothing.

        } else {

          _currentOrder.getCustomer().setStreetAddress(addr);

          // If we got a valid address, the customer should
          // be done being detailed.  Add this new customer
          // to the database and proceed to the order construction
          // state.
          Customer.getDb().add(_currentOrder.getCustomer());
          gotoDisplayingOrder();
        }
        break;

      case ICBack:

        // Check for a back button.
        if (message.equalsIgnoreCase(NewOrderView.BACK_KEY)) {

          // Go back to the customer phone number prompt.
          gotoWaitingForPhoneNumber();
        }
        break;

      default:
        handleInputError("The input was invalid. Please try again.");
        break;
    }
  }