/** * Checks submitted data for validity, throwing a ValidationException containing all of the errors if invalid * * @param storage submitted StorageLocation to validate * @param beforeChange the already-persisted StorageLocation before changes */ private void validateChange(StorageLocation storage, StorageLocation beforeChange) { List<ValidationError> errors = new ArrayList<>(); if (storage.getIdentificationBarcode() != null && (beforeChange == null || !storage.getIdentificationBarcode().equals(beforeChange.getIdentificationBarcode())) && storageLocationStore.getByBarcode(storage.getIdentificationBarcode()) != null) { errors.add(new ValidationError("identificationBarcode", String.format("There is already a storage location with this barcode (%s)", storage.getIdentificationBarcode()))); } validateLocationUnitRelationships(storage, errors); validateUrl(storage.getMapUrl(), true, errors); if (!errors.isEmpty()) { throw new ValidationException(errors); } }
private void applyChanges(StorageLocation from, StorageLocation to) { to.setAlias(from.getAlias()); to.setIdentificationBarcode(from.getIdentificationBarcode()); to.setParentLocation(from.getParentLocation()); to.setMapUrl(from.getMapUrl()); to.setProbeId(from.getProbeId()); }
dto.setIdentificationBarcode(from.getIdentificationBarcode()); dto.setDisplayLocation(from.getDisplayLocation()); dto.setFullDisplayLocation(from.getFullDisplayLocation());
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 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; }