use of uk.ac.bbsrc.tgac.miso.dto.LibraryDto 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.dto.LibraryDto in project miso-lims by miso-lims.
the class EditLibraryController method receiveBulkLibraries.
@PostMapping(value = "/bulk/receive")
public ModelAndView receiveBulkLibraries(@RequestParam Map<String, String> form, ModelMap model) throws IOException {
Integer quantity = getIntegerInput("quantity", form, true);
Long aliquotClassId = getLongInput("sampleClassId", form, isDetailedSampleEnabled());
Long projectId = getLongInput("projectId", form, false);
Long boxId = getLongInput("boxId", form, false);
LibraryDto libDto = null;
Project project = null;
if (projectId != null) {
project = projectService.get(projectId);
if (project == null)
throw new ClientErrorException("No project found for ID " + projectId);
}
SampleClass aliquotClass = null;
if (isDetailedSampleEnabled()) {
aliquotClass = sampleClassService.get(aliquotClassId);
if (aliquotClass == null)
throw new ClientErrorException("No sample class found for ID " + aliquotClassId);
DetailedLibraryDto detailedDto = new DetailedLibraryDto();
libDto = detailedDto;
SampleAliquotDto samDto = null;
if (SampleAliquotSingleCell.SUBCATEGORY_NAME.equals(aliquotClass.getSampleSubcategory())) {
samDto = new SampleAliquotSingleCellDto();
} else if (SampleAliquotRna.SUBCATEGORY_NAME.equals(aliquotClass.getSampleSubcategory())) {
samDto = new SampleAliquotRnaDto();
} else {
samDto = new SampleAliquotDto();
}
detailedDto.setSample(samDto);
samDto.setSampleClassId(aliquotClassId);
detailedDto.setParentSampleClassId(aliquotClassId);
} else {
libDto = new LibraryDto();
libDto.setSample(new SampleDto());
}
if (boxId != null) {
libDto.setBox(Dtos.asDto(boxService.get(boxId), true));
}
Set<Group> recipientGroups = authorizationManager.getCurrentUser().getGroups();
return new BulkReceiveLibraryBackend(libDto, quantity, project, aliquotClass, defaultSciName, libraryTemplateService, recipientGroups).create(model);
}
Aggregations