Insight (Assets) integration with Java API in Jira 9

Hi Community,

In Jira Software 8.20 / Jira Service Management 4.20 I was able to use the Insight Java API in the following way in my P2 plugin:

pom.xml

<dependencies>
    <dependency>
        <groupId>com.atlassian.jira.plugins</groupId>
        <artifactId>insight</artifactId>
        <version>${insight.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.servicedesk</groupId>
        <artifactId>insight-core-model</artifactId>
        <version>${insight.version}</version>
        <scope>provided</scope>
    </dependency>
<dependencies>
...
<properties>
    ...
    <insight.version>9.1.11</insight.version>
</properties>

Service class:

...
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade;
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectSchemaFacade;
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade;
import com.riadalabs.jira.plugins.insight.common.exception.InsightException;
import com.riadalabs.jira.plugins.insight.services.model.ObjectAttributeBean;
import com.riadalabs.jira.plugins.insight.services.model.ObjectAttributeValueBean;
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean;
import com.riadalabs.jira.plugins.insight.services.model.ObjectSchemaBean;
import org.springframework.stereotype.Component;
...

@Component
public class FooService {
    private final ObjectSchemaFacade objectSchemaFacade;
    private final ObjectTypeAttributeFacade objectTypeAttributeFacade;
    private final IQLFacade iqlFacade;

    public FooService(@ComponentImport ObjectSchemaFacade objectSchemaFacade,
                     @ComponentImport ObjectTypeAttributeFacade objectTypeAttributeFacade,
                     @ComponentImport IQLFacade iqlFacade) {
        this.objectSchemaFacade = objectSchemaFacade;
        this.objectTypeAttributeFacade = objectTypeAttributeFacade;
        this.iqlFacade = iqlFacade;
    }

    public List<Foo> getFooObjects() {
        ...

        Integer objectSchemaBeanId = objectSchemaFacade.findObjectSchemaBeans() ...

        List<Foo> fooObjects = iqlFacade.findObjects(objectSchemaBeanId, ...) ...

        for (Foo fooObject : fooObjects) {
            for (ObjectBean objectBean : iqlFacade.findObjects(objectSchemaBeanId, "objectType = \"Foo Type\" and ...")) {
                for (ObjectAttributeBean objectAttributeBean : objectBean.getObjectAttributeBeans()) {
                    if ("Default".equals(objectTypeAttributeFacade.loadObjectTypeAttribute(objectAttributeBean.getObjectTypeAttributeId()).getName())) {
                        ...
                    }
                }
            }
        }
        ...
    }
}

Now, after an upgrade to Jira Software 9.4.6 / Jira Service Management 5.4.6, I’d like to update the dependencies, but I cannot figure out the correct way to do it.
The official documentation mentions the ${insight.version}, but does not show if it should be added under the <properties>...</properties> or not and with what version.
https://confluence.atlassian.com/assetapps/assets-app-development-1168847878.html

Could anyone help with this?

Regards,
Ferenc

2 Likes

Meanwhile managed to talk to someone from Atlassian and they suggested not to update the dependency if the integration is not broken. :man_shrugging:

1 Like