use of uk.ac.bbsrc.tgac.miso.core.data.BoxSize in project miso-lims by miso-lims.
the class Dtos method to.
public static BoxSize to(@Nonnull BoxSizeDto from) {
BoxSize to = new BoxSize();
setLong(to::setId, from.getId(), false);
setInteger(to::setRows, from.getRows(), true);
setInteger(to::setColumns, from.getColumns(), true);
setBoolean(to::setScannable, from.isScannable(), false);
setObject(to::setBoxType, from.getBoxType(), BoxType::valueOf);
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.BoxSize 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.BoxSize in project miso-lims by miso-lims.
the class DefaultBoxSizeService method validateChange.
private void validateChange(BoxSize boxSize, BoxSize beforeChange) throws IOException {
List<ValidationError> errors = new ArrayList<>();
long usage = 0L;
if (beforeChange != null) {
usage = boxSizeDao.getUsage(beforeChange);
}
if (usage > 0L) {
if (ValidationUtils.isSetAndChanged(BoxSize::getRows, boxSize, beforeChange)) {
errors.add(new ValidationError("rows", "Cannot resize because box size is already used by " + usage + " " + Pluralizer.boxes(usage)));
}
if (ValidationUtils.isSetAndChanged(BoxSize::getColumns, boxSize, beforeChange)) {
errors.add(new ValidationError("columns", "Cannot resize because box size is already used by " + usage + " " + Pluralizer.boxes(usage)));
}
}
if (!errors.isEmpty()) {
throw new ValidationException(errors);
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.BoxSize in project miso-lims by miso-lims.
the class DefaultBoxSizeService method update.
@Override
public long update(BoxSize boxSize) throws IOException {
authorizationManager.throwIfNonAdmin();
BoxSize managed = get(boxSize.getId());
validateChange(boxSize, managed);
applyChanges(managed, boxSize);
return boxSizeDao.update(managed);
}
use of uk.ac.bbsrc.tgac.miso.core.data.BoxSize in project miso-lims by miso-lims.
the class HibernateBoxSizeDaoIT method testGet.
@Test
public void testGet() throws IOException {
long id = 1L;
BoxSize stain = sut.get(id);
assertNotNull(stain);
assertEquals(id, stain.getId());
}
Aggregations