Trying to fetch all linked issues linktype outward & inward description of current issue's parent ticket.
And join together of same linktype in json format .I have mentioned below example.
Here is the code snippet which i have written but output is not in expected format :
import com.atlassian.jira.issue.fields.rest.json.JsonData
import groovy.json.JsonBuilder
import org.jdom.Content
import groovy.json.JsonOutput
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.attachment.Attachment
import org.apache.commons.io.FilenameUtils
import com.atlassian.jira.util.io.InputStreamConsumer
import org.springframework.util.StreamUtils
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.URIBuilder
import groovyx.net.http.ContentType
import groovyx.net.http.RESTClient
import groovyx.net.http.HttpResponseDecorator
import javax.servlet.http.HttpServletRequest
import javax.ws.rs.core.Response
import com.atlassian.jira.issue.attachment.CreateAttachmentParamsBean
import java.io.ByteArrayInputStream
import java.math.MathContext
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkImpl
import com.atlassian.jira.issue.link.IssueLinkTypeImpl
def issueManager = ComponentAccessor.getIssueManager()def attachmentManager = ComponentAccessor.getAttachmentManager()
def mutableIssue = issueManager.getIssueObject("ABC-123")
//def mutableIssue = issue
def parentIssue = mutableIssue.parentObject
log.warn("parentIssue : ${parentIssue}")
def IssueLinkManager = ComponentAccessor.getIssueLinkManager()
def links = "";
List allOutIssueLink = IssueLinkManager.getInwardLinks(mutableIssue.parentObject.getId())
for (Iterator outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {
IssueLink issueLink = (IssueLink) outIterator.next();
def linkedIssue = issueLink.getSourceObject();
if ( (issueLink.issueLinkType.getOutward()) != ""){
links = links + "," +"[" + issueLink.issueLinkType.getOutward()+" : " + linkedIssue.key +"]"
}
}
allOutIssueLink = IssueLinkManager.getOutwardLinks(mutableIssue.parentObject.getId())
for (Iterator OutIterator = allOutIssueLink.iterator(); OutIterator.hasNext();) {
IssueLink issueLink = (IssueLink) OutIterator.next();
def linkedIssue = issueLink.getDestinationObject();
log.warn("${issueLink.issueLinkType.getName()}")
if ( (issueLink.issueLinkType.getInward()) != ""){
links = links + ","+ "[" +issueLink.getIssueLinkType().getInward()+" : " + linkedIssue.key + "]"
}
}
log.warn("Links : ${links}")
def json = JsonOutput.toJson(links)
def json_beauty = JsonOutput.prettyPrint(json)
log.warn("json_beauty : ${json_beauty}")