/**
   * @param torder
   * @param order
   * @param limit
   * @return
   * @throws Exception
   */
  public List getDepots(TransportOrderValue torder, OrderValue order, int limit) throws Exception {
    WaypointValue customerAddress = null;
    Address seaTerminalAddress = null;
    long carrierId;
    long container;
    boolean pickup;

    pickup = !order.getIsImportOrder();
    container = order.getContainerType().longValue();
    carrierId = order.getCarrierId();
    // get the needed customer address
    List waypoints = null;
    if (pickup) {
      waypoints = torder.getExportWaypoints();
    } else {
      waypoints = torder.getImportWaypoints();
    }

    log.debug("the length of waypoints: " + waypoints.size());
    if (order.getIsImportOrder()) {
      // last customer for import
      for (int i = waypoints.size() - 1; i >= 0; i--) {
        WaypointValue point = (WaypointValue) waypoints.get(i);
        if (point.getType().equalsIgnoreCase("Customer")) {
          customerAddress = point;
        } else if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_SEATERMINAL)) {
          seaTerminalAddress = point;
        }
      }
    } else {
      // fist customer for export
      for (int i = 0; i < waypoints.size(); i++) {
        WaypointValue point = (WaypointValue) waypoints.get(i);
        if (point.getType().equalsIgnoreCase("Customer")) {
          customerAddress = point;
        } else if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_SEATERMINAL)) {
          seaTerminalAddress = point;
        }
      }
    }

    Date fixedDate = customerAddress.getFixedDate();
    boolean isExtended = false;
    // VERSION_TOGGLE FRR.ExtendedDepots Start ----------
    if (ResourceUtil.getBoolean("FRR.ExtendedDepots")) {
      isExtended = true;
    }
    // VERSION_TOGGLE FRR.ExtendedDepots End ----------
    log.debug(
        "customer:"
            + customerAddress
            + " carrierId: "
            + carrierId
            + " container "
            + container
            + " pickup "
            + pickup);
    return getFacilityManager()
        .getDepots(
            customerAddress,
            seaTerminalAddress,
            carrierId,
            container,
            pickup,
            fixedDate,
            limit,
            isExtended);
  }
  /**
   * @param order
   * @param limit
   * @return
   * @throws Exception
   */
  public List getDepots(OrderValue order, int limit) throws Exception {
    log.debug("getDepots, order: " + order);
    WaypointValue customerAddress = null;
    WaypointValue seaTerminalAddress = null;
    long carrierId;
    long container;
    // long containerType;
    boolean pickup;

    pickup = !order.getIsImportOrder();
    container = order.getContainerType().longValue();
    carrierId = order.getCarrierId();
    // containerType = order.getContainerType().longValue();
    // get the needed customer address
    List waypoints = order.getWaypoints();
    log.info("Waypointcount: " + waypoints.size() + " limit: " + limit);

    // boolean isSpecial = false;
    // CarrierValue carrier =
    // (CarrierValue)CarrierService.getInstance().findByPrimaryKey(new
    // CarrierPK(new
    // Long(carrierId)));
    // long special = carrier.getHinterlandEquipmentChange();
    // isSpecial = (special&containerType)!=0;

    // if (!isSpecial){
    if (order.getIsImportOrder()) {
      // last customer for import
      for (int i = waypoints.size() - 1; i >= 0; i--) {
        WaypointValue point = (WaypointValue) waypoints.get(i);
        if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_CUSTOMER)) {
          customerAddress = point;
        } else if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_SEATERMINAL)) {
          seaTerminalAddress = point;
        }
      }
    } else {
      // fist customer for export
      for (int i = 0; i < waypoints.size(); i++) {
        WaypointValue point = (WaypointValue) waypoints.get(i);
        if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_CUSTOMER)) {
          customerAddress = point;
        } else if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_SEATERMINAL)) {
          seaTerminalAddress = point;
        }
      }
    }

    Date fixedDate = customerAddress.getFixedDate();
    boolean isExtended = false;
    // VERSION_TOGGLE FRR.ExtendedDepots Start ----------
    if (ResourceUtil.getBoolean("FRR.ExtendedDepots")) {
      isExtended = true;
    }
    // VERSION_TOGGLE FRR.ExtendedDepots End ----------

    return getFacilityManager()
        .getDepots(
            customerAddress,
            seaTerminalAddress,
            carrierId,
            container,
            pickup,
            fixedDate,
            limit,
            isExtended);
  }