private void loadChildEntities(StorageLocation storage) { if (storage.getParentLocation() != null && storage.getParentLocation().isSaved()) { storage.setParentLocation(get(storage.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 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)); } }
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; }