Search in sources :

Example 1 with InstrumentStatusPosition

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

the class Dtos method asDto.

public static InstrumentStatusDto asDto(@Nonnull InstrumentStatus from) {
    InstrumentStatusDto to = new InstrumentStatusDto();
    InstrumentDto instrumentDto = new InstrumentDto();
    instrumentDto.setId(from.getId());
    instrumentDto.setName(from.getName());
    to.setInstrument(instrumentDto);
    List<InstrumentPositionStatusDto> posDtos = new ArrayList<>();
    for (InstrumentStatusPosition pos : from.getPositions()) {
        InstrumentPositionStatusDto posDto = new InstrumentPositionStatusDto();
        posDto.setPosition(pos.getAlias());
        if (pos.getOutOfServiceTime() != null) {
            posDto.setOutOfService(true);
            setDateTimeString(posDto::setOutOfServiceTime, pos.getOutOfServiceTime());
        }
        if (pos.getRun() != null) {
            RunDto runDto = new RunDto();
            InstrumentStatusPositionRun run = pos.getRun();
            runDto.setId(run.getRunId());
            runDto.setName(run.getName());
            runDto.setAlias(run.getAlias());
            runDto.setStatus(run.getHealth().getKey());
            setDateString(runDto::setStartDate, run.getStartDate());
            setDateString(runDto::setEndDate, run.getCompletionDate());
            setDateTimeString(runDto::setLastModified, run.getLastModified());
            posDto.setRun(runDto);
            List<PoolDto> poolDtos = new ArrayList<>();
            for (InstrumentStatusPositionRunPool pool : run.getPools()) {
                PoolDto poolDto = new PoolDto();
                poolDto.setId(pool.getPoolId());
                poolDto.setName(pool.getName());
                poolDto.setAlias(pool.getAlias());
                poolDtos.add(poolDto);
            }
            posDto.setPools(poolDtos);
        }
        posDtos.add(posDto);
    }
    to.setPositions(posDtos);
    return to;
}
Also used : InstrumentStatusPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPosition) IonTorrentRunDto(uk.ac.bbsrc.tgac.miso.dto.run.IonTorrentRunDto) PacBioRunDto(uk.ac.bbsrc.tgac.miso.dto.run.PacBioRunDto) Ls454RunDto(uk.ac.bbsrc.tgac.miso.dto.run.Ls454RunDto) OxfordNanoporeRunDto(uk.ac.bbsrc.tgac.miso.dto.run.OxfordNanoporeRunDto) IlluminaRunDto(uk.ac.bbsrc.tgac.miso.dto.run.IlluminaRunDto) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) SolidRunDto(uk.ac.bbsrc.tgac.miso.dto.run.SolidRunDto) ArrayList(java.util.ArrayList) InstrumentStatusPositionRunPool(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPositionRunPool) InstrumentStatusPositionRun(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPositionRun)

Example 2 with InstrumentStatusPosition

use of uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPosition 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 3 with InstrumentStatusPosition

use of uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPosition 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

InstrumentStatusPosition (uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPosition)3 InstrumentStatus (uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatus)2 InstrumentStatusPositionRun (uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPositionRun)2 InstrumentStatusPositionRunPool (uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPositionRunPool)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)1 IlluminaRunDto (uk.ac.bbsrc.tgac.miso.dto.run.IlluminaRunDto)1 IonTorrentRunDto (uk.ac.bbsrc.tgac.miso.dto.run.IonTorrentRunDto)1 Ls454RunDto (uk.ac.bbsrc.tgac.miso.dto.run.Ls454RunDto)1 OxfordNanoporeRunDto (uk.ac.bbsrc.tgac.miso.dto.run.OxfordNanoporeRunDto)1 PacBioRunDto (uk.ac.bbsrc.tgac.miso.dto.run.PacBioRunDto)1 RunDto (uk.ac.bbsrc.tgac.miso.dto.run.RunDto)1 SolidRunDto (uk.ac.bbsrc.tgac.miso.dto.run.SolidRunDto)1