public Collection getLinks() { if (links == null) { links = issueLinkManager.getIssueLinks(getId()); if (links == null) { links = Collections.emptyList(); } } return links; }
/** * Retrieves ids of all sub-task issues in the system. */ @Override public Collection<Long> getAllSubTaskIssueIds() { // Get the sub-task issue link type final IssueLinkType subTaskIssueLinkType = getSubTaskIssueLinkType(); // Find all sub-task links final Collection<IssueLink> issueLinks = issueLinkManager.getIssueLinks(subTaskIssueLinkType.getId()); // Theorietically we should be able to return the count of issue links (as a sub-task should cannot be a sub-task of // more than one issue). However if this ever changes, this will likely cause a bug. Hence, this code is in place. // As it is not expected to be executed often, the safe approach is taken. Set<Long> subTaskIssueIds = new HashSet<Long>(); for (final IssueLink issueLink : issueLinks) { subTaskIssueIds.add(issueLink.getDestinationId()); } return subTaskIssueIds; }
@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); } }