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