Hi,
I have problem at hand where i need to use Insight automation and Groovy-script to make our asset management work. What i have in mind is that i have few Insight automation that checks for all objects that have empty group atribute and then add "Group1" to them.
Heres the script so far:
import com.atlassian.jira.component.ComponentAccessor;
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
Class objectTypeAttributeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade");
def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeAttributeFacadeClass);
Class objectAttributeBeanFactoryClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactory");
def objectAttributeBeanFactory = ComponentAccessor.getOSGiComponentInstanceOfType(objectAttributeBeanFactoryClass);
def objectTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttributeBean(162)
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(object, objectTypeAttributeBean, 'group1');
objectTypeAttributeBean = objectFacade.storeObjectAttributeBean(newObjectAttributeBean);
It gets the job done, but while setting the group it overwrites the previous value - What i need it to do is to Add the group1 as second group.
Another way to overcome this is if i can somehow input 2 different groups in newObjectAtributeBean - but that does not seem to work. So far i've tried following:
def groups = ['group1', 'group2']
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(object, objectTypeAttributeBean, 'group1');
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(object, objectTypeAttributeBean, 'group1', 'group2');
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(object, objectTypeAttributeBean, 'group1, group2');
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(object, objectTypeAttributeBean, groups);
Whit out success...
Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.