public StorageLocation getFreezerLocation() { if (locationUnit == LocationUnit.FREEZER) { return this; } else if (getParentLocation() == null || locationUnit == LocationUnit.ROOM) { return null; } return getParentLocation().getFreezerLocation(); }
public String getFreezerDisplayLocation() { return ((getParentLocation() == null || getParentLocation().getLocationUnit() == LocationUnit.FREEZER || getParentLocation().getLocationUnit() == LocationUnit.ROOM) ? "" : getParentLocation().getFreezerDisplayLocation() + ", ") + getDisplayLocation(); }
public String getFullDisplayLocation() { return (getParentLocation() == null ? "" : getParentLocation().getFullDisplayLocation() + ", ") + getDisplayLocation(); }
private void loadChildEntities(StorageLocation storage) { if (storage.getParentLocation() != null && storage.getParentLocation().isSaved()) { storage.setParentLocation(get(storage.getParentLocation().getId())); } }
private void createParentIfNecessary(StorageLocation freezer) throws IOException { if (freezer.getParentLocation() != null && !freezer.getParentLocation().isSaved()) { freezer.getParentLocation().setChangeDetails(authorizationManager.getCurrentUser()); long parentId = storageLocationStore.save(freezer.getParentLocation()); freezer.setParentLocation(storageLocationStore.get(parentId)); } }
@Override public StorageLocation getFreezerForBarcodedStorageLocation(String barcode) { for (StorageLocation current = getByBarcode(barcode); current != null; current = current.getParentLocation()) { if (current.getLocationUnit() == LocationUnit.FREEZER) { return current; } } return null; }
private void validateLocationUnitRelationships(StorageLocation storage, List<ValidationError> errors) { if (storage.getParentLocation() != null && !storage.getLocationUnit().getAcceptableParents().contains(storage.getParentLocation().getLocationUnit())) { errors.add(new ValidationError(String.format("%s is not an appropriate container for %s", storage.getParentLocation().getLocationUnit().getDisplayName(), storage.getLocationUnit().getDisplayName()))); for (StorageLocation child : storage.getChildLocations()) { validateLocationUnitRelationships(child, errors); } } }
public static StorageLocationDto asDto(@Nonnull StorageLocation from, boolean includeChildLocations, boolean recursive) { StorageLocationDto dto = new StorageLocationDto(); dto.setId(from.getId()); if (from.getParentLocation() != null) { dto.setParentLocationId(from.getParentLocation().getId());
private long create(StorageLocation location) throws IOException { location.setParentLocation(storageLocationStore.get(location.getParentLocation().getId())); validateChange(location, null); createParentIfNecessary(location); location.setChangeDetails(authorizationManager.getCurrentUser()); return storageLocationStore.save(location); }
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()); }
private long update(StorageLocation location) throws IOException { StorageLocation managed = get(location.getId()); location.setParentLocation(storageLocationStore.get(location.getParentLocation().getId())); validateChange(location, managed); createParentIfNecessary(location); applyChanges(location, managed); managed.setChangeDetails(authorizationManager.getCurrentUser()); return storageLocationStore.save(managed); }
public static StorageLocation to(@Nonnull StorageLocationDto from) { StorageLocation location = new StorageLocation(); location.setId(from.getId()); location.setAlias(from.getAlias()); if (!LimsUtils.isStringEmptyOrNull(from.getIdentificationBarcode())) { location.setIdentificationBarcode(from.getIdentificationBarcode()); } if (!LimsUtils.isStringEmptyOrNull(from.getMapUrl())) { location.setMapUrl(from.getMapUrl()); } if (from.getParentLocationId() != null) { location.setParentLocation(new StorageLocation()); location.getParentLocation().setId(from.getParentLocationId()); } location.setLocationUnit(LocationUnit.valueOf(from.getLocationUnit())); location.setProbeId(from.getProbeId()); return location; }