I have created a machine learning model to provide instant feedback on issues. I am attempting to integrate this by using an event listener so that when the description or a custom field is updated to send the field to my model and then return the result to the user.
I have been able to integrate the event listener to send and receive the result from my model however I am unable to find anyway to display this back to the user. Ideally it would be a small meter next to the description or custom field. What is the method that is supposed to be used to display the results from an event listener?
This is my plugin so far:
@Component
public class IssueCreatedResolvedListener implements InitializingBean, DisposableBean {
private static final Logger log = LoggerFactory.getLogger(IssueCreatedResolvedListener.class);
@JiraImport
private final EventPublisher eventPublisher;
@Autowired
public IssueCreatedResolvedListener(EventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
@Override
public void afterPropertiesSet() throws Exception {
log.info("Enabling Plugin");
eventPublisher.register(this);
}
@Override
public void destroy() throws Exception {
log.info("Killing Plugin");
eventPublisher.unregister(this);
}
@EventListener
public void onIssueEvent(IssueEvent issueEvent) throws Exception {
Long eventTypeID = issueEvent.getEventTypeId();
if(eventTypeID.equals(EventType.ISSUE_UPDATED_ID)) {
Issue issue = issueEvent.getIssue();
List changeItems = issueEvent.getChangeLog().getRelated("ChildChangeItem");
Iterator iter = changeItems.iterator();
while(iter.hasNext()) {
Map item = (Map) iter.next();
String request = "";
if(item.get("field").equals("description")) {
request += (String) item.get("newstring") + " " + (String) issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Incident Resolution Comment"));
}
else if(item.get("field").equals("Incident Resolution Comment")) {
request += issue.getDescription() + " " + (String) item.get("newstring");
}
else
continue;
log.info("{} to be evaluated.", request);
URL url = new URL("http://127.0.0.1:8000/model/");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
String urlParameters = "details=" + request;
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
log.info("Issue {} has the quality {}.", issue.getKey(), response.toString());
}
}
}
}
Hello,
To display data you need to create a web panel:
https://developer.atlassian.com/server/jira/platform/web-panel/
Maybe my assumption about the structure of the event listener and web panel is wrong but I assume that their is a singular object of the event listener so displaying to the user is impossible from the event listener. This means I need a separate web panel that has an object for each issue that is opened by the user and this web panel is then able to display the results from the event listener. The part I am struggling with is that I need some way to provide the results to the web panel and to keep the result up to date. I am already storing the results of the event listener in my database so when the web panel is started I can get the results from the database but keeping this up to date after an event is slow and not ideal. Is there someway to communicate between the event listener and web panel to keep the data up to date?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can put data to cache or to AO. It is up to you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.