use of uk.ac.bbsrc.tgac.miso.dto.SampleDto in project miso-lims by miso-lims.
the class EditSampleController method getRelations.
private List<SampleDto> getRelations(Sample sample) {
List<SampleDto> relations = new ArrayList<>();
if (LimsUtils.isDetailedSample(sample)) {
DetailedSample detailed = (DetailedSample) sample;
for (DetailedSample parent = detailed.getParent(); parent != null; parent = parent.getParent()) {
relations.add(0, Dtos.asDto(LimsUtils.deproxify(parent), false));
}
addChildren(relations, detailed.getChildren());
}
return relations;
}
use of uk.ac.bbsrc.tgac.miso.dto.SampleDto 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.SampleDto 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);
}
use of uk.ac.bbsrc.tgac.miso.dto.SampleDto in project miso-lims by miso-lims.
the class EditSampleController method createBulkSamples.
/**
* Used to create new samples.
* <ul>
* <li>Detailed Sample: create new samples of a given sample class. Root identities will be found or created.</li>
* <li>Plain Sample: create new samples.</li>
* </ul>
* Sends Dtos objects which will then be used for editing in grid.
*/
@PostMapping(value = "/bulk/new")
public ModelAndView createBulkSamples(@RequestParam Map<String, String> form, ModelMap model) throws IOException {
Integer quantity = getIntegerInput("quantity", form, true);
String targetCategory = getStringInput("targetCategory", form, isDetailedSampleEnabled());
Long projectId = getLongInput("projectId", form, false);
Long boxId = getLongInput("boxId", form, false);
if (quantity == null || quantity <= 0)
throw new RestException("Must specify quantity of samples to create", Status.BAD_REQUEST);
final SampleDto template;
if (isDetailedSampleEnabled()) {
// create new detailed samples
confirmClassesExist(targetCategory);
template = getCorrectDetailedSampleDto(targetCategory);
} else {
template = new SampleDto();
}
final Project project;
if (projectId == null) {
project = null;
} else {
project = projectService.get(projectId);
template.setProjectId(projectId);
}
if (boxId != null) {
template.setBox(Dtos.asDto(boxService.get(boxId), true));
}
Set<Group> recipientGroups = authorizationManager.getCurrentUser().getGroups();
return new BulkCreateSampleBackend(template.getClass(), template, quantity, project, targetCategory, recipientGroups).create(model);
}
use of uk.ac.bbsrc.tgac.miso.dto.SampleDto in project miso-lims by miso-lims.
the class RequisitionController method edit.
@GetMapping("/{id}")
public ModelAndView edit(@PathVariable long id, ModelMap model) throws IOException {
Requisition requisition = requisitionService.get(id);
if (requisition == null) {
throw new NotFoundException("No requisition found for ID: " + id);
}
model.put("title", "Requisition " + id);
List<Sample> samples = sampleService.list(0, 0, false, "id", PaginationFilter.requisitionId(id));
List<Sample> extractions = sampleService.getChildren(samples.stream().map(Sample::getId).collect(Collectors.toSet()), SampleStock.CATEGORY_NAME);
List<SampleDto> extractionDtos = extractions.stream().map(sam -> Dtos.asDto(sam, false)).collect(Collectors.toList());
model.put("extractions", extractionDtos);
List<Long> libraryIds = libraryService.listIdsByRequisitionId(id);
List<Run> runs = runService.listByLibraryIdList(libraryIds);
List<RunDto> runDtos = runs.stream().map(Dtos::asDto).collect(Collectors.toList());
model.put("runs", runDtos);
return setupForm(requisition, PageMode.EDIT, model);
}
Aggregations