Search in sources :

Example 1 with InstrumentStatus

use of uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatus in project miso-lims by miso-lims.

the class HibernateInstrumentStatusDao method list.

@Override
public List<InstrumentStatus> list() throws IOException {
    @SuppressWarnings("unchecked") List<InstrumentStatus> instruments = currentSession().createCriteria(InstrumentStatus.class).list();
    for (InstrumentStatus instrument : instruments) {
        for (InstrumentStatusPosition position : instrument.getPositions()) {
            InstrumentStatusPositionRun run = (InstrumentStatusPositionRun) currentSession().createCriteria(InstrumentStatusPositionRun.class).add(Restrictions.eq("instrumentId", instrument.getId())).add(Restrictions.eq("positionId", position.getPositionId())).setMaxResults(1).uniqueResult();
            if (run != null) {
                position.setRun(run);
                @SuppressWarnings("unchecked") List<InstrumentStatusPositionRunPool> pools = currentSession().createCriteria(InstrumentStatusPositionRunPool.class).add(Restrictions.eq("runId", run.getRunId())).add(Restrictions.eq("positionId", position.getPositionId())).list();
                run.setPools(pools);
            }
        }
    }
    return instruments;
}
Also used : InstrumentStatusPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPosition) InstrumentStatusPositionRun(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPositionRun) InstrumentStatus(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatus) InstrumentStatusPositionRunPool(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPositionRunPool)

Example 2 with InstrumentStatus

use of uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatus in project miso-lims by miso-lims.

the class HibernateInstrumentStatusDaoIT method testList.

@Test
public void testList() throws Exception {
    List<InstrumentStatus> list = sut.list();
    assertNotNull(list);
    assertEquals(3, list.size());
    InstrumentStatus status1 = find(list, InstrumentStatus::getId, 1L);
    assertNotNull(status1);
    assertEquals("SN7001179", status1.getName());
    assertNotNull(status1.getPositions());
    assertEquals(3, status1.getPositions().size());
    InstrumentStatusPosition pos1a = find(status1.getPositions(), InstrumentStatusPosition::getAlias, "A");
    assertNotNull(pos1a.getRun());
    assertEquals(2L, pos1a.getRun().getRunId());
    assertNull(pos1a.getOutOfServiceTime());
    InstrumentStatusPosition pos1b = find(status1.getPositions(), InstrumentStatusPosition::getAlias, "B");
    assertNotNull(pos1b.getRun());
    assertEquals(3L, pos1b.getRun().getRunId());
    assertNull(pos1b.getOutOfServiceTime());
    InstrumentStatus status2 = find(list, InstrumentStatus::getId, 2L);
    assertNotNull(status2);
    assertEquals("h1180", status2.getName());
    assertNotNull(status2.getPositions());
    assertEquals(3, status2.getPositions().size());
    InstrumentStatusPosition pos2a = find(status2.getPositions(), InstrumentStatusPosition::getAlias, "A");
    assertNotNull(pos2a);
    assertNotNull(pos2a.getRun());
    assertEquals(4L, pos2a.getRun().getRunId());
    assertNull(pos2a.getOutOfServiceTime());
    InstrumentStatusPosition pos2b = find(status2.getPositions(), InstrumentStatusPosition::getAlias, "B");
    assertNotNull(pos2b);
    assertNull(pos2b.getRun());
    assertNotNull(pos2b.getOutOfServiceTime());
    InstrumentStatus status4 = find(list, InstrumentStatus::getId, 4L);
    assertNotNull(status4);
    assertEquals("miseq1", status4.getName());
    assertNotNull(status4.getPositions());
    assertEquals(1, status4.getPositions().size());
    InstrumentStatusPosition pos4 = status4.getPositions().get(0);
    assertNull(pos4.getAlias());
    assertNull(pos4.getRun());
    assertNull(pos4.getOutOfServiceTime());
}
Also used : InstrumentStatusPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPosition) InstrumentStatus(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatus) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Aggregations

InstrumentStatus (uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatus)2 InstrumentStatusPosition (uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPosition)2 Test (org.junit.Test)1 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)1 InstrumentStatusPositionRun (uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPositionRun)1 InstrumentStatusPositionRunPool (uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPositionRunPool)1