Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,348
Community Members
 
Community Events
176
Community Groups

Groovy script to remove default concatenator after importing Insight objects

By default, Insight import functionality inserts concatenator character when composing Attribute value from more external data locator values. The default concatenator is space and it is not currently possible to disable it; this is already described in scope of the following feature request: JSDSERVER-8622: Add option to remove the concatenator completely when importing objects 

This Community post provides a possible workaround to remove the concatenator from an assembled Object key with a Groovy script, triggered from an Insight Automation rule.

The Groovy script can be executed, for example, on an Object update event  with an Automation rule similar to the one on the screenshot:
automation.png

Groovy code example:

import com.atlassian.jira.component.ComponentAccessor;

def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade"));
def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade"));
def objectAttributeBeanFactory = ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactory"));

def objectTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttributeBean(161).createMutable() //The id of the attribute, found in the object type Attributes screen
def objectAttributeBean = objectFacade.loadObjectAttributeBean(object.getId(), objectTypeAttributeBean.getId());

def attrValue = objectAttributeBean.getObjectAttributeValueBeans()[0].getValue()
def containsSpace = attrValue.contains(" ")

/* check if the attribute contains space inserted as a concatenator value, replace it with empty char */
if (containsSpace == true) {
attrValue = attrValue.replaceAll("\\s","")
}
/* debug value */
// log.warn("New value: " + attrValue)

/* Create the new attribute bean based on the value */
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(object, objectTypeAttributeBean, attrValue);
/* Load the attribute bean */
if (objectAttributeBean != null) {
/* If attribute exist reuse the old id for the new attribute */
newObjectAttributeBean.setId(objectAttributeBean.getId());
}
/* Store the object attribute into Insight. */
try {
objectTypeAttributeBean = objectFacade.storeObjectAttributeBean(newObjectAttributeBean);
} catch (Exception vie) {
log.warn("Could not update object attribute due to validation exception:" + vie.getMessage());
}

 

1 comment

Fabian Lim Community Leader Aug 20, 2021

Thanks for sharing!

Like Marko Filipan likes this

Comment

Log in or Sign up to comment
TAGS

Atlassian Community Events