예제 #1
0
  /**
   * Generate a sequenced club id using the prefix passed and a sequence value + check digit
   *
   * @param delegator used to obtain a sequenced value
   * @param prefix prefix inserted at the beginning of the ID
   * @param length total length of the ID including prefix and check digit
   * @return Sequenced Club ID string with a length as defined starting with the prefix defined
   */
  public static String createClubId(Delegator delegator, String prefix, int length) {
    final String clubSeqName = "PartyClubSeq";
    String clubId = prefix != null ? prefix : "";

    // generate the sequenced number and pad
    Long seq = delegator.getNextSeqIdLong(clubSeqName);
    clubId =
        clubId + UtilFormatOut.formatPaddedNumber(seq.longValue(), (length - clubId.length() - 1));

    // get the check digit
    int check = UtilValidate.getLuhnCheckDigit(clubId);
    clubId = clubId + Integer.toString(check);

    return clubId;
  }
예제 #2
0
  protected void applyLineToPackage(
      String shipmentId, GenericValue userLogin, LocalDispatcher dispatcher, int shipPackSeqId)
      throws GeneralException {
    String shipmentPackageSeqId = UtilFormatOut.formatPaddedNumber(shipPackSeqId, 5);

    Map<String, Object> packageMap = new HashMap<String, Object>();
    packageMap.put("shipmentId", shipmentId);
    packageMap.put("shipmentItemSeqId", this.getShipmentItemSeqId());
    // quanity given, by defult one because it is a required field
    packageMap.put("quantity", BigDecimal.ONE);
    packageMap.put("shipmentPackageSeqId", shipmentPackageSeqId);
    packageMap.put("userLogin", userLogin);
    Map<String, Object> packageResp = dispatcher.runSync("addShipmentContentToPackage", packageMap);

    if (ServiceUtil.isError(packageResp)) {
      throw new GeneralException(ServiceUtil.getErrorMessage(packageResp));
    }
  }