use of uk.ac.bbsrc.tgac.miso.core.util.IndexChecker in project miso-lims by miso-lims.
the class EditSampleController method setupForm.
@GetMapping(value = "/{sampleId}")
public ModelAndView setupForm(@PathVariable Long sampleId, ModelMap model) throws IOException {
Sample sample = sampleService.get(sampleId);
if (sample == null)
throw new NotFoundException("No sample found for ID " + sampleId.toString());
model.put("title", "Sample " + sampleId);
model.put("previousSample", sampleService.getPreviousInProject(sample));
model.put("nextSample", sampleService.getNextInProject(sample));
model.put("sampleCategory", LimsUtils.isDetailedSample(sample) ? ((DetailedSample) sample).getSampleClass().getSampleCategory() : "plain");
List<LibraryDto> libraries = sample.isSaved() ? libraryService.listBySampleId(sample.getId()).stream().map(lib -> Dtos.asDto(lib, false)).collect(Collectors.toList()) : Collections.emptyList();
model.put("sampleLibraries", libraries);
Set<Pool> pools = libraries.stream().flatMap(WhineyFunction.flatRethrow(library -> poolService.listByLibraryId(library.getId()))).distinct().collect(Collectors.toSet());
List<RunDto> runDtos = pools.stream().flatMap(WhineyFunction.flatRethrow(pool -> runService.listByPoolId(pool.getId()))).map(Dtos::asDto).collect(Collectors.toList());
model.put("samplePools", pools.stream().map(p -> Dtos.asDto(p, false, false, indexChecker)).collect(Collectors.toList()));
model.put("sampleRuns", runDtos);
model.put("sampleRelations", getRelations(sample));
addArrayData(sampleId, model);
model.put("sampleTransfers", sample.getTransferViews().stream().map(Dtos::asDto).collect(Collectors.toList()));
model.put("sample", sample);
SampleDto sampleDto = Dtos.asDto(sample, false, libraries.size());
setRelatedSlideDtos(sample, sampleDto);
model.put("sampleDto", !sample.isSaved() ? "null" : mapper.writeValueAsString(sampleDto));
ObjectNode formConfig = mapper.createObjectNode();
formConfig.put("detailedSample", isDetailedSampleEnabled());
MisoWebUtils.addJsonArray(mapper, formConfig, "projects", projectService.list(), Dtos::asDto);
MisoWebUtils.addJsonArray(mapper, formConfig, Config.SOPS, sopService.listByCategory(SopCategory.SAMPLE), Dtos::asDto);
model.put("formConfig", mapper.writeValueAsString(formConfig));
return new ModelAndView("/WEB-INF/pages/editSample.jsp", model);
}
use of uk.ac.bbsrc.tgac.miso.core.util.IndexChecker 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.core.util.IndexChecker in project miso-lims by miso-lims.
the class RunRestController method getPotentialExperimentExpansions.
@GetMapping("/{runId}/potentialExperimentExpansions")
@ResponseBody
public List<AddRequest> getPotentialExperimentExpansions(@PathVariable long runId) throws IOException {
Run run = getRun(runId);
Map<Library, List<Partition>> libraryGroups = getLibraryGroups(run);
return libraryGroups.entrySet().stream().<AddRequest>flatMap(WhineyFunction.rethrow(//
group -> //
experimentService.listAllByLibraryId(group.getKey().getId()).stream().filter(experiment -> experiment.getInstrumentModel().getId() == run.getSequencer().getInstrumentModel().getId()).flatMap(experiment -> //
group.getValue().stream().filter(partition -> experiment.getRunPartitions().stream().noneMatch(rp -> rp.getPartition().equals(partition))).map(partition -> {
AddRequest request = new AddRequest();
request.experiment = Dtos.asDto(experiment);
request.partition = Dtos.asDto(partition, indexChecker);
return request;
})))).collect(Collectors.toList());
}
use of uk.ac.bbsrc.tgac.miso.core.util.IndexChecker 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());
}
use of uk.ac.bbsrc.tgac.miso.core.util.IndexChecker in project miso-lims by miso-lims.
the class EditRunController method setupForm.
public ModelAndView setupForm(Run run, ModelMap model) throws IOException {
if (run.getId() == Run.UNSAVED_ID) {
model.put("title", "New Run");
model.put("multiplexed", false);
model.put("metrics", "[]");
model.put("partitionNames", "[]");
} else {
model.put("title", "Run " + run.getId());
model.put("metrics", getSources().filter(Objects::nonNull).map(source -> source.fetchMetrics(run)).filter(metrics -> !isStringBlankOrNull(metrics)).collect(new JsonArrayCollector()));
if (run.getSequencerPartitionContainers().size() == 1) {
ObjectMapper mapper = new ObjectMapper();
model.put("partitionNames", mapper.writeValueAsString(run.getSequencerPartitionContainers().get(0).getPartitions().stream().sorted(Comparator.comparing(Partition::getPartitionNumber)).map(partition -> partition.getPool() == null ? "N/A" : partition.getPool().getAlias()).collect(Collectors.toList())));
} else {
model.put("partitionNames", "[]");
}
model.put("runReportLinks", externalUriBuilder.getUris(run));
}
model.put("runPositions", run.getRunPositions().stream().map(Dtos::asDto).collect(Collectors.toList()));
model.put("runPartitions", run.getSequencerPartitionContainers().stream().flatMap(container -> container.getPartitions().stream()).map(WhineyFunction.rethrow(partition -> {
PartitionDto dto = Dtos.asDto(partition, false, indexChecker);
RunPartition runPartition = runPartitionService.get(run, partition);
if (runPartition != null) {
if (runPartition.getQcType() != null) {
dto.setQcType(runPartition.getQcType().getId());
dto.setQcNotes(runPartition.getNotes());
}
if (runPartition.getPurpose() != null) {
dto.setRunPurposeId(runPartition.getPurpose().getId());
}
} else {
dto.setQcNotes("");
}
return dto;
})).collect(Collectors.toList()));
model.put("runAliquots", getRunAliquots(run));
MisoWebUtils.addIssues(issueTrackerManager, () -> issueTrackerManager.searchIssues(run.getAlias()), model);
model.put("run", run);
ObjectMapper mapper = new ObjectMapper();
ObjectNode partitionConfig = mapper.createObjectNode();
partitionConfig.put("platformType", run.getPlatformType().name());
partitionConfig.put("instrumentModelId", run.getSequencer().getInstrumentModel().getId());
partitionConfig.put("runId", run.getId());
partitionConfig.put("isFull", run.isFull());
partitionConfig.put("showContainer", true);
partitionConfig.put("sequencingParametersId", run.getSequencingParameters() == null ? 0 : run.getSequencingParameters().getId());
partitionConfig.put("showPool", true);
model.put("partitionConfig", mapper.writeValueAsString(partitionConfig));
model.put("experiments", experimentService.listAllByRunId(run.getId()).stream().map(expt -> Dtos.asDto(expt)).collect(Collectors.toList()));
ObjectNode experimentConfig = mapper.createObjectNode();
experimentConfig.put("runId", run.getId());
model.put("experimentConfiguration", mapper.writeValueAsString(experimentConfig));
model.put("runDto", mapper.writeValueAsString(Dtos.asDto(run)));
ObjectNode formConfig = mapper.createObjectNode();
User user = authorizationManager.getCurrentUser();
formConfig.put("isAdmin", user.isAdmin());
formConfig.put("isRunReviewer", user.isRunReviewer() || user.isAdmin());
MisoWebUtils.addJsonArray(mapper, formConfig, "sops", sopService.listByCategory(SopCategory.RUN), Dtos::asDto);
model.put("formConfig", mapper.writeValueAsString(formConfig));
return new ModelAndView("/WEB-INF/pages/editRun.jsp", model);
}
Aggregations