use of uk.ac.bbsrc.tgac.miso.core.service.RunService in project miso-lims by miso-lims.
the class RunRestController method setPartitionPurposes.
@PutMapping("/{runId}/partition-purposes")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setPartitionPurposes(@PathVariable long runId, @RequestBody RunPartitionPurposeRequest request) throws IOException {
Run run = RestUtils.retrieve("Run", runId, runService);
RunPurpose purpose = RestUtils.retrieve("Run purpose", request.getRunPurposeId(), runPurposeService);
List<Partition> partitions = run.getSequencerPartitionContainers().stream().flatMap(container -> container.getPartitions().stream()).filter(partition -> request.getPartitionIds().contains(partition.getId())).collect(Collectors.toList());
for (Partition partition : partitions) {
RunPartition runPartition = runPartitionService.get(run, partition);
if (runPartition == null) {
runPartition = new RunPartition();
runPartition.setRunId(run.getId());
runPartition.setPartitionId(partition.getId());
}
runPartition.setPurpose(purpose);
runPartitionService.save(runPartition);
}
}
use of uk.ac.bbsrc.tgac.miso.core.service.RunService in project miso-lims by miso-lims.
the class RunRestController method setQc.
@PostMapping(value = "/{runId}/qc", produces = "application/json")
@ResponseStatus(code = HttpStatus.NO_CONTENT)
public void setQc(@PathVariable Long runId, @RequestBody RunPartitionQCRequest request) throws IOException {
Run run = RestUtils.retrieve("Run", runId, runService);
PartitionQCType qcType = partitionQcTypeService.list().stream().filter(qt -> qt.getId() == request.getQcTypeId().longValue()).findAny().orElseThrow(() -> new RestException(String.format("No partition QC type found with ID: %d", request.getQcTypeId()), Status.BAD_REQUEST));
//
run.getSequencerPartitionContainers().stream().flatMap(//
container -> container.getPartitions().stream()).filter(//
partition -> request.partitionIds.contains(partition.getId())).map(WhineyFunction.rethrow(partition -> {
RunPartition runPartition = runPartitionService.get(run, partition);
if (runPartition == null) {
runPartition = new RunPartition();
runPartition.setRunId(run.getId());
runPartition.setPartitionId(partition.getId());
}
runPartition.setQcType(qcType);
runPartition.setNotes(request.notes);
return runPartition;
})).forEach(WhineyConsumer.rethrow(runPartitionService::save));
}
Aggregations