1
0
-1

I would like to write some code to check if an issue has been exalated in scriptrunner, I am using the following code in scriptrunner for the scripted field that I created as a custom field but it seems that I have a compilation error: I am getting the error stating that [Static type checking] - The variable [eventTypeManager] is undeclared. I am importing the appropriate packages though, how can I fix this problem. Otherwise, how can we check in scriptrunner that and issue has been exalated? 



 import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventType
import com.atlassian.jira.event.type.EventTypeManager
import com.atlassian.jira.*
import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import org.slf4j.Logger
import org.slf4j.LoggerFactory
 
class DefaultAccountListener extends AbstractIssueEventListener {
 
    private final Logger LOG = LoggerFactory.getLogger(DefaultAccountListener)
 
    private static final String EXALATED_EVENT_TYPE = "com.exalate.api.domain.trigger.EXALATED"
    private static final String EXALATE_UPDATED_EVENT_TYPE = "com.exalate.api.domain.trigger.UPDATED"
 
    @Override
    void customEvent(IssueEvent event) {
        Issue issue = event.issue
        EventType eventType = eventTypeManager.getEventType(event.getEventTypeId())
        LOG.debug("Custom event caught for issue ${issue.key}: type [${eventType.type}], name [${eventType.name}], nameKey [${eventType.nameKey}]")
 
        if (eventType.name.equalsIgnoreCase(EXALATED_EVENT_TYPE)) {
            LOG.debug("EXALATED event caught for issue ${issue.key}")
        }
    }
}
  1. Francis Martens (Exalate)
    eventTypeManager needs to be instantiated.

    Check componentAccessor for more details.

  2. Mouna Hammoudi

    I used the code which instantiates EventTypeManager and I get the error Cannot find matching method com.atlassian.jira.event.type.EventTypeManager#getEventType(java.lang.Object). Please check if the declared type is correct and if the method exists


     EventTypeManager eventTypeManager=ComponentAccessor.getEventTypeManager()
            EventType eventType = eventTypeManager.getEventType(event.getEventTypeId())
            if (eventType.name.equalsIgnoreCase(EXALATED_EVENT_TYPE)) {
                return "EXALATED event caught for issue ${issue.key}"
            }



CommentAdd your comment...

2 answers

  1.  
    1
    0
    -1

    Would it be possible to use this kind of code to access the exalate API in scriptrunner?    


    static def ttrepo = ComponentAccessor.getOSGiComponentInstanceOfType(ttRepoClass)
        static def essClass = exaCl.loadClass("com.exalate.api.replication.out.IEventSchedulerService")
        static def ess = ComponentAccessor.getOSGiComponentInstanceOfType(essClass)
        static def relationRepoClass = exaCl.loadClass("com.exalate.api.persistence.relation.IRelationRepository")
        static def relrepo = ComponentAccessor.getOSGiComponentInstanceOfType(relationRepoClass)

      CommentAdd your comment...
    1.  
      1
      0
      -1

      The simplest approach is to set in your incoming sync script a custom field.
      Something like 


      issue."Remote Key" = replica.key



      Finding all the issues which have been exalated is then very simple

      "Remote Key" is not empty



      Using scriptrunner requires you to access the Exalate API which is not public atm.

      1. Mouna Hammoudi

        yes but I do not want to add an extra field in my incoming script , I want to do everything with scriptrunner, your suggestion would mean I would need to add a new custom field to my Jira and I do not want that  

      2. Francis Martens (Exalate)

        hmm - but you do have a scripted field :thinking_face:

      3. Mouna Hammoudi

        what do you mean? my scripted field is the following and what I am trying to do is to set the field value to the text "Yes" if it was exalated otherwise, I would like to go to have a link that the user would click on and that would force a REST connection that would force an exalate 

      4. Mouna Hammoudi

        By the way, I am synchrinzing Jira data center and Jira cloud, here are my connections for Jira cloud: 


        and here are my connections for Jira data center: 


      CommentAdd your comment...