Search in sources :

Example 1 with SampleDto

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;
}
Also used : ArrayList(java.util.ArrayList) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) DetailedSampleDto(uk.ac.bbsrc.tgac.miso.dto.DetailedSampleDto) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto)

Example 2 with SampleDto

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);
}
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 3 with SampleDto

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

Example 4 with SampleDto

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);
}
Also used : Project(uk.ac.bbsrc.tgac.miso.core.data.Project) Group(com.eaglegenomics.simlims.core.Group) RestException(uk.ac.bbsrc.tgac.miso.webapp.controller.rest.RestException) DetailedSampleDto(uk.ac.bbsrc.tgac.miso.dto.DetailedSampleDto) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with SampleDto

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);
}
Also used : PageMode(uk.ac.bbsrc.tgac.miso.webapp.util.PageMode) PathVariable(org.springframework.web.bind.annotation.PathVariable) AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) PaginationFilter(uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter) RequisitionService(uk.ac.bbsrc.tgac.miso.core.service.RequisitionService) NotFoundException(org.springframework.security.acls.model.NotFoundException) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ModelMap(org.springframework.ui.ModelMap) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) GetMapping(org.springframework.web.bind.annotation.GetMapping) Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition) RequisitionDto(uk.ac.bbsrc.tgac.miso.dto.RequisitionDto) ListItemsPage(uk.ac.bbsrc.tgac.miso.webapp.util.ListItemsPage) RunPartitionAliquotService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionAliquotService) SampleService(uk.ac.bbsrc.tgac.miso.core.service.SampleService) LibraryService(uk.ac.bbsrc.tgac.miso.core.service.LibraryService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Collectors(java.util.stream.Collectors) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) SampleStock(uk.ac.bbsrc.tgac.miso.core.data.SampleStock) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) NotFoundException(org.springframework.security.acls.model.NotFoundException) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto) Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

SampleDto (uk.ac.bbsrc.tgac.miso.dto.SampleDto)5 Group (com.eaglegenomics.simlims.core.Group)3 PostMapping (org.springframework.web.bind.annotation.PostMapping)3 Project (uk.ac.bbsrc.tgac.miso.core.data.Project)3 DetailedSampleDto (uk.ac.bbsrc.tgac.miso.dto.DetailedSampleDto)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 NotFoundException (org.springframework.security.acls.model.NotFoundException)2 Controller (org.springframework.stereotype.Controller)2 ModelMap (org.springframework.ui.ModelMap)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 PathVariable (org.springframework.web.bind.annotation.PathVariable)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 DetailedSample (uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)2