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) ); } }
void manageLinks(final MutableIssue issue, final MutableIssue newIssue, final ApplicationUser applicationUser) { // [JRA-13245] subtask->issue - should delete link from parent if (!newIssue.getIssueType().isSubTask() && issue.getIssueType().isSubTask()) { removeLinkFromParent(issue, applicationUser); } //[JRA-13245] issue->subtask - set parent, and add link from the new parent to the currently moved subtask else if (newIssue.getIssueType().isSubTask() && !issue.getIssueType().isSubTask()) { // get the new parent issue addLinkFromNewParent(newIssue, newIssue.getParentObject(), applicationUser); } // subtask->subtask and new parent else if (newIssue.getIssueType().isSubTask() && issue.getIssueType().isSubTask() && !Optional.ofNullable(issue.getParentId()).equals(Optional.ofNullable(newIssue.getParentId()))) { // remove from current parent removeLinkFromParent(issue, applicationUser); //add links from new parent addLinkFromNewParent(newIssue, newIssue.getParentObject(), applicationUser); } }
@Override public Either<NegativeResponseStatus, IssueCreationResultBean> copyIssue(CopyIssueBean copyIssueBean) { try { if(projectInfoService.isIssueTypeASubtask(copyIssueBean.getTargetIssueType(), copyIssueBean.getTargetProjectKey())){ MutableIssue sourceIssue = issueManager.getIssueObject(copyIssueBean.getOriginalKey()); if(sourceIssue.getProjectObject().getKey().equals(copyIssueBean.getTargetProjectKey())){ copyIssueBean.setTargetParentId(sourceIssue.getParentId()); } } return Either.right(copyIssueService.copyIssue(copyIssueBean)); } catch (CopyIssueException e) { return Either.left(NegativeResponseStatus.errorOccured(jiraLocation, e.getErrorCollection())); } }
else if (oldIssue.getIssueType().isSubTask() && newIssue.getIssueType().isSubTask() && !Optional.ofNullable(oldIssue.getParentId()).equals(Optional.ofNullable(newIssue.getParentId())))
final Issue parent = getParentTargetIssue(cloneIssue.getParentId()); if (parent == null) "Could not find parent [" + cloneIssue.getParentId() + "] for subtask [" + cloneIssue.getId() + "] in the parent BulkEditBean.");
regularIssues.containsKey(issue.getParentId()))