api/src/main/java/com/epam/pipeline/manager/issue/IssueManager.java
@Transactional(propagation = Propagation.REQUIRED)
    public Issue deleteIssue(Long issueId) {
        Optional<Issue> issue = issueDao.loadIssue(issueId);
        issue.ifPresent(i -> {
            List<Long> commentIds = commentDao.loadCommentsForIssue(issueId)
                .stream()
                .map(IssueComment::getId)
                .collect(Collectors.toList());

            List<Attachment> attachments = attachmentDao.loadAttachmentsByCommentIds(commentIds).entrySet()
                .stream().flatMap(e -> e.getValue().stream()).collect(Collectors.toList());
            attachments.addAll(attachmentDao.loadAttachmentsByIssueId(issueId));
            attachmentFileManager.deleteAttachments(attachments);

            commentDao.deleteAllCommentsForIssue(issueId);
            issueDao.deleteIssue(issueId);
        });

        return issue.orElseThrow(getIssueNotFoundException(issueId));
    }
/**
     * Deletes an {@link Issue} specified by ID. If issue doesn't exist an error will be occurred.
     * @param issueId issue ID
     * @return deleted issue
     */
Deletes an  Issue specified by ID. If issue doesn't exist an error will be occurred.
@param issueId issue ID
@return deleted issue
Deletes an Issue specified by ID . If issue doesn ' t exist an error will be occurred . @param issueId issue ID @return deleted issue
@Transactional(propagation = Propagation.REQUIRED)
    public Issue deleteIssue(Long issueId) {
        Optional<Issue> issue = issueDao.loadIssue(issueId);
        issue.ifPresent(i -> {
            List<Long> commentIds = commentDao.loadCommentsForIssue(issueId)
                .stream()
                .map(IssueComment::getId)
                .collect(Collectors.toList());
            List<Attachment> attachments = attachmentDao.loadAttachmentsByCommentIds(commentIds).entrySet()
                .stream().flatMap(e -> e.getValue().stream()).collect(Collectors.toList());
            attachments.addAll(attachmentDao.loadAttachmentsByIssueId(issueId));
            attachmentFileManager.deleteAttachments(attachments);
            commentDao.deleteAllCommentsForIssue(issueId);
            issueDao.deleteIssue(issueId);
        });
        return issue.orElseThrow(getIssueNotFoundException(issueId));
    }
@ Transactional ( propagation = Propagation . REQUIRED ) public Issue deleteIssue ( Long issueId ) { Optional < Issue > issue = issueDao . loadIssue ( issueId ) ; issue . ifPresent ( i -> { List < Long > commentIds = commentDao . loadCommentsForIssue ( issueId ) . stream ( ) . map ( IssueComment :: getId ) . collect ( Collectors . toList ( ) ) ; List < Attachment > attachments = attachmentDao . loadAttachmentsByCommentIds ( commentIds ) . entrySet ( ) . stream ( ) . flatMap ( e -> e . getValue ( ) . stream ( ) ) . collect ( Collectors . toList ( ) ) ; attachments . addAll ( attachmentDao . loadAttachmentsByIssueId ( issueId ) ) ; attachmentFileManager . deleteAttachments ( attachments ) ; commentDao . deleteAllCommentsForIssue ( issueId ) ; issueDao . deleteIssue ( issueId ) ; } ) ; return issue . orElseThrow ( getIssueNotFoundException ( issueId ) ) ; }
Deletes an {@link Issue} specified by ID.
Deletes an { @link Issue } specified by ID .