Skip to main content
Skip table of contents

Java API - Getting started

Java

Java developer section

Setup

All the steps in this section are detailled in Java setup.

Maven

This is the minimal pom structure. This includes the module dependency, OSGI instructions and Maven repository reference :

CODE
<project ...>
	<dependencies>
		<dependency>
    		<groupId>com.valiantys.software.elements.api</groupId>
    		<artifactId>elements-public-api</artifactId>
    		<version>1.0.0</version>
    		<scope>provided</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jira-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
					<instructions>
                        <Import-Package>
							com.valiantys.software.elements.api,
               				com.valiantys.software.elements.api.content,
                			com.valiantys.software.elements.api.model,
                			com.valiantys.software.elements.api.model.builders,
                			com.valiantys.software.elements.api.render,
                			com.valiantys.software.elements.api.render.format,
                			com.valiantys.software.elements.api.event
                        </Import-Package>
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>
		</plugins>
	</build>

    <repositories>
		<repository>
    		<id>valiantys-repository</id>
    		<name>Valiantys</name>
    		<url>https://repository.valiantys.com/artifactory/valiantys-public</url>
		</repository>
    </repositories>


</project>

Service reference

This code used Atlassian Plugin Scanner. It allows you to inject a service from another plugin (Element PanelContentService here). 

JAVA
@Named
public class MyService {
 
    private final PanelContentService panelContentService;
 
    @Inject
    public MyService(PanelContentService panelContentService) {
        this.panelContentService = panelContentService;
    }
     
    public void doStuff() throws ElementsException {
        Panel panel = panelContentService.getPanel(IssueRef.byKey("ISSUE-1"), PanelRef.byName("My Panel"));
        ...
    }
}


Groovy

ScriptRunner user section

Example script

All the steps in this section are detailled in ScriptRunner setup.

This code below contains the minimum to reference and use a service in Elements Checklist.

This references the PanelRenderingService and generates the default HTML content for a panel

GROOVY
import com.valiantys.software.elements.api.model.*;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.plugin.PluginAccessor;

PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor();
Class panelRenderingServiceClass = pluginAccessor.getClassLoader().findClass("com.valiantys.software.elements.api.render.PanelRenderingService");

def panelRenderingService = ComponentAccessor.getOSGiComponentInstanceOfType(panelRenderingServiceClass);

def htmlContent = panelRenderingService.renderPanel(IssueRef.byKey("test-36"), PanelRef.byName("Item List"))

return htmlContent
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.