Search in sources :

Example 6 with Dtos

use of uk.ac.bbsrc.tgac.miso.dto.Dtos in project miso-lims by miso-lims.

the class EditArrayController method setupForm.

@RequestMapping("/{arrayId}")
public ModelAndView setupForm(@PathVariable(name = "arrayId", required = true) long arrayId, ModelMap model) throws IOException {
    model.addAttribute(PageMode.PROPERTY, PageMode.EDIT.getLabel());
    Array array = arrayService.get(arrayId);
    if (array == null) {
        throw new NotFoundException("Array not found");
    }
    model.addAttribute(MODEL_ATTR_ARRAYRUNS, arrayRunService.listByArrayId(arrayId).stream().map(Dtos::asDto).collect(Collectors.toList()));
    ObjectMapper mapper = new ObjectMapper();
    model.addAttribute(MODEL_ATTR_JSON, mapper.writer().writeValueAsString(Dtos.asDto(array)));
    return new ModelAndView(JSP, model);
}
Also used : Array(uk.ac.bbsrc.tgac.miso.core.data.Array) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ModelAndView(org.springframework.web.servlet.ModelAndView) NotFoundException(org.springframework.security.acls.model.NotFoundException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with Dtos

use of uk.ac.bbsrc.tgac.miso.dto.Dtos 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 8 with Dtos

use of uk.ac.bbsrc.tgac.miso.dto.Dtos in project miso-lims by miso-lims.

the class EditUserController method setupForm.

private ModelAndView setupForm(User user, ModelMap model) throws IOException {
    model.put("title", user.isSaved() ? ("User " + user.getId()) : "New User");
    model.put("user", user);
    ObjectMapper mapper = new ObjectMapper();
    model.put("userDto", mapper.writeValueAsString(Dtos.asDto(user)));
    if (user.isSaved()) {
        model.put("groups", user.getGroups().stream().map(Dtos::asDto).collect(Collectors.toList()));
    }
    return new ModelAndView("/WEB-INF/pages/editUser.jsp", model);
}
Also used : Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ModelAndView(org.springframework.web.servlet.ModelAndView) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 9 with Dtos

use of uk.ac.bbsrc.tgac.miso.dto.Dtos in project miso-lims by miso-lims.

the class EditExperimentController method setupForm.

@GetMapping(value = "/{experimentId}")
public ModelAndView setupForm(@PathVariable Long experimentId, ModelMap model) throws IOException {
    Experiment experiment = experimentService.get(experimentId);
    if (experiment == null)
        throw new NotFoundException("No experiment found for ID " + experimentId.toString());
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode consumableConfig = mapper.createObjectNode();
    consumableConfig.put("experimentId", experiment.getId());
    Stream.<// 
    KitDescriptor>concat(// 
    Stream.of(experiment.getLibrary().getKitDescriptor()), // 
    experiment.getRunPartitions().stream().map(// 
    RunPartition::getPartition).flatMap(partition -> Stream.of(partition.getSequencerPartitionContainer().getClusteringKit(), // 
    partition.getSequencerPartitionContainer().getMultiplexingKit()))).filter(// 
    Objects::nonNull).distinct().map(// 
    Dtos::asDto).forEach(consumableConfig.putArray("allowedDescriptors")::addPOJO);
    model.put("experiment", experiment);
    model.put("experimentDto", mapper.writeValueAsString(Dtos.asDto(experiment)));
    model.put("consumables", experiment.getKits().stream().map(Dtos::asDto).collect(Collectors.toList()));
    model.put("consumableConfig", mapper.writeValueAsString(consumableConfig));
    model.put("runPartitions", experiment.getRunPartitions().stream().map(entry -> new ExperimentDto.RunPartitionDto(Dtos.asDto(entry.getRun()), Dtos.asDto(entry.getPartition(), indexChecker))).collect(Collectors.toList()));
    model.put("title", "Edit Experiment");
    return new ModelAndView("/WEB-INF/pages/editExperiment.jsp", model);
}
Also used : KitDescriptor(uk.ac.bbsrc.tgac.miso.core.data.impl.kit.KitDescriptor) PathVariable(org.springframework.web.bind.annotation.PathVariable) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.Experiment.RunPartition) NotFoundException(org.springframework.security.acls.model.NotFoundException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) IOException(java.io.IOException) Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) ExperimentDto(uk.ac.bbsrc.tgac.miso.dto.ExperimentDto) Controller(org.springframework.stereotype.Controller) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) Collectors(java.util.stream.Collectors) IndexChecker(uk.ac.bbsrc.tgac.miso.core.util.IndexChecker) ModelMap(org.springframework.ui.ModelMap) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Objects(java.util.Objects) ModelAndView(org.springframework.web.servlet.ModelAndView) ExperimentService(uk.ac.bbsrc.tgac.miso.core.service.ExperimentService) Stream(java.util.stream.Stream) GetMapping(org.springframework.web.bind.annotation.GetMapping) KitDescriptor(uk.ac.bbsrc.tgac.miso.core.data.impl.kit.KitDescriptor) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ExperimentDto(uk.ac.bbsrc.tgac.miso.dto.ExperimentDto) Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) ModelAndView(org.springframework.web.servlet.ModelAndView) NotFoundException(org.springframework.security.acls.model.NotFoundException) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.Experiment.RunPartition) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 10 with Dtos

use of uk.ac.bbsrc.tgac.miso.dto.Dtos in project miso-lims by miso-lims.

the class EditGroupController method adminSetupForm.

@RequestMapping(value = "/{groupId}", method = RequestMethod.GET)
public ModelAndView adminSetupForm(@PathVariable long groupId, ModelMap model) throws IOException {
    model.put("title", "Group " + groupId);
    Group group = groupService.get(groupId);
    if (group == null) {
        throw new NotFoundException("No group found for ID " + groupId);
    }
    model.put("includedUsers", group.getUsers().stream().map(Dtos::asDto).collect(Collectors.toList()));
    model.put("availableUsers", userService.list().stream().map(Dtos::asDto).collect(Collectors.toList()));
    return setupForm(group, model);
}
Also used : Group(com.eaglegenomics.simlims.core.Group) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) NotFoundException(org.springframework.security.acls.model.NotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Dtos (uk.ac.bbsrc.tgac.miso.dto.Dtos)29 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)14 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 ModelAndView (org.springframework.web.servlet.ModelAndView)11 NotFoundException (org.springframework.security.acls.model.NotFoundException)10 GetMapping (org.springframework.web.bind.annotation.GetMapping)10 PostMapping (org.springframework.web.bind.annotation.PostMapping)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)7 PutMapping (org.springframework.web.bind.annotation.PutMapping)7 IOException (java.io.IOException)6 Collectors (java.util.stream.Collectors)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 Controller (org.springframework.stereotype.Controller)6 PathVariable (org.springframework.web.bind.annotation.PathVariable)6 User (com.eaglegenomics.simlims.core.User)5 List (java.util.List)5 ArrayList (java.util.ArrayList)4 Objects (java.util.Objects)4 Stream (java.util.stream.Stream)4