use of uk.ac.bbsrc.tgac.miso.dto.SampleAliquotDto in project miso-lims by miso-lims.
the class SampleRestController method buildHierarchy.
/**
* Converts the DTO to a Sample, complete with parents. Parent SampleClasses are inferred where necessary
*
* @param sampleDto
* @return
* @throws IOException
*/
public Sample buildHierarchy(SampleDto sampleDto) throws IOException {
if (sampleDto instanceof SampleAliquotDto) {
SampleAliquotDto dto = (SampleAliquotDto) sampleDto;
dto.setStockClassId(inferIntermediateSampleClassId(dto, dto.getSampleClassId(), SampleAliquot.CATEGORY_NAME, SampleStock.CATEGORY_NAME, true));
// Some hierarchies have two Aliquot levels
if (dto.getStockClassId() == null) {
dto.setParentAliquotClassId(inferIntermediateSampleClassId(dto, dto.getSampleClassId(), SampleAliquot.CATEGORY_NAME, SampleAliquot.CATEGORY_NAME, false));
Long topAliquotClassId = dto.getParentAliquotClassId() == null ? dto.getSampleClassId() : dto.getParentAliquotClassId();
dto.setStockClassId(inferIntermediateSampleClassId(dto, topAliquotClassId, SampleAliquot.CATEGORY_NAME, SampleStock.CATEGORY_NAME, false));
}
if (dto.getParentId() == null) {
// infer tissue processing class if necessary
SampleClass processingClass = sampleClassService.getRequiredTissueProcessingClass(dto.getStockClassId());
if (processingClass != null) {
dto.setTissueProcessingClassId(processingClass.getId());
// infer tissue class
dto.setParentSampleClassId(inferIntermediateSampleClassId(dto, dto.getTissueProcessingClassId(), SampleTissueProcessing.CATEGORY_NAME, SampleTissue.CATEGORY_NAME, false));
} else {
// infer tissue class
dto.setParentSampleClassId(inferIntermediateSampleClassId(dto, dto.getStockClassId(), SampleStock.CATEGORY_NAME, SampleTissue.CATEGORY_NAME, false));
}
}
} else if (sampleDto instanceof SampleStockDto) {
// infer tissue processing class if necessary
SampleStockDto dto = (SampleStockDto) sampleDto;
SampleClass processingClass = sampleClassService.getRequiredTissueProcessingClass(dto.getSampleClassId());
if (processingClass != null) {
dto.setTissueProcessingClassId(processingClass.getId());
// infer tissue class
dto.setParentSampleClassId(inferIntermediateSampleClassId(dto, dto.getTissueProcessingClassId(), SampleTissueProcessing.CATEGORY_NAME, SampleTissue.CATEGORY_NAME, false));
} else {
// infer tissue class
dto.setParentSampleClassId(inferIntermediateSampleClassId(dto, dto.getSampleClassId(), SampleStock.CATEGORY_NAME, SampleTissue.CATEGORY_NAME, false));
}
} else if (sampleDto instanceof SampleTissueProcessingDto) {
DetailedSampleDto dto = (DetailedSampleDto) sampleDto;
Long topProcessingClassId = dto.getSampleClassId();
if (sampleDto instanceof SampleTissuePieceDto) {
SampleTissuePieceDto lcmDto = (SampleTissuePieceDto) dto;
// Some hierarchies have two Tissue Processing levels
lcmDto.setParentSlideClassId(inferIntermediateSampleClassId(dto, dto.getSampleClassId(), SampleTissueProcessing.CATEGORY_NAME, SampleTissueProcessing.CATEGORY_NAME, true));
if (lcmDto.getParentSlideClassId() != null) {
topProcessingClassId = lcmDto.getParentSlideClassId();
}
}
dto.setParentSampleClassId(inferIntermediateSampleClassId(dto, topProcessingClassId, SampleTissueProcessing.CATEGORY_NAME, SampleTissue.CATEGORY_NAME, false));
}
return Dtos.to(sampleDto);
}
use of uk.ac.bbsrc.tgac.miso.dto.SampleAliquotDto 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