How to update active objects in a plugin

Hello everyone,
I need to update entries in AO whenever the user changes input in a Jira workflow post-function via the console. I am not sure exactly where to do this.

Scenario: A Jira admin can go into the workflow of a project, edit the post-function, and change some value input. Once the workflow is published, this value is then updated in AO.

I have a service with an update function that takes a Jira projectKey (as unique identifier, the new value to update, and the value’s type (so I know what to update in the DB). I have the following query to get the AO based on projectKey:
Data[] data = ao.find(data.class,"projectKey == ?", projectKey));

AO entity classes: Data, DataService, DataServiceImp
Postfunction classes: CreateRepo and CreateRepoFactory

Does anyone know where I can listen for the changes in console and change them in AO accordingly? I tried to add code to the CreateRepoFactory class but can’t seem to access the projectKey (or any unique identifier for the project) from inside there.

Thank you!

Once you have the data object that you want to update you can update the values you need and then call you may need to do this inside a transaction for additional safety.

e.g you can do it right inside the update function.


public void updateValue(String projectKey, String newValue){
    //You will need to import transactionTemplate just the same as AO
        Data[] data = ao.find(Data.class,"projectKey = ?", projectKey));
        if(data.length != 1) //error handling of some kind here
        return null;

In many cases this should be refactored into a service component which handles all of create, find, update and delete for your entities