Search in sources :

Example 1 with SampleAliquotDto

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);
}
Also used : DetailedSampleDto(uk.ac.bbsrc.tgac.miso.dto.DetailedSampleDto) SampleClass(uk.ac.bbsrc.tgac.miso.core.data.SampleClass) SampleTissueProcessingDto(uk.ac.bbsrc.tgac.miso.dto.SampleTissueProcessingDto) SampleTissuePieceDto(uk.ac.bbsrc.tgac.miso.dto.SampleTissuePieceDto) SampleAliquotDto(uk.ac.bbsrc.tgac.miso.dto.SampleAliquotDto) SampleStockDto(uk.ac.bbsrc.tgac.miso.dto.SampleStockDto)

Example 2 with SampleAliquotDto

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);
}
Also used : Group(com.eaglegenomics.simlims.core.Group) SampleAliquotSingleCellDto(uk.ac.bbsrc.tgac.miso.dto.SampleAliquotSingleCellDto) Project(uk.ac.bbsrc.tgac.miso.core.data.Project) SampleClass(uk.ac.bbsrc.tgac.miso.core.data.SampleClass) SampleAliquotDto(uk.ac.bbsrc.tgac.miso.dto.SampleAliquotDto) LibraryDto(uk.ac.bbsrc.tgac.miso.dto.LibraryDto) DetailedLibraryDto(uk.ac.bbsrc.tgac.miso.dto.DetailedLibraryDto) ClientErrorException(uk.ac.bbsrc.tgac.miso.webapp.controller.component.ClientErrorException) SampleAliquotRnaDto(uk.ac.bbsrc.tgac.miso.dto.SampleAliquotRnaDto) DetailedLibraryDto(uk.ac.bbsrc.tgac.miso.dto.DetailedLibraryDto) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

SampleClass (uk.ac.bbsrc.tgac.miso.core.data.SampleClass)2 SampleAliquotDto (uk.ac.bbsrc.tgac.miso.dto.SampleAliquotDto)2 Group (com.eaglegenomics.simlims.core.Group)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 Project (uk.ac.bbsrc.tgac.miso.core.data.Project)1 DetailedLibraryDto (uk.ac.bbsrc.tgac.miso.dto.DetailedLibraryDto)1 DetailedSampleDto (uk.ac.bbsrc.tgac.miso.dto.DetailedSampleDto)1 LibraryDto (uk.ac.bbsrc.tgac.miso.dto.LibraryDto)1 SampleAliquotRnaDto (uk.ac.bbsrc.tgac.miso.dto.SampleAliquotRnaDto)1 SampleAliquotSingleCellDto (uk.ac.bbsrc.tgac.miso.dto.SampleAliquotSingleCellDto)1 SampleDto (uk.ac.bbsrc.tgac.miso.dto.SampleDto)1 SampleStockDto (uk.ac.bbsrc.tgac.miso.dto.SampleStockDto)1 SampleTissuePieceDto (uk.ac.bbsrc.tgac.miso.dto.SampleTissuePieceDto)1 SampleTissueProcessingDto (uk.ac.bbsrc.tgac.miso.dto.SampleTissueProcessingDto)1 ClientErrorException (uk.ac.bbsrc.tgac.miso.webapp.controller.component.ClientErrorException)1