private void setOptionalFields( ShipmentLineItem lineItem, ShipmentLineItemDTO dto, String packedDateFormat, String shippedDateFormat, Date creationDate) throws ParseException { if (!isBlank(dto.getCost())) { BigDecimal cost = new BigDecimal(dto.getCost().trim()); if (cost.compareTo(new BigDecimal(0)) == -1) { throw new DataException("error.cost.negative"); } lineItem.setCost(cost); } if (!isBlank(dto.getReplacedProductCode())) { lineItem.setReplacedProductCode(dto.getReplacedProductCode().trim()); } Date packedDate = (!isBlank(dto.getPackedDate())) ? parseDate(packedDateFormat, dto.getPackedDate().trim()) : creationDate; lineItem.setPackedDate(packedDate); if (!isBlank(dto.getShippedDate())) { lineItem.setShippedDate(parseDate(shippedDateFormat, dto.getShippedDate().trim())); } }
private void setMandatoryFields( ShipmentLineItem lineItem, ShipmentLineItemDTO shipmentLineItemDTO) { lineItem.setProductCode(shipmentLineItemDTO.getProductCode().trim()); lineItem.setOrderId(shipmentLineItemDTO.getOrderId()); lineItem.setOrderNumber(shipmentLineItemDTO.getOrderNumber()); String quantityShipped = shipmentLineItemDTO.getQuantityShipped().trim(); if (quantityShipped.length() > 8) { throw new DataException("invalid.quantity.shipped"); } lineItem.setQuantityShipped(Integer.valueOf(quantityShipped)); }