Get Filter from Gadget & get gadgets from dashboard

Hello,

is there a possibility how to get the filter of a gadget? I want to retrieve all issues in a filter. And this filter I want to access by a gadget. I know it is possible to get all issues in a filter. But my point is to get the filter via an Gadget-Object.

How can I do this programmatical?

Another question:

Can I iterate over all gadgets in a dashboard? I want to get all gadgets that are contained in a dashboard. If I got these gadgets, I could get the filter.

By the way are there any event-listener for dashboards? So when dashboard is updated an event will be triggered. I found for example listener for projects or issues but nothing for dashboards or gadgets.

Thanks in advance for any help.

4 answers

1 accepted

0 vote
Timothy Chin Community Champion Jun 30, 2014

If I'm not mistaken, you can get the gadget's infomration if you get the gadget object.

Can I iterate over all gadgets in a dashboard?

Yes.

By the way are there any event-listener for dashboards

No.

This class DefaultPortalPageService should get you unstuck.

Thanks for your answer.

The PortalPageService is the top level service for Dashboard operations. For historical reasons, Dashboards were called Portals and hence the prefix "Portal" is used consistently throughout the code.

See follwing link: http://goo.gl/qmV3Ll

When I have a PortalPage/Dashboard, how can I access all the gadgets in this dashboard?

I have following Java Code:

User user = (User)ComponentAccessor.getCrowdService().getUser("admin"); 
       PortalPage portalpage = ComponentAccessor.getComponent(PortalPageService.class).getPortalPage(new JiraServiceContextImpl(user), (long)10201);

//how to get all gadgets with portalPage

Is there a way to get all gadgets with portalpage or another way how to iterate over all gadgets? If possible a little code sample would help me further.

OK, I found a solution.

You can't access all gadgets directly from the PortalPage instance. Instead you need to use the PortalPageService right from the beginning to access all PortletConfigurations like in the Code-Listing below:

List<List<PortletConfiguration>> portletConfigs = pps.getPortletConfigurations(new JiraServiceContextImpl(user), (long)10202); // pps is instance PortalPageService

And now with the List of the List of PortletConfigurations you can iterate through all GadgetURIs and you can access all Queries like:

for(int i = 0; i<portletConfigs.size(); i++)
{
 	List<PortletConfiguration> llconfigs = portletConfigs.get(i);
  	for(int j = 0; j<llconfigs.size(); j++)
    {
             PortletConfiguration pc = llconfigs.get(j);
             log.info("QUERY:" + pc.getGadgetURI().getQuery());
    }
}

It (PortalPage) no longer has a link to the PortletConfigurations (Gadgets) displayed on a dashboard. To get this information one should consult the PortalPageService directly.

Atlassian JIRA API

Unfortunately, whenever I call the method getQuery, it will return null, although a filter were defined in the corresponding gadget. What is wrong? How can I get the filter/query from every gadget?

Does anybody have an idea or a hint, how to get the Filter/Query of a Gadget receiving from the GadgetURI as mentioned above? Is it possible via the JIRA API 6.2.7 or do I have to consult the REST API?

Is it possible to access a gadget from java code that you have created before in a dashboard? And get its query somehow? How is a Gadget defined in the JIRA API?

Please help me.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,314 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot