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;
}
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;
}
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());
}
Aggregations