Executing a script or workflow on data set save
Hello,
We are creating data set and saving it in First Spirit. We want to execute a script or workflow to create a pdf document as soon as we data set gets saved, what are the options we can follow?
Thanks
-
Hello Sumant,
it depends on the purpose of the pdf. If the only requirement is to generate a pdf of the content so that the editor can check it (or to deploy it), you should simply generate a pdf using the PDF-FOP presentation channel. FirstSpirit will then generate the pdf automatically (via the corresponding template code in the presentation channel).
If the pdf should not be created by FirstSpirit, it depends on when it should be generated.
If generation depends on the release of the data record, it would make sense to trigger the corresponding generation in the release workflow.
Alternatively, if generation should happen every time the data record is saved, you can use the IDProviderEventAgent to listen for changes to the data record and react accordingly.Best regards,
Holger0 -
Hello Holger,
Is it possible to share any previously done implementation of IDProviderEventAgent in Java as an example?
Thanks,
Sumant!
0 -
Hello Sumant,
here is an example Beanshell-Script I used during quality assurance
import de.espirit.firstspirit.agency.IDProviderEventAgent;
import de.espirit.firstspirit.event.RevisionEvent;
import de.espirit.firstspirit.event.EventInfo;
import java.util.function.Consumer;
import java.util.function.Predicate;
eventFilter = new Predicate<EventInfo>() {
boolean test(info) {
//context.logInfo("EVENTAGENT-Info Objekt: " + info);
//filter here so you only consume events you need to analyse
return true;
}
};
eventListener = new Consumer<RevisionEvent>() {
void accept(event) {
//context.logInfo("EVENTAGENT-Event received for Revision" + event.getRevision());
//context.logInfo("EVENTAGENT-Changed Languages: " + event.getChangedLanguages());
changes = event.getChanges();
//context.logInfo("EVENTAGENT-Event.getChanges:" + changes);
it = changes.iterator();
while (it.hasNext()) {
change = it.next();
changeInfo = change.getEventInfo();
if (changeInfo.isEntity()) {
element = change.getElement();
entity = element.getEntity();
//...
}
}
}
};
eventAgent = context.requireSpecialist(IDProviderEventAgent.TYPE);
eventAgent.addListener(eventFilter,eventListener);
Thread.sleep(10000*60*1);
eventAgent.removeListener(eventListener);I hope that this is sufficient to create a corresponding module.
Important: To avoid performance issues, it is important to ensure that the filter only allows the necessary events!
Best regards,
Holger0
Please sign in to leave a comment.
Comments
3 comments