Search in sources :

Example 1 with TransferNotificationDto

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

the class TransferRestController method addNotification.

@PostMapping("/{transferId}/notifications")
@ResponseBody
public TransferNotificationDto addNotification(@PathVariable long transferId, @RequestBody TransferNotificationDto dto, @RequestParam(defaultValue = "false") boolean saveContact) throws IOException {
    Transfer transfer = RestUtils.retrieve("Transfer", transferId, transferService);
    TransferNotificationDto result = RestUtils.createObject("Notification", dto, from -> {
        TransferNotification notification = Dtos.to(from);
        notification.setTransfer(transfer);
        return notification;
    }, transferNotificationService, Dtos::asDto);
    if (saveContact) {
        Contact contact = new Contact();
        contact.setName(result.getRecipientName());
        contact.setEmail(result.getRecipientEmail());
        contactService.create(contact);
    }
    return result;
}
Also used : Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) TransferNotificationDto(uk.ac.bbsrc.tgac.miso.dto.TransferNotificationDto) TransferNotification(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferNotification) Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) Contact(uk.ac.bbsrc.tgac.miso.core.data.impl.Contact) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 Contact (uk.ac.bbsrc.tgac.miso.core.data.impl.Contact)1 Transfer (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer)1 TransferNotification (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferNotification)1 Dtos (uk.ac.bbsrc.tgac.miso.dto.Dtos)1 TransferNotificationDto (uk.ac.bbsrc.tgac.miso.dto.TransferNotificationDto)1