use of uk.ac.bbsrc.tgac.miso.core.data.type.QcType in project miso-lims by miso-lims.
the class Dtos method to.
public static QC to(@Nonnull QcDto dto) {
QC to;
switch(dto.getQcTarget()) {
case "Library":
LibraryQC newLibraryQc = new LibraryQC();
Library ownerLibrary = new LibraryImpl();
ownerLibrary.setId(dto.getEntityId());
newLibraryQc.setLibrary(ownerLibrary);
to = newLibraryQc;
break;
case "Sample":
SampleQC newSampleQc = new SampleQC();
Sample ownerSample = new SampleImpl();
ownerSample.setId(dto.getEntityId());
newSampleQc.setSample(ownerSample);
to = newSampleQc;
break;
case "Pool":
PoolQC newPoolQc = new PoolQC();
Pool ownerPool = new PoolImpl();
ownerPool.setId(dto.getEntityId());
newPoolQc.setPool(ownerPool);
to = newPoolQc;
break;
case "Container":
ContainerQC newContainerQc = new ContainerQC();
SequencerPartitionContainer ownerContainer = new SequencerPartitionContainerImpl();
ownerContainer.setId(dto.getEntityId());
newContainerQc.setContainer(ownerContainer);
to = newContainerQc;
break;
case "Requisition":
RequisitionQC newRequisitionQc = new RequisitionQC();
Requisition ownerRequisition = new Requisition();
ownerRequisition.setId(dto.getEntityId());
newRequisitionQc.setRequisition(ownerRequisition);
to = newRequisitionQc;
break;
default:
throw new IllegalArgumentException("No such QC target: " + dto.getQcTarget());
}
if (dto.getId() != null) {
to.setId(dto.getId());
}
to.setDate(parseDate(dto.getDate()));
setBigDecimal(to::setResults, dto.getResults());
setObject(to::setType, QcType::new, dto.getQcTypeId());
to.setDescription(dto.getDescription());
setObject(to::setInstrument, InstrumentImpl::new, dto.getInstrumentId());
setObject(to::setKit, KitDescriptor::new, dto.getKitDescriptorId());
setString(to::setKitLot, dto.getKitLot());
addQcControlRuns(dto.getControls(), to, QcTarget.valueOf(dto.getQcTarget()));
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.type.QcType in project miso-lims by miso-lims.
the class HibernateQcTypeDao method list.
@Override
public List<QcType> list() throws IOException {
Criteria criteria = currentSession().createCriteria(QcType.class);
@SuppressWarnings("unchecked") List<QcType> records = criteria.list();
return records;
}
use of uk.ac.bbsrc.tgac.miso.core.data.type.QcType in project miso-lims by miso-lims.
the class HibernateQcTypeDaoIT method testCreateControl.
@Test
public void testCreateControl() throws Exception {
QcControl control = new QcControl();
control.setAlias("Shiny New Control");
QcType qcType = (QcType) currentSession().get(QcType.class, 1L);
control.setQcType(qcType);
long savedId = dao.createControl(control);
clearSession();
QcControl saved = (QcControl) currentSession().get(QcControl.class, savedId);
assertNotNull(saved);
assertEquals(control.getAlias(), saved.getAlias());
QcType savedQcType = (QcType) currentSession().get(QcType.class, 1L);
assertNotNull(savedQcType);
assertEquals(1, savedQcType.getControls().size());
assertEquals(control.getAlias(), savedQcType.getControls().iterator().next().getAlias());
}
use of uk.ac.bbsrc.tgac.miso.core.data.type.QcType in project miso-lims by miso-lims.
the class HibernateQcTypeDaoIT method testGet.
@Test
public void testGet() throws IOException {
QcType qcType = dao.get(3L);
assertNotNull(qcType);
assertEquals("Bioanalyser", qcType.getName());
assertEquals(QcTarget.Sample, qcType.getQcTarget());
}
use of uk.ac.bbsrc.tgac.miso.core.data.type.QcType in project miso-lims by miso-lims.
the class HibernateQcTypeDaoIT method testListByNameAndTarget.
@Test
public void testListByNameAndTarget() throws Exception {
String name = "QuBit";
QcTarget target = QcTarget.Library;
List<QcType> qcTypes = dao.listByNameAndTarget(name, target);
assertNotNull(qcTypes);
assertEquals(1, qcTypes.size());
assertEquals(name, qcTypes.get(0).getName());
assertEquals(target, qcTypes.get(0).getQcTarget());
}
Aggregations