how to access status names in groovy

Jon Hill September 26, 2018

I'm working on a groovy validator that is reviewing the Lifecycle attribute of a given object type.  This Lifecycle attribute is of type Status, and so far all I'm able to do is identify the value of the attribute for a given object, e.g. 50.

I happen to know that the name of the status whose ID is 50 is Assigned and its Category is Active, but I can't figure out how to find that information programmatically.

The Assigned status is defined at the Schema level, but I will also need to consider statuses that are defined at the Insight level such as Closed (whose ID is 7).  

 

This code:

 def lifecycleStateOAB = objectFacade.loadObjectAttributeBean(affectedAssetId, insightAttribAssetLifecycleStateId);
def lifecycleStateOAVB = lifecycleStateOAB.getObjectAttributeValueBeans();
log.info("LifecycleStateOAVB Class: " + lifecycleStateOAVB[0].getClass().toString());
log.info("LifecycleStateOAVB: " + lifecycleStateOAVB[0].toString());
log.info("LifecycleStateOAVB Value : " + lifecycleStateOAVB[0].getValue());

 

returns these results:

2018-09-26 16:29:36,316 [http-nio-8081-exec-17] | LifecycleStateOAVB Class: class com.riadalabs.jira.plugins.insight.services.model.ObjectAttributeValueBean
2018-09-26 16:29:36,316 [http-nio-8081-exec-17] | LifecycleStateOAVB: [994383(50)]
2018-09-26 16:29:36,316 [http-nio-8081-exec-17] | LifecycleStateOAVB Value : 50

 

But what I want is a way to convert that value of 50 into the name "Assigned" or its Category "Active." 

1 answer

1 accepted

3 votes
Answer accepted
Jon Hill September 26, 2018

Never mind!

 

Class configureFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ConfigureFacade");
def configureFacade = ComponentAccessor.getOSGiComponentInstanceOfType(configureFacadeClass);

def status = configureFacade.loadStatusTypeBean(50) ;
log.info("Status name: " + lc.getName());

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events