Situation:
I found a forum article that describes a custom plugin to trigger an event.
I think that I may be able to use the same CP to activate and deactivate events.
I start by creating a DB table that will contain the typed ID from each backend database event table (file, FTP, timer, etc.) for events with the activateFlag = '1'. Then I feed the resulting list into a custom plugin.
The sample below is using process variables to get the typed ID, but I will change that to consuming a stream before I am done. My problem is that I don't have java docs for the com.adeptia.indigo.event.Event or EventUtils classes. Will event.activate() do the required steps to activate an event, and what is the "arg0" string that event.deactivateEvent is expecting?
import javax.security.auth.Subject;
import com.adeptia.indigo.event.Event;
import com.adeptia.indigo.storage.Entity;
import com.adeptia.indigo.event.EventUtils;
import com.adeptia.indigo.logging.Logger;
Logger log = service.getLogger();
String eventID = (String) context.get("eventTypeId"); String activate =
(String) context.get("active"); Subject sub = service.getSubject(); Entity entity = EventUtils.getEntity(eventID, sub); if (entity != null) {
log.info("entity name: "+entity.getEntityName());
Event event = ((Event) entity);
event.setSubject(sub);
if (activate.equalsIgnoreCase("true")) {
event.activate();
}
else {
event.deactivateEvent(arg0, sub);
}
}
Solution:
"event.activate()" will activate the event. In "event.deactivateEvent(arg0, sub)", "arg0" is the typed Id. You need to pass the "typed Id" and "subject" to the deactivate() method in order to deactivate any particular event. You can get "subject" by using "service.getSubject()".
Comments
0 comments
Article is closed for comments.