use of uk.ac.bbsrc.tgac.miso.core.data.Boxable in project miso-lims by miso-lims.
the class LimsUtils method generateAndSetIdBarcode.
/**
* Generates a unique barcode for a Nameable entity, and sets the identificationBarcode property for Boxables and LibraryAliquots.
*
* @param nameable Nameable object
* @throws IOException
*/
public static void generateAndSetIdBarcode(Nameable nameable) throws IOException {
String barcode = null;
if (nameable instanceof LibraryAliquot && nameable.getName() != null) {
barcode = nameable.getName();
if (((LibraryAliquot) nameable).getLibrary() != null && ((LibraryAliquot) nameable).getLibrary().getAlias() != null) {
barcode += "::" + ((LibraryAliquot) nameable).getLibrary().getAlias();
}
((LibraryAliquot) nameable).setIdentificationBarcode(barcode);
} else if (nameable instanceof Boxable && nameable.getName() != null) {
barcode = nameable.getName();
if (((Boxable) nameable).getAlias() != null) {
barcode += "::" + ((Boxable) nameable).getAlias();
}
((Boxable) nameable).setIdentificationBarcode(barcode);
} else {
throw new IOException("Error generating barcode");
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.Boxable in project miso-lims by miso-lims.
the class DefaultBoxService method discardSingleItem.
@Override
public void discardSingleItem(Box box, String position) throws IOException {
Box managed = boxStore.get(box.getId());
BoxPosition bp = managed.getBoxPositions().get(position);
if (bp == null) {
throw new IllegalArgumentException("No item in the specified box position");
}
Boxable target = boxStore.getBoxable(bp.getBoxableId());
addBoxContentsChangeLog(managed, String.format("Discarded %s (%s) from %s", target.getAlias(), target.getName(), target.getBoxPosition()));
discardBoxable(bp.getBoxableId());
managed.getBoxPositions().remove(position);
boxStore.save(managed);
}
use of uk.ac.bbsrc.tgac.miso.core.data.Boxable in project miso-lims by miso-lims.
the class DefaultBoxService method discardBoxable.
private void discardBoxable(BoxableId id) throws IOException {
Boxable target = boxStore.getBoxable(id);
discardBoxable(target);
}
use of uk.ac.bbsrc.tgac.miso.core.data.Boxable in project miso-lims by miso-lims.
the class HibernateBoxDaoIT method testGetBoxable.
@Test
public void testGetBoxable() throws IOException {
Boxable item = dao.getBoxable(new BoxableId(EntityType.SAMPLE, 15L));
assertNotNull(item);
assertEquals(EntityType.SAMPLE, item.getEntityType());
assertEquals(15L, item.getId());
}
use of uk.ac.bbsrc.tgac.miso.core.data.Boxable in project miso-lims by miso-lims.
the class HibernateBoxDaoIT method testSaveBoxable.
@Test
public void testSaveBoxable() throws IOException {
Boxable item = dao.getBoxable(new BoxableId(EntityType.SAMPLE, 15L));
assertFalse(item.isDiscarded());
item.setDiscarded(true);
dao.saveBoxable(item);
sessionFactory.getCurrentSession().flush();
sessionFactory.getCurrentSession().clear();
Boxable saved = dao.getBoxable(new BoxableId(EntityType.SAMPLE, 15L));
assertTrue(saved.isDiscarded());
}
Aggregations