Search in sources :

Example 26 with Dtos

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

the class UserRestController method create.

@PostMapping
@ResponseBody
public UserDto create(@RequestBody UserDto dto) throws IOException {
    if (!securityManager.canCreateNewUser()) {
        throw new RestException("Cannot create new users in MISO directly.", Status.BAD_REQUEST);
    }
    return RestUtils.createObject("User", dto, d -> {
        User user = Dtos.to(d);
        user.setPassword(passwordEncoder.encode(d.getPassword()));
        return user;
    }, userService, Dtos::asDto);
}
Also used : User(com.eaglegenomics.simlims.core.User) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 27 with Dtos

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

Example 28 with Dtos

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

the class TransferController method setupForm.

public ModelAndView setupForm(Transfer transfer, PageMode pageMode, boolean editSend, boolean editReceipt, ModelMap model) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode formConfig = mapper.createObjectNode();
    formConfig.put(PageMode.PROPERTY, pageMode.getLabel());
    formConfig.put("editSend", editSend);
    formConfig.put("editReceipt", editReceipt);
    Collection<Group> senderGroups = null;
    User user = authorizationManager.getCurrentUser();
    if (user.isAdmin()) {
        senderGroups = groupService.list();
    } else if (editSend && transfer.getSenderLab() == null) {
        senderGroups = user.getGroups();
    } else if (transfer.getSenderGroup() != null) {
        senderGroups = Collections.singleton(transfer.getSenderGroup());
    } else {
        senderGroups = Collections.emptySet();
    }
    MisoWebUtils.addJsonArray(mapper, formConfig, "senderGroups", senderGroups, Dtos::asDto);
    Collection<Group> recipientGroups = null;
    if (user.isAdmin() || editSend) {
        recipientGroups = groupService.list();
    } else if (transfer.getRecipientGroup() != null) {
        recipientGroups = Collections.singleton(transfer.getRecipientGroup());
    } else {
        recipientGroups = Collections.emptySet();
    }
    MisoWebUtils.addJsonArray(mapper, formConfig, "recipientGroups", recipientGroups, Dtos::asDto);
    ObjectNode itemsListConfig = mapper.createObjectNode();
    itemsListConfig.put("editSend", editSend);
    itemsListConfig.put("editReceipt", editReceipt);
    model.put(PageMode.PROPERTY, pageMode.getLabel());
    model.put("transfer", transfer);
    model.put("transferDto", mapper.writeValueAsString(Dtos.asDto(transfer)));
    model.put("formConfig", mapper.writeValueAsString(formConfig));
    model.put("itemsListConfig", mapper.writeValueAsString(itemsListConfig));
    model.put("notificationsEnabled", notificationsEnabled());
    return new ModelAndView("/WEB-INF/pages/editTransfer.jsp", model);
}
Also used : Group(com.eaglegenomics.simlims.core.Group) User(com.eaglegenomics.simlims.core.User) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ModelAndView(org.springframework.web.servlet.ModelAndView) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 29 with Dtos

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

the class QcTableTag method doStartTagInternal.

@Override
protected int doStartTagInternal() throws Exception {
    QualityControllable<?> qcItem = (QualityControllable<?>) item;
    ObjectMapper mapper = new ObjectMapper();
    pageContext.getOut().append(String.format("<br/><h1>QCs</h1><table id='%1$s' class='display no-border ui-widget-content'></table><script type='text/javascript'>jQuery(document).ready(function () { ListUtils.createStaticTable('%1$s', ListTarget.qc('%2$s'), { entityId : %3$d }, %4$s);});</script>", getId(), qcItem.getQcTarget(), qcItem.getId(), mapper.writeValueAsString(qcItem.getQCs().stream().map(Dtos::asDto).collect(Collectors.toList()))));
    return SKIP_BODY;
}
Also used : Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) QualityControllable(uk.ac.bbsrc.tgac.miso.core.data.qc.QualityControllable) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

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