use of uk.ac.bbsrc.tgac.miso.dto.ExperimentDto in project miso-lims by miso-lims.
the class EditExperimentController method setupForm.
@GetMapping(value = "/{experimentId}")
public ModelAndView setupForm(@PathVariable Long experimentId, ModelMap model) throws IOException {
Experiment experiment = experimentService.get(experimentId);
if (experiment == null)
throw new NotFoundException("No experiment found for ID " + experimentId.toString());
ObjectMapper mapper = new ObjectMapper();
ObjectNode consumableConfig = mapper.createObjectNode();
consumableConfig.put("experimentId", experiment.getId());
Stream.<//
KitDescriptor>concat(//
Stream.of(experiment.getLibrary().getKitDescriptor()), //
experiment.getRunPartitions().stream().map(//
RunPartition::getPartition).flatMap(partition -> Stream.of(partition.getSequencerPartitionContainer().getClusteringKit(), //
partition.getSequencerPartitionContainer().getMultiplexingKit()))).filter(//
Objects::nonNull).distinct().map(//
Dtos::asDto).forEach(consumableConfig.putArray("allowedDescriptors")::addPOJO);
model.put("experiment", experiment);
model.put("experimentDto", mapper.writeValueAsString(Dtos.asDto(experiment)));
model.put("consumables", experiment.getKits().stream().map(Dtos::asDto).collect(Collectors.toList()));
model.put("consumableConfig", mapper.writeValueAsString(consumableConfig));
model.put("runPartitions", experiment.getRunPartitions().stream().map(entry -> new ExperimentDto.RunPartitionDto(Dtos.asDto(entry.getRun()), Dtos.asDto(entry.getPartition(), indexChecker))).collect(Collectors.toList()));
model.put("title", "Edit Experiment");
return new ModelAndView("/WEB-INF/pages/editExperiment.jsp", model);
}
use of uk.ac.bbsrc.tgac.miso.dto.ExperimentDto in project miso-lims by miso-lims.
the class ExperimentRestController method addPartition.
@PostMapping(value = "/{experimentId}/add", produces = "application/json")
@ResponseBody
public ExperimentDto addPartition(@PathVariable Long experimentId, @RequestParam("runId") Long runId, @RequestParam("partitionId") Long partitionId) throws IOException {
Experiment experiment = experimentService.get(experimentId);
if (experiment == null) {
throw new RestException("No such experiment.", Status.NOT_FOUND);
}
Run run = runService.get(runId);
if (run == null) {
throw new RestException("No such run.", Status.NOT_FOUND);
}
Partition partition = containerService.getPartition(partitionId);
if (partition == null) {
throw new RestException("No such partition.", Status.NOT_FOUND);
}
if (run.getSequencerPartitionContainers().stream().flatMap(container -> container.getPartitions().stream()).noneMatch(p -> p.getId() == partitionId)) {
throw new RestException("Partition not in run.", Status.BAD_REQUEST);
}
if (experiment.getRunPartitions().stream().noneMatch(rp -> rp.getPartition().getId() == partition.getId() && rp.getRun().getId() == run.getId())) {
RunPartition rp = new RunPartition();
rp.setExperiment(experiment);
rp.setPartition(partition);
rp.setRun(run);
experiment.getRunPartitions().add(rp);
experimentService.update(experiment);
}
return get(experimentId);
}
use of uk.ac.bbsrc.tgac.miso.dto.ExperimentDto in project miso-lims by miso-lims.
the class RunRestController method getPotentialExperiments.
@GetMapping("/{runId}/potentialExperiments")
@ResponseBody
public List<StudiesForExperiment> getPotentialExperiments(@PathVariable long runId) throws IOException {
Run run = getRun(runId);
RunDto runDto = Dtos.asDto(run);
InstrumentModelDto instrumentModelDto = Dtos.asDto(run.getSequencer().getInstrumentModel());
Map<Library, List<Partition>> libraryGroups = getLibraryGroups(run);
return libraryGroups.entrySet().stream().map(group -> new Pair<>(group.getKey(), group.getValue().stream().map(partition -> Dtos.asDto(partition, indexChecker)).map(partitionDto -> new RunPartitionDto(runDto, partitionDto)).collect(Collectors.toList()))).map(group -> {
StudiesForExperiment result = new StudiesForExperiment();
result.experiment = new ExperimentDto();
result.experiment.setLibrary(Dtos.asDto(group.getKey(), false));
result.experiment.setInstrumentModel(instrumentModelDto);
result.experiment.setPartitions(group.getValue());
result.studies = group.getKey().getSample().getProject().getStudies().stream().map(Dtos::asDto).collect(Collectors.toList());
return result;
}).collect(Collectors.toList());
}
Aggregations