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, Query.select().where("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!
Em

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

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

e.g.

public void updateValue(String projectKey, String newValue){
    //You will need to import transactionTemplate just the same as AO
    transactionTemplate.execute(()->{
        Data[] data = ao.find(Data.class, Query.select().where("projectKey = ?", projectKey));
        if(data.length != 1) //error handling of some kind here
        data[0].setValue(newValue);
        data.save();
        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