NOW LOADING

Java API

Java API

This page only explains how to call our Java API. If you want to integrate Requirement Yogi with another system, please go to /docs/extensions-4-reqif/.

We assume that you already know how to build a Confluence plugin. If you don’t, please head to Atlassian’s websites for tutorials and help.

Add Requirement Yogi as a dependency

In your pom.xml, section <dependencies>:

        <dependency>
            <groupId>com.playsql</groupId>
            <artifactId>requirementyogi</artifactId>
            <version>${requirementsyogi.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.playsql</groupId>
                    <artifactId>utils</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

The property requirementsyogi.version should be defined somewhere else in your pom.xml. Versions are visible on our public Maven repository (external1/external1).

Then in your pom.xml, section <build> -> plugins -> plugin -> maven-amps-plugin -> configuration, import the API packages:

                 <configuration>
                    <instructions>
                        <Import-Package>
                            com.playsql.requirementyogi.ao;version="0.0.0",
                            com.playsql.requirementyogi.api;version="0.0.0",
                            ... and maybe other packages that are provided by Confluence.

If you don’t know what this is doing, head over to Atlassian’s websites to understand: <Instructions> in Atlassian plugins. Basically, the <dependency> section tells Maven which library it compiles against, but at runtime, Confluence needs to know which packages should be provided to the plugin, and this is what the <instructions> section does.

From then on, you will be able to call Requirement Yogi’s API from your Java code.

Searching for requirements

com.playsql.requirementyogi.api.RequirementService has a few methods to search for and retrieve requirements:

try {
    SearchResult<Requirement> searchResults = requirementService.search(
        RYSearchQuery.parse("@Priority = \"High\""),
        "space1", false, false, null, null, null, null, null, true);
    
    println("Count: " + searchResults.getCount() + " requirements found, " + searchResults.getResults().size() + " will be displayed");
    for (Requirement requirement : searchResults.getResults()) {
        println("Requirement " + requirement.getKey() + " has the title: " + requirement.getHtmlExcerpt());
    }
} catch (SearchException ex) {
    println("Exception while searching for requirements: " + ex.getMessage());
}