api/src/main/java/com/epam/pipeline/manager/issue/IssueManager.java
@Transactional(propagation = Propagation.REQUIRED)
    public List<Issue> deleteIssuesForEntity(EntityVO entity) {
        validateEntityParameters(entity);
        validateEntityCanBeModified(entity);
        List<Issue> issuesToDelete = issueDao.loadIssuesForEntity(entity);
        if (CollectionUtils.isNotEmpty(issuesToDelete)) {
            List<Long> issuesIds = issuesToDelete.stream().map(Issue::getId).collect(Collectors.toList());

            List<Long> commentIds = commentDao.loadCommentsForIssues(issuesIds).values().stream()
                .flatMap(Collection::stream)
                .map(IssueComment::getId)
                .collect(Collectors.toList());

            List<Attachment> attachments = attachmentDao.loadAttachmentsByCommentIds(commentIds).values().stream()
                    .flatMap(Collection::stream)
                    .collect(Collectors.toList());
            attachments.addAll(attachmentDao.loadAttachmentsByIssueIds(issuesIds));
            attachmentFileManager.deleteAttachments(attachments);

            commentDao.deleteAllCommentsForIssuesList(issuesIds);
            issueDao.deleteIssuesForEntity(entity);
        }
        return issuesToDelete;
    }
/**
     * Deletes all issues for specified entity. Note: this method doesn't throw if entity doesn't exist.
     * @param entity target entity
     * @return list of issues that were deleted
     */
Deletes all issues for specified entity. Note: this method doesn't throw if entity doesn't exist.
@param entity target entity
@return list of issues that were deleted
Deletes all issues for specified entity . Note : this method doesn ' t throw if entity doesn ' t exist . @param entity target entity @return list of issues that were deleted
@Transactional(propagation = Propagation.REQUIRED)
    public List<Issue> deleteIssuesForEntity(EntityVO entity) {
        validateEntityParameters(entity);
        validateEntityCanBeModified(entity);
        List<Issue> issuesToDelete = issueDao.loadIssuesForEntity(entity);
        if (CollectionUtils.isNotEmpty(issuesToDelete)) {
            List<Long> issuesIds = issuesToDelete.stream().map(Issue::getId).collect(Collectors.toList());
            List<Long> commentIds = commentDao.loadCommentsForIssues(issuesIds).values().stream()
                .flatMap(Collection::stream)
                .map(IssueComment::getId)
                .collect(Collectors.toList());
            List<Attachment> attachments = attachmentDao.loadAttachmentsByCommentIds(commentIds).values().stream()
                    .flatMap(Collection::stream)
                    .collect(Collectors.toList());
            attachments.addAll(attachmentDao.loadAttachmentsByIssueIds(issuesIds));
            attachmentFileManager.deleteAttachments(attachments);
            commentDao.deleteAllCommentsForIssuesList(issuesIds);
            issueDao.deleteIssuesForEntity(entity);
        }
        return issuesToDelete;
    }
@ Transactional ( propagation = Propagation . REQUIRED ) public List < Issue > deleteIssuesForEntity ( EntityVO entity ) { validateEntityParameters ( entity ) ; validateEntityCanBeModified ( entity ) ; List < Issue > issuesToDelete = issueDao . loadIssuesForEntity ( entity ) ; if ( CollectionUtils . isNotEmpty ( issuesToDelete ) ) { List < Long > issuesIds = issuesToDelete . stream ( ) . map ( Issue :: getId ) . collect ( Collectors . toList ( ) ) ; List < Long > commentIds = commentDao . loadCommentsForIssues ( issuesIds ) . values ( ) . stream ( ) . flatMap ( Collection :: stream ) . map ( IssueComment :: getId ) . collect ( Collectors . toList ( ) ) ; List < Attachment > attachments = attachmentDao . loadAttachmentsByCommentIds ( commentIds ) . values ( ) . stream ( ) . flatMap ( Collection :: stream ) . collect ( Collectors . toList ( ) ) ; attachments . addAll ( attachmentDao . loadAttachmentsByIssueIds ( issuesIds ) ) ; attachmentFileManager . deleteAttachments ( attachments ) ; commentDao . deleteAllCommentsForIssuesList ( issuesIds ) ; issueDao . deleteIssuesForEntity ( entity ) ; } return issuesToDelete ; }
Deletes all issues for specified entity.
Deletes all issues for specified entity .