O'Reilly logo

Practical JIRA Plugins by Matthew B. Doar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Storing Data with Your Plugin

Overview

One of the most common questions when adding new functionality to JIRA is where do I store my plugin’s data?. The brute-force way is to add new tables or new columns to the database by modifying the file entitydefs/entitymodel.xml, but then all your future upgrades will need to make the same changes.

Two better approaches to storing your data are covered in this chapter. The first one is to use the same PropertySet interface that JIRA uses for much of its own configuration data. The second approach is to use the newer Active Objects plugin, which can handle both more complex data and more of it. This Atlassian plugin is shipped as part of JIRA 5.0 and later, but can also be installed separately in JIRA 4.3 and 4.4.

Storing Data with PropertySet

The first approach is to store plugin data where JIRA stores this kind of configuration data, which is in the propertyentry table. This also has the advantage of allowing us to use the same classes, such as PropertyUtils, that JIRA uses for accessing the data. However it is strictly key/value pairs with no idea of relational concepts.

The way that JIRA uses the propertyentry database table is based on the PropertySet interface from OpenSymphony. This interface allows you to store unique key=value pairs with various get and set methods for different types of data.

The propertyentry table is defined in the entitymodel.xml file, as shown in Example 6-1. Note that the entity name OSPropertyEntry ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required