Search in sources :

Example 6 with RunDto

use of uk.ac.bbsrc.tgac.miso.dto.run.RunDto 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

RunDto (uk.ac.bbsrc.tgac.miso.dto.run.RunDto)6 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Controller (org.springframework.stereotype.Controller)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 PathVariable (org.springframework.web.bind.annotation.PathVariable)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Collection (java.util.Collection)2 Map (java.util.Map)2 Stream (java.util.stream.Stream)2 Status (javax.ws.rs.core.Response.Status)2 Value (org.springframework.beans.factory.annotation.Value)2 NotFoundException (org.springframework.security.acls.model.NotFoundException)2 ModelMap (org.springframework.ui.ModelMap)2 Run (uk.ac.bbsrc.tgac.miso.core.data.Run)2