use of uk.ac.bbsrc.tgac.miso.core.data.qc.PoolQC in project miso-lims by miso-lims.
the class BulkPoolQCIT method testAutoUpdateVolume.
@Test
public void testAutoUpdateVolume() throws Exception {
// Goal: ensure that volume and volume units are updated by the QC
BulkQCPage page = getAddPage(Arrays.asList(2201L), 1);
HandsOnTable table = page.getTable();
Map<String, String> attrs = Maps.newLinkedHashMap();
attrs.put(QcColumns.DATE, "2018-07-10");
attrs.put(QcColumns.TYPE, "update volume qc");
attrs.put(QcColumns.RESULT, "10.43");
fillRow(table, 0, attrs);
assertFalse(table.isWritable(QcColumns.POOL_ALIAS, 0));
assertFalse(table.isWritable(QcColumns.UNITS, 0));
assertColumnValues(table, 0, attrs, "pre-save");
assertTrue(page.save(false));
PoolQC saved = getLatestQc();
assertQCAttributes(attrs, saved);
assertEquals(String.format("Expected volume to be updated to %s, instead got %f", "10.43", saved.getPool().getVolume()), 0, saved.getPool().getVolume().compareTo(new BigDecimal("10.43")));
assertEquals(String.format("Expected volume units to be updated to %s, instead got %s", VolumeUnit.MICROLITRES.getUnits(), saved.getPool().getVolumeUnits().getUnits()), VolumeUnit.MICROLITRES, saved.getPool().getVolumeUnits());
}
use of uk.ac.bbsrc.tgac.miso.core.data.qc.PoolQC 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.qc.PoolQC in project miso-lims by miso-lims.
the class DefaultQualityControlService method saveControlRuns.
private void saveControlRuns(long savedId, QC from, QcTargetStore handler) throws IOException {
QC to = get(from.getEntity().getQcTarget(), from.getId());
List<QcControlRun> toDelete = new ArrayList<>();
for (QcControlRun toControl : to.getControls()) {
if (!toControl.isSaved()) {
// newly created QC
continue;
}
QcControlRun fromControl = from.getControls().stream().filter(fc -> fc.getId() == toControl.getId()).findFirst().orElse(null);
if (fromControl == null) {
toDelete.add(toControl);
} else {
toControl.setControl(fromControl.getControl());
toControl.setLot(fromControl.getLot());
toControl.setQcPassed(fromControl.isQcPassed());
handler.updateControlRun(toControl);
}
}
for (QcControlRun control : toDelete) {
handler.deleteControlRun(control);
}
for (QcControlRun fromControl : from.getControls()) {
if (!fromControl.isSaved()) {
switch(to.getType().getQcTarget()) {
case Container:
((ContainerQcControlRun) fromControl).setQc((ContainerQC) to);
break;
case Library:
((LibraryQcControlRun) fromControl).setQc((LibraryQC) to);
break;
case Pool:
((PoolQcControlRun) fromControl).setQc((PoolQC) to);
break;
case Sample:
((SampleQcControlRun) fromControl).setQc((SampleQC) to);
break;
default:
throw new IllegalArgumentException("Unhandled QC target: " + to.getType().getQcTarget());
}
handler.createControlRun(fromControl);
}
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.qc.PoolQC in project miso-lims by miso-lims.
the class BulkPoolQCIT method testAutoUpdateConcentration.
@Test
public void testAutoUpdateConcentration() throws Exception {
// Goal: ensure that volume and volume units are updated by the QC
BulkQCPage page = getAddPage(Arrays.asList(2201L), 1);
HandsOnTable table = page.getTable();
Map<String, String> attrs = Maps.newLinkedHashMap();
attrs.put(QcColumns.DATE, "2018-07-10");
attrs.put(QcColumns.TYPE, "update concentration qc");
attrs.put(QcColumns.RESULT, "24.78");
fillRow(table, 0, attrs);
assertFalse(table.isWritable(QcColumns.POOL_ALIAS, 0));
assertFalse(table.isWritable(QcColumns.UNITS, 0));
assertColumnValues(table, 0, attrs, "pre-save");
assertTrue(page.save(false));
PoolQC saved = getLatestQc();
assertQCAttributes(attrs, saved);
assertEquals(String.format("Expected concentration to be updated to %s, instead got %f", "24.78", saved.getPool().getConcentration()), 0, saved.getPool().getConcentration().compareTo(new BigDecimal("24.78")));
assertEquals(String.format("Expected concentration units to be updated to %s, instead got %s", ConcentrationUnit.NANOMOLAR.getUnits(), saved.getPool().getConcentrationUnits().getUnits()), ConcentrationUnit.NANOMOLAR, saved.getPool().getConcentrationUnits());
}
use of uk.ac.bbsrc.tgac.miso.core.data.qc.PoolQC in project miso-lims by miso-lims.
the class BulkPoolQCIT method testEditQc.
@Test
public void testEditQc() throws Exception {
// Goal: ensure a pool QC can be edited
BulkQCPage page = getEditPage(Arrays.asList(2201L));
HandsOnTable table = page.getTable();
Map<String, String> attrs = Maps.newLinkedHashMap();
attrs.put(QcColumns.DATE, "2018-07-10");
attrs.put(QcColumns.RESULT, "32.6");
fillRow(table, 0, attrs);
assertFalse(table.isWritable(QcColumns.POOL_ALIAS, 0));
assertFalse(table.isWritable(QcColumns.UNITS, 0));
assertFalse(table.isWritable(QcColumns.TYPE, 0));
assertColumnValues(table, 0, attrs, "pre-save");
assertTrue(page.save(false));
PoolQC saved = getLatestQc();
assertQCAttributes(attrs, saved);
}
Aggregations