Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Access to Active Object entity in my groovy class.

Mizan
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.
February 29, 2012

Hi ,

Is it possible to access a Active Object Entity in my groovy script ? in my groovy class i need to check values which i have stored in an active object table . i will be using my groovy class with behaviours plugin .

If yes how ? can someone please guide me on how to acheive this .

Thanx in advance :)

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Samuel Le Berrigaud
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2012

You should be able to access Active Objects in your groovy script.

However you'd need to get it injected, the Active Objects component cannot be accessed through the ComponentManager.

If you provide some example of how you work with Groovy in your plugin, I might be able to better help with getting things working. Care to share some source code?

Mizan
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.
March 4, 2012

Hi Sam ,

I have created a plugin which stores data in it using Active objects entity , i want to access this entity in a groovy class which i will use to add behaviours to a customfield. I have not started any coding with this groovy class .

pseudo code

-> ActiveObjects ao;

->final class_name =ao.find(myEntity.class);

->if(class_name contains ("something"))

->display values corressponding to "something"

Mizan
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.
March 4, 2012

Hmm so its not possible to access the entity from an external groovy class , its private to the plugin . am i right ? I thought i can access it like how we access the database , because i can see a AO table in the database .

Samuel Le Berrigaud
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2012

What I'd like to know is how you're going to instantiate your Groovy class in the context of the plugin?

Samuel Le Berrigaud
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2012

Indeed each plugin's Active Objects component is unique and not accessible from outside the scope of that plugin. The fact that you can see the tables in the database is purely a fact that we can't hide them as Active Objects simply uses the same database as the application itself.

Mizan
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.
March 4, 2012

So can i access this entity via database ?

Samuel Le Berrigaud
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2012

There is nothing preventing you from doing it, if you can get hold of a connection. But I strongly advice against doing so. This is not how Active Objects is meant to be used, and therefore it might have some unwanted side effects.

I you need access to some data, you might want to get that data exposed from by the plugin itself in a consumable form for you. For example as a REST service.

1 vote
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.
February 29, 2012

The answer should be yes... personally I have not used AO yet. Can you get your an instance of ao using:

ComponentManager.getOSGiComponentInstanceOfType("com.atlassian.activeobjects.external.ActiveObjects")

?

Mizan
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.
February 29, 2012

I get an error "unable to resolve class" when i try to update my class in behaviours , i used

ActiveObjects ao =ComponentManager.getOSGiComponentInstanceOfType("com.atlassian.activeobjects.external.ActiveObjects");

I am not sure whether this is possible , i need to use something like

Example[] varx=ao.find(Example.class,"example_id=1"); 

in my groovy class .

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.
February 29, 2012

You will likely need to rebuild behaviours plugin component-import AO I think... I will have a play later and get back to you. But actually it should be without the quotes..

TAGS
AUG Leaders

Atlassian Community Events