use of uk.ac.bbsrc.tgac.miso.core.data.qc.PoolQcControlRun 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.PoolQcControlRun in project miso-lims by miso-lims.
the class Dtos method addQcControlRuns.
private static void addQcControlRuns(@Nonnull Collection<QcControlRunDto> list, QC qc, QcTarget qcTarget) {
if (list == null) {
return;
}
for (QcControlRunDto from : list) {
QcControlRun to = null;
switch(qcTarget) {
case Container:
ContainerQcControlRun containerQcControlRun = new ContainerQcControlRun();
containerQcControlRun.setQc((ContainerQC) qc);
((ContainerQC) qc).getControls().add(containerQcControlRun);
to = containerQcControlRun;
break;
case Library:
LibraryQcControlRun libraryQcControlRun = new LibraryQcControlRun();
libraryQcControlRun.setQc((LibraryQC) qc);
((LibraryQC) qc).getControls().add(libraryQcControlRun);
to = libraryQcControlRun;
break;
case Pool:
PoolQcControlRun poolQcControlRun = new PoolQcControlRun();
poolQcControlRun.setQc((PoolQC) qc);
((PoolQC) qc).getControls().add(poolQcControlRun);
to = poolQcControlRun;
break;
case Run:
throw new IllegalArgumentException("Unhandled QC target: Run");
case Sample:
SampleQcControlRun sampleQcControlRun = new SampleQcControlRun();
sampleQcControlRun.setQc((SampleQC) qc);
((SampleQC) qc).getControls().add(sampleQcControlRun);
to = sampleQcControlRun;
break;
default:
throw new IllegalArgumentException("Unhandled QC target: " + qcTarget == null ? "null" : qcTarget.getLabel());
}
setLong(to::setId, from.getId(), false);
setObject(to::setControl, QcControl::new, from.getControlId());
setString(to::setLot, from.getLot());
setBoolean(to::setQcPassed, from.getQcPassed(), false);
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.qc.PoolQcControlRun in project miso-lims by miso-lims.
the class HibernatePoolQcDaoIT method makeControlRun.
@Override
protected QcControlRun makeControlRun(PoolQC qc) {
PoolQcControlRun controlRun = new PoolQcControlRun();
controlRun.setQc(qc);
return controlRun;
}
Aggregations