How to detect a issue is an Epic?

Hi,

I try to detect an issue is an Epic issue. How can I do that?
I try to check if issue have the field name “Epic Name” like this:

Collection<CustomField> customField = customFieldManager.getCustomFieldObjectsByName("Epic Name");
getCurrentIssue().getCustomFieldValue(customField.iterator().next());

I can not use the name of Issue type. Because the name can be change via admin?

Is there any way?

Thank you,

Historically, I have used the various Helper classes the Jira Software offers – In this case, IssueTypeService within the Jira Software package:
https://docs.atlassian.com/jira-software/6.7.7/com/atlassian/greenhopper/service/issue/IssueTypeService.html

Hi @sfbehnke,
Thank you for your answer. Can I ask " Is there any way to detect an epic issue in the Jira package?"
I don’t want to add the greenhopper to my plugin.
Thank you,

The Jira app has no concept of the ‘Epic Issuetype’, so without Greenhopper you will not be able to get a guarantee. As far as Jira is considered, ‘Epic’ is the same as ‘Task’ or ‘Bug’.

Hi @sfbehnke,
I try with the solution to detect if the server is the Jira software or not like this

try {
     EpicService epicService = ComponentAccessor.getComponent(EpicService.class);
      if (epicService.isEpic(getCurrentIssue())) {
        log.info("\nIt is an Epic ne he");
      } else {
        log.info("\nIt is NOT an Epic");
      }
    } catch (Exception e) {
      log.info("It isn't a jira software", e);
    }

But I can’t get the EpicServer.class via componentAccessor :frowning: => the EpicService =null

Do you know another way to detect if it a Jira software like this idea?
Thank you,

Don’t use ComponentAccessor? Why would you use that in a plugin? I have only ever used Dependency Injection via SpringScanner in a plugin.

@Named
public class MyComponent {
  @ComponentImport
  private final EpicService epicService;

  public MyComponent(final EpicService epicService) {
    this.epicService = epicService;
  }

  public Boolean myMethod() {
    return (epicService.isEpic(getCurrentIssue());
  }
} 

I may have misunderstood: Check out this link. How to detect a server is a Jira Software/ a Jira Service Desk,...?

Hi @sfbehnke,

I want to inject the EpicService in runtime, so I can resolve my problem via this method:
EpicService epicService = ComponentAccessor.getOSGiComponentInstanceOfType(EpicService.class);

Is this the safe way?

Cheers,

Why do you need it at runtime? The annotations are only for Dependency Injection, which I thought we were talking about here.