use of uk.ac.bbsrc.tgac.miso.core.data.impl.StorageLocation in project miso-lims by miso-lims.
the class FreezerPageIT method testCreate.
@Test
public void testCreate() {
FreezerPage page1 = FreezerPage.getForCreate(getDriver(), getBaseUrl());
Map<FreezerPage.Field, String> fields = Maps.newLinkedHashMap();
fields.put(Field.ROOM, "Room One");
fields.put(Field.ALIAS, "New Freezer");
page1.setFields(fields);
FreezerPage page2 = page1.save();
long savedId = Long.parseLong(page2.getField(Field.ID));
StorageLocation saved = (StorageLocation) getSession().get(StorageLocation.class, savedId);
assertFreezerAttributes(fields, saved);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.StorageLocation in project miso-lims by miso-lims.
the class DefaultStorageLocationService method update.
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);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.StorageLocation in project miso-lims by miso-lims.
the class Dtos method to.
public static Box to(@Nonnull BoxDto from) {
Box to = new BoxImpl();
setLong(to::setId, from.getId(), false);
setString(to::setAlias, from.getAlias());
setString(to::setDescription, from.getDescription());
setString(to::setIdentificationBarcode, from.getIdentificationBarcode());
setString(to::setLocationBarcode, from.getLocationBarcode());
setObject(to::setUse, BoxUse::new, from.getUseId());
setObject(to::setSize, BoxSize::new, from.getSizeId());
setObject(to::setStorageLocation, StorageLocation::new, from.getStorageLocationId());
if (!isStringEmptyOrNull(from.getStorageLocationBarcode())) {
if (to.getStorageLocation() == null) {
to.setStorageLocation(new StorageLocation());
}
StorageLocation storageLocation = to.getStorageLocation();
setString(storageLocation::setIdentificationBarcode, from.getStorageLocationBarcode());
}
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.StorageLocation in project miso-lims by miso-lims.
the class StorageLocationRestController method addFreezerShelf.
@PostMapping(value = "/freezers/{id}/shelves")
@ResponseBody
public StorageLocationDto addFreezerShelf(@PathVariable(name = "id", required = true) long id, @RequestParam(name = "identificationBarcode", required = false) String barcode) throws IOException {
StorageLocation freezer = getFreezer(id);
int lastShelf = freezer.getChildLocations().stream().filter(loc -> loc.getLocationUnit() == LocationUnit.SHELF).map(StorageLocation::getAlias).mapToInt(Integer::parseInt).max().orElse(0);
StorageLocation shelf = new StorageLocation();
shelf.setAlias(Integer.toString(lastShelf + 1));
shelf.setLocationUnit(LocationUnit.SHELF);
shelf.setParentLocation(freezer);
if (!LimsUtils.isStringEmptyOrNull(barcode)) {
shelf.setIdentificationBarcode(barcode);
}
long savedId = storageLocationService.addFreezerStorage(shelf);
StorageLocation saved = storageLocationService.get(savedId);
return StorageLocationDto.from(saved, false, false);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.StorageLocation in project miso-lims by miso-lims.
the class StorageLocationRestController method createStack.
private StorageLocationDto createStack(StorageLocation parent, int height, String barcode, List<String> childBarcodes) throws IOException {
String stackNumber = findNextNumber(parent, LocationUnit.STACK);
StorageLocation stack = makeStorage(stackNumber, LocationUnit.STACK, parent, barcode);
for (int i = 1; i <= height; i++) {
makeStorage(Integer.toString(i), LocationUnit.STACK_POSITION, stack, childBarcodes.get(i - 1));
}
return doSave(stack);
}
Aggregations