public static BoxDto asDto(@Nonnull Box from, boolean includePositions) { BoxDto dto = new BoxDto(); dto.setId(from.getId()); dto.setName(from.getName()); dto.setAlias(from.getAlias()); dto.setDescription(from.getDescription()); dto.setIdentificationBarcode(from.getIdentificationBarcode()); dto.setLocationBarcode(from.getLocationBarcode()); if (from.getUse() != null) { dto.setUseId(from.getUse().getId()); dto.setUseAlias(from.getUse().getAlias()); } if (from.getSize() != null) { dto.setSizeId(from.getSize().getId()); dto.setRows(from.getSize().getRows()); dto.setCols(from.getSize().getColumns()); dto.setScannable(from.getSize().getScannable()); } if (includePositions) { dto.setItems(from.getBoxPositions().values().stream().map(Dtos::asDto).collect(Collectors.toList())); } if (from.getStorageLocation() != null) { dto.setStorageLocationId(from.getStorageLocation().getId()); dto.setStorageLocationBarcode(from.getStorageLocation().getIdentificationBarcode()); dto.setFreezerDisplayLocation(from.getStorageLocation().getFreezerDisplayLocation()); dto.setStorageDisplayLocation(from.getStorageLocation().getFullDisplayLocation()); } dto.setTubeCount(from.getTubeCount()); return dto; }
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())); } } }