@Override @Nullable public Long getParentIssueId(Long issueId) { if (issueId == null) return null; // Check if we have any incoming sub-task issue links final List<IssueLink> inwardLinks = issueLinkManager.getInwardLinks(issueId); for (final IssueLink inwardLink : inwardLinks) { if (inwardLink.getIssueLinkType().isSubTaskLinkType()) { return inwardLink.getSourceId(); } } return null; }
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); } }
/** * 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)); }
Collection<IssueLink> inwardLinks = issueLinkManager.getInwardLinks(subTask.getId()); for (final IssueLink issueLink : inwardLinks)