Search in sources :

Example 1 with Boxable

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");
    }
}
Also used : Boxable(uk.ac.bbsrc.tgac.miso.core.data.Boxable) DetailedLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedLibraryAliquot) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) IOException(java.io.IOException)

Example 2 with Boxable

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);
}
Also used : Boxable(uk.ac.bbsrc.tgac.miso.core.data.Boxable) Box(uk.ac.bbsrc.tgac.miso.core.data.Box) BoxPosition(uk.ac.bbsrc.tgac.miso.core.data.BoxPosition)

Example 3 with Boxable

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);
}
Also used : Boxable(uk.ac.bbsrc.tgac.miso.core.data.Boxable)

Example 4 with Boxable

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());
}
Also used : BoxableId(uk.ac.bbsrc.tgac.miso.core.data.BoxableId) Boxable(uk.ac.bbsrc.tgac.miso.core.data.Boxable) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Example 5 with Boxable

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());
}
Also used : BoxableId(uk.ac.bbsrc.tgac.miso.core.data.BoxableId) Boxable(uk.ac.bbsrc.tgac.miso.core.data.Boxable) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Aggregations

Boxable (uk.ac.bbsrc.tgac.miso.core.data.Boxable)8 Box (uk.ac.bbsrc.tgac.miso.core.data.Box)4 BoxableId (uk.ac.bbsrc.tgac.miso.core.data.BoxableId)4 IOException (java.io.IOException)3 BoxPosition (uk.ac.bbsrc.tgac.miso.core.data.BoxPosition)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 List (java.util.List)2 Set (java.util.Set)2 Consumer (java.util.function.Consumer)2 Test (org.junit.Test)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Service (org.springframework.stereotype.Service)2 Transactional (org.springframework.transaction.annotation.Transactional)2 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)2 AuthorizationManager (uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager)2 BoxService (uk.ac.bbsrc.tgac.miso.core.service.BoxService)2 ChangeLogService (uk.ac.bbsrc.tgac.miso.core.service.ChangeLogService)2 ValidationError (uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError)2 ValidationException (uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException)2