Manipulating with JIRA entities from a plugin component

alexandreev January 31, 2012

I am creating a plugin which will have a scheduled job inside periodically synchronizing jira database with 3rd party software. So all the routines will be performed in background.

It will be required to perform the following set of tasks:

1) Search for issues / projects / versions / jira users by certain search criteria

2) Create new / Update existing issues / projects /versions / jira users

All the changes performed by the plugin should be visible in "Recent Activity" like it was done directly by users.

Which internal Jira API(s) I need to use within my plugin to achieve the goals? Which is the best practice to perform this task?

10 answers

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2012

I agree with Jamie. Use OfBizDelegator only when you know all the DB Entity relations. It is advised to use manager classes if possible and use delegator only if that is not an option.

0 votes
alexandreev January 31, 2012

Thanks Jamie for clarification, this definitely makes sense for me.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2012

By writing to the db I mean using OfBizDelegator to store values directly in the DB. Sometimes it's ok, but for the things you're talking about, it's not. Unless you want to tear your hair out dealing with problems involving the caches and referential integrity. Really, there is only one way to do this.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2012

You don't want to be writing to the database directly, so if you need to create <anything> in jira, the managers etc are the only choice you have.

0 votes
alexandreev January 31, 2012

But what about Jobin's OfBizDelegator - seems quite competitive alternative.

0 votes
alexandreev January 31, 2012

Thank you Jamie and Jobin for the hints. The picture is getting clearer now.

So as far as I see I have 2 ways:

1) Use OfBiz Entity Manager to work directly with jira database

2) Use Managers for every kind of JIRA data I need to deal with

Could you, please, highlight the biggest pros and cons of both approaches as I am on crossroads and need to choose the best way or it may cost much if I will discover some restriction in the middle of the road.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2012

In that case, ProjectManager, ProjectVersionManager, and UserManager/UserAccessor. Of course, you can go direct to the DB as well.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2012

You're unlikely to get a good answer with such a broad question. Start with JqlQueryBuilder, IssueService, etc etc.

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2012

Use OfBizDelegator. You will find all the methods in the Java docs. There is a chapter for working with DB in JIRA Development Cookbook.

0 votes
alexandreev January 31, 2012

Well I do not need too detailed explanations. I would like to find out if there is a separate API for Jira DB manipulation and where can I read for this. I.e. which can provide me the interface to access all jira entities.

As for example you mentioned JqlQueryBuilder and IssueService but I don't only need to deal with issues but also with projects, versions and users.

I searched over the docs and questions database but can't find anything suitable.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events