use of uk.ac.bbsrc.tgac.miso.core.data.qc.QC in project miso-lims by miso-lims.
the class QcRestController method update.
@PutMapping(path = "/{id}")
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public QcDto update(@PathVariable("id") Long id, @RequestBody QcDto qc) throws IOException {
QC updated = Dtos.to(qc);
updated.setId(id);
return Dtos.asDto(qcService.update(updated));
}
use of uk.ac.bbsrc.tgac.miso.core.data.qc.QC in project miso-lims by miso-lims.
the class QcRestController method bulkDelete.
@PostMapping(value = "/bulk-delete")
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public void bulkDelete(@RequestParam String qcTarget, @RequestBody(required = true) List<Long> ids) throws IOException {
List<QC> items = new ArrayList<>();
QcTarget target = null;
try {
target = QcTarget.valueOf(qcTarget);
} catch (IllegalArgumentException e) {
throw new RestException("Unsupported QC target: " + qcTarget, Status.BAD_REQUEST);
}
for (Long id : ids) {
if (id == null) {
throw new RestException("QC id cannot be null", Status.BAD_REQUEST);
}
QC item = qcService.get(target, id);
if (item == null) {
throw new RestException(String.format("No %s QC found with ID: %d", qcTarget, id), Status.BAD_REQUEST);
}
items.add(item);
}
qcService.bulkDelete(items);
}
use of uk.ac.bbsrc.tgac.miso.core.data.qc.QC in project miso-lims by miso-lims.
the class QcController method editBulk.
@PostMapping("/bulk/edit/{qcTarget}")
public ModelAndView editBulk(@PathVariable("qcTarget") String qcTargetLabel, @RequestParam Map<String, String> form, ModelMap model) throws IOException {
QcTarget qcTarget = getQcTarget(qcTargetLabel);
String qcIds = getStringInput("ids", form, true);
int addControls = getIntegerInput("addControls", form, true);
return new BulkEditTableBackend<QC, QcDto>("qc", QcDto.class, "QCs") {
@Override
protected QcDto asDto(QC model) {
return Dtos.asDto(model);
}
@Override
protected Stream<QC> load(List<Long> modelIds) throws IOException {
return modelIds.stream().map(WhineyFunction.rethrow(id -> qcService.get(qcTarget, id)));
}
@Override
protected void writeConfiguration(ObjectMapper mapper, ObjectNode config) throws IOException {
config.putPOJO("instruments", instrumentService.list().stream().map(Dtos::asDto).collect(Collectors.toList()));
config.put("addControls", addControls);
config.put("qcTarget", qcTarget.getLabel());
}
@Override
protected boolean isNewInterface() {
return true;
}
}.edit(qcIds, model);
}
Aggregations