public TrackingStatusDTO mapFrom(TrackingStatus trackingStatus) { TrackingStatusDTO dto = new TrackingStatusDTO(); dto.setTrackerId(trackingStatus.getTrackerId()); dto.setPackageId(trackingStatus.getPackageId()); dto.setTrackingNumber(trackingStatus.getTrackingNumber()); dto.setWeight(trackingStatus.getWeight()); dto.setEstimatedDeliveryDate(trackingStatus.getEstimatedDeliveryDate()); dto.setCarrier(trackingStatus.getCarrier()); dto.setUpdated(trackingStatus.getUpdated()); dto.setStatus(trackingStatus.getStatus()); dto.setCreated(trackingStatus.getCreated()); dto.setShippingMethod(trackingStatus.getShippingMethod()); if (hasHistory) { dto.setTrackingHistories( trackingStatus .getTrackingHistories() .stream() .map(TrackingHistoryDTO::new) .collect(toList())); } return dto; }
public static TrackingStatus toHibernate(TrackingStatusDTO trackingStatusDTO) { TrackingStatus trackingStatus = new TrackingStatus(); trackingStatus.setTrackerId(trackingStatusDTO.getTrackerId()); trackingStatus.setPackageId(trackingStatusDTO.getPackageId()); trackingStatus.setTrackingNumber(trackingStatusDTO.getTrackingNumber()); trackingStatus.setWeight(trackingStatusDTO.getWeight()); trackingStatus.setEstimatedDeliveryDate(trackingStatusDTO.getEstimatedDeliveryDate()); trackingStatus.setCarrier(trackingStatusDTO.getCarrier()); trackingStatus.setUpdated(trackingStatusDTO.getUpdated()); trackingStatus.setStatus(trackingStatusDTO.getStatus()); trackingStatus.setCreated(trackingStatusDTO.getCreated()); trackingStatus.setShippingMethod(trackingStatusDTO.getShippingMethod()); return trackingStatus; }