Search in sources :

Example 1 with LibraryDto

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);
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) SampleTissueProcessing(uk.ac.bbsrc.tgac.miso.core.data.SampleTissueProcessing) BulkCreateTableBackend(uk.ac.bbsrc.tgac.miso.webapp.util.BulkCreateTableBackend) Autowired(org.springframework.beans.factory.annotation.Autowired) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ModelMap(org.springframework.ui.ModelMap) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) BoxUtils(uk.ac.bbsrc.tgac.miso.core.util.BoxUtils) Project(uk.ac.bbsrc.tgac.miso.core.data.Project) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) Map(java.util.Map) AliasComparator(uk.ac.bbsrc.tgac.miso.core.util.AliasComparator) DetailedSampleDto(uk.ac.bbsrc.tgac.miso.dto.DetailedSampleDto) RestException(uk.ac.bbsrc.tgac.miso.webapp.controller.rest.RestException) PostMapping(org.springframework.web.bind.annotation.PostMapping) SampleService(uk.ac.bbsrc.tgac.miso.core.service.SampleService) SopCategory(uk.ac.bbsrc.tgac.miso.core.data.impl.Sop.SopCategory) SampleIdentityDto(uk.ac.bbsrc.tgac.miso.dto.SampleIdentityDto) SampleStockDto(uk.ac.bbsrc.tgac.miso.dto.SampleStockDto) Collection(java.util.Collection) Set(java.util.Set) QcNodeService(uk.ac.bbsrc.tgac.miso.core.service.QcNodeService) SampleAliquotDto(uk.ac.bbsrc.tgac.miso.dto.SampleAliquotDto) Collectors(java.util.stream.Collectors) IndexChecker(uk.ac.bbsrc.tgac.miso.core.util.IndexChecker) ModelAndView(org.springframework.web.servlet.ModelAndView) LibraryDto(uk.ac.bbsrc.tgac.miso.dto.LibraryDto) MisoWebUtils(uk.ac.bbsrc.tgac.miso.webapp.util.MisoWebUtils) List(java.util.List) Stream(java.util.stream.Stream) SampleStock(uk.ac.bbsrc.tgac.miso.core.data.SampleStock) PoolService(uk.ac.bbsrc.tgac.miso.core.service.PoolService) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) BulkEditTableBackend(uk.ac.bbsrc.tgac.miso.webapp.util.BulkEditTableBackend) SampleClass(uk.ac.bbsrc.tgac.miso.core.data.SampleClass) SampleIdentity(uk.ac.bbsrc.tgac.miso.core.data.SampleIdentity) AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) SampleTissueDto(uk.ac.bbsrc.tgac.miso.dto.SampleTissueDto) SampleTissueProcessingDto(uk.ac.bbsrc.tgac.miso.dto.SampleTissueProcessingDto) SampleClassService(uk.ac.bbsrc.tgac.miso.core.service.SampleClassService) NotFoundException(org.springframework.security.acls.model.NotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayList(java.util.ArrayList) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) Value(org.springframework.beans.factory.annotation.Value) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto) BulkPropagateTableBackend(uk.ac.bbsrc.tgac.miso.webapp.util.BulkPropagateTableBackend) Group(com.eaglegenomics.simlims.core.Group) LimsUtils(uk.ac.bbsrc.tgac.miso.core.util.LimsUtils) GetMapping(org.springframework.web.bind.annotation.GetMapping) Status(javax.ws.rs.core.Response.Status) SampleAliquot(uk.ac.bbsrc.tgac.miso.core.data.SampleAliquot) SampleTissue(uk.ac.bbsrc.tgac.miso.core.data.SampleTissue) LibraryService(uk.ac.bbsrc.tgac.miso.core.service.LibraryService) WhineyFunction(uk.ac.bbsrc.tgac.miso.core.util.WhineyFunction) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) ArrayRunService(uk.ac.bbsrc.tgac.miso.core.service.ArrayRunService) BoxService(uk.ac.bbsrc.tgac.miso.core.service.BoxService) BoxDto(uk.ac.bbsrc.tgac.miso.dto.BoxDto) ProjectService(uk.ac.bbsrc.tgac.miso.core.service.ProjectService) Collections(java.util.Collections) ArrayService(uk.ac.bbsrc.tgac.miso.core.service.ArrayService) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) SopService(uk.ac.bbsrc.tgac.miso.core.service.SopService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) ModelAndView(org.springframework.web.servlet.ModelAndView) NotFoundException(org.springframework.security.acls.model.NotFoundException) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) LibraryDto(uk.ac.bbsrc.tgac.miso.dto.LibraryDto) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) DetailedSampleDto(uk.ac.bbsrc.tgac.miso.dto.DetailedSampleDto) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with LibraryDto

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);
}
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

Group (com.eaglegenomics.simlims.core.Group)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 Project (uk.ac.bbsrc.tgac.miso.core.data.Project)2 SampleClass (uk.ac.bbsrc.tgac.miso.core.data.SampleClass)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Status (javax.ws.rs.core.Response.Status)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Value (org.springframework.beans.factory.annotation.Value)1 NotFoundException (org.springframework.security.acls.model.NotFoundException)1 Controller (org.springframework.stereotype.Controller)1