private void removeLinkFromParent(final MutableIssue issue, final ApplicationUser applicationUser) { if (issue.getParentId() != null) { List<IssueLink> parentLinks = issueLinkManager.getOutwardLinks(issue.getParentId()); parentLinks.stream().filter(link -> link.getIssueLinkType().isSubTaskLinkType() && link.getDestinationId().equals(issue.getId())).forEach( link -> issueLinkManager.removeIssueLink(link, applicationUser) ); } }
@Override public void removeIssueLinkType(Long issueLinkTypeId, IssueLinkType swapLinkType, ApplicationUser remoteUser) { Collection<IssueLink> issueLinks = issueLinkManager.getIssueLinks(issueLinkTypeId); if (swapLinkType == null) { // We do not have a swap issue link type so just remove all the issue links for (final IssueLink issueLink : issueLinks) { // Remove the link of this type issueLinkManager.removeIssueLink(issueLink, remoteUser); } } else { // We were given another issue link type to move all the existing issue links to // So move the links before deleting the issue link type for (final IssueLink issueLink : issueLinks) { // Move all the link if the link type that we are about to delete to a different link type issueLinkManager.changeIssueLinkType(issueLink, swapLinkType, remoteUser); } } issueLinkTypeManager.removeIssueLinkType(issueLinkTypeId); } }
@Override public void delete(DeleteIssueLinkValidationResult validationResult) { notNull("validationResult", validationResult); if (!validationResult.isValid()) { throw new IllegalStateException("You cannot delete an issue link with an invalid validation result."); } final IssueLink issueLink = validationResult.getIssueLink(); final Long sourceId = issueLink.getSourceObject().getId(); final Long destinationId = issueLink.getDestinationObject().getId(); final Long issueLinkTypeId = issueLink.getIssueLinkType().getId(); issueLinkManager.removeIssueLink(issueLinkManager.getIssueLink(sourceId, destinationId, issueLinkTypeId), validationResult.getUser()); }
/** * Removes the parent link and adds change item. * * @param context jira service context */ public void preStoreUpdates(JiraServiceContext context, IssueChangeHolder changeHolder, Issue currentIssue, MutableIssue targetIssue) { Collection<IssueLink> inwardLinks = issueLinkManager.getInwardLinks(currentIssue.getId()); for (final IssueLink issueLink : inwardLinks) { if (issueLink.getIssueLinkType().isSubTaskLinkType()) { issueLinkManager.removeIssueLink(issueLink, context.getLoggedInUser()); } } // need to reorder sequence. subTaskManager.resetSequences(currentIssue.getParentObject()); final Issue parentIssue = currentIssue.getParentObject(); changeHolder.addChangeItem(new ChangeItemBean(ChangeItemBean.STATIC_FIELD, "Parent", parentIssue.getId().toString(), parentIssue.getKey(), null, null)); }
issueLinkManager.removeIssueLink(issueLink, currentUser);