@Override public List<IssueLink> getSubTaskIssueLinks(final Long issueId) { List<IssueLink> subTasks = new ArrayList<IssueLink>(); for (IssueLink link : issueLinkManager.getOutwardLinks(issueId)) { if (link.getIssueLinkType().isSubTaskLinkType()) { subTasks.add(link); } } // Sort the sub-task issue links on sequence Collections.sort(subTasks, new SequenceIssueLinkComparator()); return subTasks; }
public void addIndex(Document doc, Issue issue) { // This accesses the link manager directly (instead of issue.getSubtasks()) so that we only pull out the ids. // This has a performance improvement final List<IssueLink> outwardLinks = issueLinkManager.getOutwardLinks(issue.getId()); for (final IssueLink outwardLink : outwardLinks) { if (outwardLink.getIssueLinkType().isSubTaskLinkType()) { doc.add(new Field(getDocumentFieldId(), outwardLink.getDestinationId().toString(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); } } } }
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) ); } }
public boolean isIssueWithLinks() { final MutableIssue issue = getMutableIssue(); if (issueLinkManager.isLinkingEnabled()) { //checking if there are any not-subtask issue links (inward or outward) return Iterables.any(issueLinkManager.getOutwardLinks(issue.getId()), IssueLinkCopier.isNotSubtaskIssueLink) || Iterables.any(issueLinkManager.getInwardLinks(issue.getId()), IssueLinkCopier.isNotSubtaskIssueLink) || !remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue).isEmpty(); } return false; }
/** * We index the links in 3 ways. First, we index just the link type, so queries can be done like see if something is * a duplicate of another issue. Second, we index the link type with a direction flag which enables queries of all * issues that are blockers of other issues. Third, we link the link type plus direction plus the OTHER issue id so * that we can do a search like "all cloners of this issue" (or all cloners of other issues!). * * @param doc the lucene document that should be modified by adding relevant fields to. * @param issue the issue that contains the data that will be indexed and which can be used to determine the * project/issue type context that will allow you to determine if we should add the value as searchable */ public void addIndex(Document doc, Issue issue) { Long issueId = issue.getId(); addFieldsToDoc(doc, issueLinkManager.getInwardLinks(issueId), IN); addFieldsToDoc(doc, issueLinkManager.getOutwardLinks(issueId), OUT); }
private boolean givenIssueHasAnyCopyableLink(Issue issue) { Collection<IssueLink> inwardLinks = issueLinkManager.getInwardLinks(issue.getId()); if (hasAnyCopyableLinkInGivenLinks(inwardLinks)) { return true; } Collection<IssueLink> outwardLinks = issueLinkManager.getOutwardLinks(issue.getId()); if (hasAnyCopyableLinkInGivenLinks(outwardLinks)) { return true; } return false; }
public void copyLocalIssueLinks(final Issue localIssue, final String copiedIssueKey, final Long copiedIssueId) { //we throw out all subtask and cloner links before copying final Predicate<IssueLink> isNotSubtaskAndClonedLink = Predicates.and(isNotSubtaskIssueLink, isNotSpecifiedLinkType(clonerIssueLinkType)); final Iterable<IssueLink> inwardLinks = Iterables.filter(issueLinkManager.getInwardLinks(localIssue.getId()), isNotSubtaskAndClonedLink); for (final IssueLink inwardLink : inwardLinks) { final IssueLinkType type = inwardLink.getIssueLinkType(); remoteJira.copyLocalIssueLink(inwardLink.getSourceObject(), copiedIssueKey, copiedIssueId, type, JiraProxy.LinkCreationDirection.OUTWARD, JiraProxy.LinkCreationDirection.INWARD); } final Iterable<IssueLink> outwardLinks = Iterables.filter(issueLinkManager.getOutwardLinks(localIssue.getId()), isNotSubtaskAndClonedLink); for (final IssueLink outwardLink : outwardLinks) { final IssueLinkType type = outwardLink.getIssueLinkType(); remoteJira.copyLocalIssueLink(outwardLink.getDestinationObject(), copiedIssueKey, copiedIssueId, type, JiraProxy.LinkCreationDirection.INWARD, JiraProxy.LinkCreationDirection.OUTWARD); } } }
private void cloneLinksIfNeeded(Issue clone, Set<Long> originalIssueIdSet) throws CreateException { if (isCloneLinks() && issueLinkManager.isLinkingEnabled()) { Collection<IssueLink> inwardLinks = issueLinkManager.getInwardLinks(originalIssue.getId()); cloneInwardLinks(clone, originalIssueIdSet, inwardLinks); Collection<IssueLink> outwardLinks = issueLinkManager.getOutwardLinks(originalIssue.getId()); cloneOutwardLinks(clone, originalIssueIdSet, outwardLinks); cloneRemoteIssueLinks(clone); } }