use of uk.ac.bbsrc.tgac.miso.core.data.qc.QcTarget in project miso-lims by miso-lims.
the class DefaultQualityControlService method startBulkOperation.
private BulkQcSaveOperation startBulkOperation(List<QC> items, ThrowingFunction<QC, QC, IOException> action) throws IOException {
QcTarget qcTarget = qcTypeService.get(items.get(0).getType().getId()).getQcTarget();
BulkQcSaveOperation operation = new BulkQcSaveOperation(qcTarget, items, authorizationManager.getCurrentUser());
// Authentication is tied to the thread, so use this same auth in the new thread
Authentication auth = SecurityContextHolder.getContextHolderStrategy().getContext().getAuthentication();
Thread thread = new Thread(() -> {
SecurityContextHolder.getContextHolderStrategy().getContext().setAuthentication(auth);
try {
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
while (operation.hasMore()) {
try {
QC item = operation.getNextItem();
QC saved = action.apply(item);
operation.addSuccess(saved.getId());
} catch (ValidationException e) {
operation.addFailure(e);
status.setRollbackOnly();
} catch (Exception e) {
operation.setFailed(e);
status.setRollbackOnly();
}
}
}
});
} catch (Exception e) {
// Exception during transaction commit
operation.setFailed(e);
}
if (operation.isFailed()) {
Exception exception = operation.getException();
if (!(exception instanceof BulkValidationException)) {
LoggerFactory.getLogger(DefaultQualityControlService.class).error("Bulk save failed", exception);
}
}
operation.setComplete();
});
thread.start();
return operation;
}
use of uk.ac.bbsrc.tgac.miso.core.data.qc.QcTarget in project miso-lims by miso-lims.
the class AsyncOperationManager method startAsyncBulkQcUpdate.
public <T, R extends Identifiable> ObjectNode startAsyncBulkQcUpdate(List<QcDto> dtos) throws IOException {
final QcTarget qcTarget = getQcTarget(dtos.get(0).getQcTarget());
List<QC> items = validateBulkUpdate("QC", dtos, Dtos::to, id -> qualityControlService.get(qcTarget, id));
BulkSaveOperation<QC> operation = qualityControlService.startBulkUpdate(items);
String uuid = addAsyncOperation(operation);
return makeRunningProgress(uuid, operation);
}
use of uk.ac.bbsrc.tgac.miso.core.data.qc.QcTarget in project miso-lims by miso-lims.
the class QcController method editBulkFrom.
@PostMapping("/bulk/editFrom/{qcTarget}")
public ModelAndView editBulkFrom(@PathVariable("qcTarget") String qcTargetLabel, @RequestParam Map<String, String> form, ModelMap model) throws IOException {
QcTarget qcTarget = getQcTarget(qcTargetLabel);
String entityIds = getStringInput("entityIds", form, true);
int addControls = getIntegerInput("addControls", form, true);
return new BulkQcEditTable(qcTarget, qcService, instrumentService, addControls).display(entityIds, model);
}
use of uk.ac.bbsrc.tgac.miso.core.data.qc.QcTarget in project miso-lims by miso-lims.
the class QcController method addBulk.
@PostMapping("/bulk/addFrom/{qcTarget}")
public ModelAndView addBulk(@PathVariable("qcTarget") String qcTargetLabel, @RequestParam Map<String, String> form, ModelMap model) throws IOException {
QcTarget qcTarget = getQcTarget(qcTargetLabel);
String entityIds = getStringInput("entityIds", form, true);
int copies = getIntegerInput("copies", form, true);
int controls = getIntegerInput("controls", form, true);
return new BulkQcAddTable(qcTarget, qcService, instrumentService, copies, controls).display(entityIds, model);
}
use of uk.ac.bbsrc.tgac.miso.core.data.qc.QcTarget 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