private void applyChanges(Box from, Box to) throws IOException { to.setAlias(from.getAlias()); to.setDescription(from.getDescription()); to.setIdentificationBarcode(LimsUtils.nullifyStringIfBlank(from.getIdentificationBarcode())); to.setLocationBarcode(from.getLocationBarcode()); to.setUse(boxStore.getUseById(from.getUse().getId())); to.setStorageLocation(from.getStorageLocation()); }
private void loadChildEntities(Box box) throws IOException { if (box.getSize() != null) { box.setSize(getSize(box.getSize().getId())); } box.setUse(getUse(box.getUse().getId())); if (box.getStorageLocation() != null) { if (box.getStorageLocation().getId() > 0L) { box.setStorageLocation(storageLocationService.get(box.getStorageLocation().getId())); } else if (!LimsUtils.isStringEmptyOrNull(box.getStorageLocation().getIdentificationBarcode())) { box.setStorageLocation(storageLocationService.getByBarcode(box.getStorageLocation().getIdentificationBarcode())); } } }
public static Box to(@Nonnull BoxDto from) { Box to = new BoxImpl(); if (from.getId() != null) to.setId(from.getId()); to.setAlias(from.getAlias()); to.setDescription(from.getDescription()); to.setIdentificationBarcode(from.getIdentificationBarcode()); to.setLocationBarcode(from.getLocationBarcode() == null ? "" : from.getLocationBarcode()); if (from.getUseId() != null) { BoxUse use = new BoxUse(); use.setId(from.getUseId()); to.setUse(use); } if (from.getSizeId() != null) { BoxSize size = new BoxSize(); size.setId(from.getSizeId()); to.setSize(size); } if (from.getStorageLocationId() != null) { to.setStorageLocation(new StorageLocation()); to.getStorageLocation().setId(from.getStorageLocationId()); } if (!isStringEmptyOrNull(from.getStorageLocationBarcode())) { if (to.getStorageLocation() == null) { to.setStorageLocation(new StorageLocation()); } to.getStorageLocation().setIdentificationBarcode(from.getStorageLocationBarcode()); } return to; }