De- Linking an Issue

AKASHB July 28, 2013

i am writting an Groovy Script for post function, My question is: I have created a issue link, now on certian transition i want that link to get De-Link, So for it My approach is to grab that issue link and then do the de-link for both the issues. But i don't know how to grab the Issue Link ID.

Can any of thee geniouses out there can help me out?

2 answers

1 accepted

1 vote
Answer accepted
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2013

to get the issue link id's bi-directionally as follows

to get OUward links

List<IssueLink> allOutIssueLink = issueLinkManager.getOutwardLinks(sourceIssue.getId());
for (Iterator<IssueLink> outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {
	IssueLink issueLink = (IssueLink) outIterator.next();
	System.out.println(issueLink.getIssueLinkType().getId());	
}

same way to get inword issueLink's

List<IssueLink> allInIssueLink = issueLinkManager.getInwardLinks(sourceIssue.getId());
for (Iterator<IssueLink> inIterator = allInIssueLink.iterator(); inIterator.hasNext();) {
	IssueLink issueLink = (IssueLink) inIterator.next();
	System.out.println(issueLink.getIssueLinkType().getId());
if (issueLink.getIssueLinkType().getId() == 10) {
Issue destinationIssue = issueLink.getDestinationObject();
}
 }

AKASHB July 28, 2013

Once i gether the issue links,

I want to delink it and make the associated issue to move back to some other status.

AKASHB July 28, 2013

I have tried using Inward issue, I am getting the Inward issue name and ID but i want an issue which is linked to it, So any thoughts on it?

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2013

you have to use following code to get linked issues

Issue issue=issueLink.getDestinationObject();

check my answer i have update the inword issuelink code

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2013

i have already given code to delink right?

issueLink = issueLinkManager.getIssueLink(sourceId, destId, linkType);
 
issueLinkManager.removeIssueLink(issueLink , remoteuser);

is it not worked?

AKASHB July 28, 2013

Rambanam: Yes, I know and have implemented it and its working perfectly fine, since i have used Customfield plugin on 1 issue type through whcih i used to gather that custom field and make it as mutable issue and perform operations, But this plugin was implemented only on 1 issue type but i am trying to write a groovy script for other issue type, such that Bi-Directional functionality works,

So now since i have created a links between 2 issues, I want to grab issue link ID and then perform operations like setting Status and delinking.

AKASHB July 28, 2013

So my motive is:

1) Gather the linked issue
2) Gather the current status of the issue
3) Look about the other linked status of the issue
4) Replace the issue's status from the current to the newest status (that you are looking to place)
5) update the issue

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2013

you are asking about delink or move status?

AKASHB July 28, 2013

So any thoughts about this.

AKASHB July 28, 2013

I am trying to use the inward link but still its giving me the link name and ID of itself,

my code goes like this:



log.warn("Current Issue is : " + issue)

List<IssueLink> allInIssueLink = linkManager.getInwardLinks(issue.getId());
for (Iterator<IssueLink> inIterator = allInIssueLink.iterator(); inIterator.hasNext();) {
IssueLink issueLink = (IssueLink) inIterator.next();
log.warn("Issue Link Type is : " +issueLink.getIssueLinkType().getId());
log.warn("Issue Link Name : " + issueLink.getIssueLinkType().getName())
Issue issue1= issueLink.getDestinationObject()
}


Collection<IssueLinkType> issueLinkTypes = ((IssueLinkTypeManager) ComponentManager
.getComponentInstanceOfType(IssueLinkTypeManager.class)).getIssueLinkTypes();
String linkID=null;
for (IssueLinkType linktype : issueLinkTypes) {
String name=linktype.getName();
if(name.equals("Open Position - Candidate Ticket")){
linkID=linktype.getId();
break;
}
}


}


OpenPositionFinalVersion(issue)

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

did you print issue1 object?

try somethink like this

List&lt;IssueLink&gt; allInIssueLink = linkManager.getInwardLinks(issue.getId());
for (Iterator&lt;IssueLink&gt; inIterator = allInIssueLink.iterator(); inIterator.hasNext();) {
IssueLink issueLink = (IssueLink) inIterator.next();
log.warn("Issue Link Type is : " +issueLink.getIssueLinkType().getId());
log.warn("Issue Link Name : " + issueLink.getIssueLinkType().getName());
Issue issue1= issueLink.getDestinationObject();
log.warn("issue1 : " + issue1);
if(issue1!=null){
log.warn("issue1 Key: " + issue1.getKey());
}
}

Suggest an answer

Log in or Sign up to answer