public void setParentLocation(StorageLocation parentLocation) { if (this.getLocationUnit() != LocationUnit.ROOM) { // rooms are at the top of the hierarchy so parentLocation should be null this.parentLocation = parentLocation; if (parentLocation.childLocations == null) { parentLocation.childLocations = new HashSet<>(); } parentLocation.childLocations.add(this); } }
/** Only freezers can have probes */ public void setProbeId(String probeId) { if (getLocationUnit() == null || getLocationUnit() != LocationUnit.FREEZER || isStringEmptyOrNull(probeId)) { this.probeId = null; } else { this.probeId = probeId; } }
@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 String getDisplayLocation() { return getLocationUnit().getDisplayName() + " " + getAlias(); }
@Override public long createRoom(StorageLocation room) throws IOException { if (room.getLocationUnit() != LocationUnit.ROOM) { throw new IllegalArgumentException("Location is not a room"); } room.setChangeDetails(authorizationManager.getCurrentUser()); if (room.getId() == StorageLocation.UNSAVED_ID) { return storageLocationStore.save(room); } else { throw new IllegalArgumentException("Can not yet update rooms"); } }
@Override public long saveFreezer(StorageLocation freezer) throws IOException { if (freezer.getLocationUnit() != LocationUnit.FREEZER) { throw new IllegalArgumentException("Location is not a freezer"); } loadChildEntities(freezer); if (freezer.getId() == StorageLocation.UNSAVED_ID) { return create(freezer); } else { return update(freezer); } }
public String getFreezerDisplayLocation() { return ((getParentLocation() == null || getParentLocation().getLocationUnit() == LocationUnit.FREEZER || getParentLocation().getLocationUnit() == LocationUnit.ROOM) ? "" : getParentLocation().getFreezerDisplayLocation() + ", ") + getDisplayLocation(); }
/** * Add a changelog entry to record a Box added to or removed from a StorageLocation * * @param location the StorageLocation that box was added to or removed from * @param box the Box that was added or removed * @param addition true for addition; false for removal * @throws IOException */ private void addStorageChangeLog(StorageLocation location, Box box, boolean addition) throws IOException { if (location.getLocationUnit() != LocationUnit.FREEZER) { throw new IllegalArgumentException(String.format("%s is not a freezer", location.getAlias())); } String message = addition ? String.format("Added %s (%s) to %s", box.getAlias(), box.getName(), box.getStorageLocation().getFreezerDisplayLocation()) : (String.format("Removed %s (%s)", box.getAlias(), box.getName())); ChangeLog change = location.createChangeLog(message, "", authorizationManager.getCurrentUser()); changeLogService.create(change); }
dto.setParentLocationId(from.getParentLocation().getId()); dto.setLocationUnit(from.getLocationUnit().name()); switch (from.getLocationUnit().getBoxStorageAmount()) { case NONE: dto.setAvailableStorage(false);
if (box.getStorageLocation().getLocationUnit().getBoxStorageAmount() == BoxStorageAmount.NONE) { errors.add(new ValidationError("storageLocation", "Invalid box location")); } else if (box.getStorageLocation().getLocationUnit().getBoxStorageAmount() == BoxStorageAmount.SINGLE) { if (beforeChange == null || beforeChange.getStorageLocation() == null || beforeChange.getStorageLocation().getId() != box.getStorageLocation().getId()) {