use of uk.ac.bbsrc.tgac.miso.core.data.BoxUse 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.BoxUse in project miso-lims by miso-lims.
the class ListBoxesController method listBoxes.
@RequestMapping("/boxes")
public ModelAndView listBoxes(ModelMap model) throws Exception {
List<BoxUse> uses = boxUseService.list();
BoxUse all = new BoxUse();
all.setAlias(ALL_TAB);
uses.add(0, all);
return new TabbedListBoxPage("box", "boxUse", uses.stream(), TAB_SORTER, BoxUse::getAlias, BoxUse::getId).list(model);
}
use of uk.ac.bbsrc.tgac.miso.core.data.BoxUse in project miso-lims by miso-lims.
the class HibernateBoxUseDaoIT method testUpdate.
@Test
public void testUpdate() throws IOException {
long id = 1L;
String alias = "New Alias";
BoxUse boxUse = (BoxUse) getSessionFactory().getCurrentSession().get(BoxUse.class, id);
assertNotEquals(alias, boxUse.getAlias());
boxUse.setAlias(alias);
sut.update(boxUse);
clearSession();
BoxUse saved = (BoxUse) getSessionFactory().getCurrentSession().get(BoxUse.class, id);
assertEquals(alias, saved.getAlias());
}
use of uk.ac.bbsrc.tgac.miso.core.data.BoxUse in project miso-lims by miso-lims.
the class HibernateBoxDaoIT method testSave.
@Test
public void testSave() throws Exception {
Box box = new BoxImpl();
UserImpl user = new UserImpl();
user.setId(1l);
Date now = new Date();
box.setCreator(user);
box.setCreationTime(now);
box.setLastModifier(user);
box.setLastModified(now);
box.setDescription("newboxdescription");
box.setAlias("newboxalias");
box.setName("newbox");
box.setLocationBarcode("newlocationbarcode");
BoxSize boxSize = new BoxSize();
boxSize.setColumns(2);
boxSize.setRows(3);
boxSize.setId(1l);
box.setSize(boxSize);
BoxUse boxuse = (BoxUse) sessionFactory.getCurrentSession().get(BoxUse.class, 1L);
box.setUse(boxuse);
long boxId = dao.save(box);
Box retrieved = dao.get(boxId);
assertEquals(box.getDescription(), retrieved.getDescription());
assertEquals(box.getAlias(), retrieved.getAlias());
assertEquals(box.getSize().getId(), retrieved.getSize().getId());
assertEquals(box.getName(), retrieved.getName());
}
use of uk.ac.bbsrc.tgac.miso.core.data.BoxUse in project miso-lims by miso-lims.
the class DefaultBoxUseService method update.
@Override
public long update(BoxUse boxUse) throws IOException {
authorizationManager.throwIfNonAdmin();
BoxUse managed = get(boxUse.getId());
validateChange(boxUse, managed);
applyChanges(managed, boxUse);
return boxUseDao.update(managed);
}
Aggregations