How can I determine all the structure boards that are using a particular type of synchronizer?

Tom Jackson
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.
November 18, 2014

We have 100's of structure boards and many of them have synchronizers installed. We have built two custom synchronizers and are interested in determining which structure boards are using them. I'm happy to write a script or DB query but can't figure out which API to exploit. I've looked through your REST endpoints to no avail and recall you saying that your derby DB isn't query-able. Am I out of luck?

Thanks!

1 answer

1 accepted

1 vote
Answer accepted
Pavel Zvyagin [ALM Works] November 19, 2014

Hello Thomas, thanks for the question! You can get the result by using Structure's Java API. You'll need to install the Script Runner plugin (if you don't have it yet) and use a Groovy script like the following:

// get the services we need
import com.atlassian.jira.component.ComponentAccessor
def plugin = ComponentAccessor.getPluginAccessor().getPlugin('com.almworks.jira.structure')
def structureManager = plugin.getModuleDescriptor('structure-manager').getModule()
def syncManager = plugin.getModuleDescriptor('sync-manager').getModule()


// get all structures (except archived)
def structures = structureManager.getAllStructures(null, null, true)
// find structures having the synchronizers you need
def result = structures.findAll { str ->
  // get all synchronizers for the structure
  def syncs = syncManager.getInstalledSynchronizersForStructure(str.id)
  // check if any of the syncs satisfies the condition
  syncs.any { sync ->
    // in this case, the sync must be enabled and be a FilterSynchronizer
    // adjust the condition as needed
    syncManager.isAutosyncEnabled(sync.instanceId) && sync.synchronizer.class.simpleName == 'FilterSynchronizer'
  }
}


// format the result -- you may need to use <br> as separator for ScriptRunner 3
result.join('\n')

This example script finds all enabled filter synchronzers, so you'll need to adjust the it to find the ones you're interested in.

We also have an online developer guide with a Java API reference, which could be helpful.

I hope this helps. Please write if you have any questions.

Tom Jackson
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.
November 19, 2014

Worked like a champ! Thanks!!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events