@Override public IssueLink getIssueLink(Long sourceId, Long destinationId, Long issueLinkTypeId) { return issueLinkManager.getIssueLink(sourceId, destinationId, issueLinkTypeId); }
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; }
public LinkCollection getLinkCollection(final Issue issue, final ApplicationUser user) { return issueLinkManager.getLinkCollection(issue, user); }
@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); } }
/** * 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); }
@Override public void createSubTaskIssueLink(Issue parentIssue, Issue subTaskIssue, ApplicationUser remoteUser) throws CreateException { if (parentIssue == null) { throw new IllegalArgumentException("Parent Issue cannot be null."); } else if (subTaskIssue == null) { throw new IllegalArgumentException("Sub-Task Issue cannot be null."); } // Determine the next sequence of the issue final Collection subTaskIssueLinks = getSubTaskIssueLinks(parentIssue.getId()); // Determine the sequence of the new sub-task link final long sequence = subTaskIssueLinks == null ? 0 : subTaskIssueLinks.size(); issueLinkManager.createIssueLink(parentIssue.getId(), subTaskIssue.getId(), getSubTaskIssueLinkType().getId(), sequence, remoteUser); }
if (!issueLinkManager.isLinkingEnabled())
try issueLinkManager.createIssueLink(inwardIssue.getId(), outwardIssue.getId(), linkType.getId(), null, authContext.getUser()); issueLinkId = issueLinkManager.getIssueLink(inwardIssue.getId(), outwardIssue.getId(), linkType.getId()).getId();
LinkCollection linkCollection = issueLinkManager.getLinkCollection(issue, authContext.getUser()); Set<IssueLinkType> linkTypes = linkCollection.getLinkTypes(); if (linkTypes != null) IssueLink issueLink = issueLinkManager.getIssueLink(issue.getId(), outwardIssue.getId(), issueLinkType.getId()); linkBeans.add(buildLink(issueLinkType, outwardIssue, true, issueLink.getId().toString())); IssueLink issueLink = issueLinkManager.getIssueLink(inwardIssue.getId(), issue.getId(), issueLinkType.getId()); linkBeans.add(buildLink(issueLinkType, inwardIssue, false, issueLink.getId().toString()));
@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)); }
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) ); } }
issueLinkManager.getLinkCollectionOverrideSecurity(issue) : issueLinkManager.getLinkCollection(issue, searcher); linkCollections.add(collection);
@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; }
@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; }
@Override public Either<NegativeResponseStatus, SuccessfulResponse> copyLocalIssueLink(Issue localIssue, String remoteIssueKey, Long remoteIssueId, SimplifiedIssueLinkType issueLinkType, LinkCreationDirection localDirection, LinkCreationDirection remoteDirection) { try { //In contrary to remote links, local are always created in both directions so is is not possible to create only one-way local link. //So here we care only local direction (ie creating link from source issue) if (localDirection == LinkCreationDirection.OUTWARD) { issueLinkManager.createIssueLink(localIssue.getId(), remoteIssueId, issueLinkType.getId(), null, jiraAuthenticationContext.getLoggedInUser()); } else if (localDirection == LinkCreationDirection.INWARD) { issueLinkManager.createIssueLink(remoteIssueId, localIssue.getId(), issueLinkType.getId(), null, jiraAuthenticationContext.getLoggedInUser()); } return SuccessfulResponse.buildEither(jiraLocation); } catch (CreateException e) { return Either.left(NegativeResponseStatus.errorOccured(jiraLocation, e.getMessage())); } }
private void validateLinkingEnabled(final I18nHelper i18n, final ErrorCollection errors) { if (!issueLinkManager.isLinkingEnabled()) { errors.addErrorMessage(i18n.getText("admin.issuelinking.status", i18n.getText("admin.common.words.disabled")), Reason.FORBIDDEN); } }
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; }
Collection<IssueLink> inwardLinks = issueLinkManager.getInwardLinks(subTask.getId()); for (final IssueLink issueLink : inwardLinks) issueLinkManager.removeIssueLink(issueLink, currentUser);
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)); } } } }