Hi,
What i have is a listener that creates a new issue when the actual issue is reopened. What i want is a rutine that creates a link to bind both issues.
I've find some documentation and even i don't understand the code completely. I try to do some test with this code:
***********
private final static Long EVENT_REOPEN = 7L;
public void workflowEvent(IssueEvent event){
if(EVENT_REOPEN.equals(event.getEventTypeId())){
boolean wasIndexing = ImportUtils.isIndexIssues();
ImportUtils.setIndexIssues(true);
IssueInputParameters issueInputParameters = new IssueInputParametersImpl()
.setProjectId(event.getIssue().getProjectObject().getId()).setIssueTypeId("1")
.setSummary("New issue")
.setReporterId(event.getIssue().getProjectObject().getLeadUserName())
.setAssigneeId(ComponentManager.getInstance().getUserUtil().getUser("gfi").getName())
.setDescription("Issue '" + event.getIssue().getSummary()
+ "' reopened.").setEnvironment("Tests").setStatusId("1")
.setPriorityId("1").setResolutionId("1");
IssueService issueService = ComponentManager.getInstance().getIssueService();
CreateValidationResult createValidationResult = issueService.validateCreate(event.getRemoteUser(), issueInputParameters);
IssueResult createResult = issueService.create(event.getRemoteUser(), createValidationResult);
ImportUtils.setIndexIssues(wasIndexing);
IssueLinkManager issueLinkManager = ComponentManager.getInstance().getIssueLinkManager();
try{
issueLinkManager.createIssueLink(event.getIssue().getId(), createResult.getIssue().getId(), 10040L, new Long(0), event.getRemoteUser());
}catch (CreateException e) { e.printStackTrace();}
}
}
***********
"10040L" and "new Long()" are just testing values to put on the required IssueLinkTypeId and sequence constructor-fileds. I really doesn't know to get the appropriated values. Well, this code makes my JIRA go crazy. I get a error on the console and i've problems to find my issues with the issue browser (with this error message: "An error occurred whilst rendering this message. Please contact the administrators, and inform them of this bug. Details: ------- ").
So, resuming. Any idea about how to make the link programmatically?
Thanks!!
Alberto.