Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

After an event is configured in Canvas Studio, a simple Java handler is necessary to trigger the event. Let's assume that the event is a login activity, so when the user logs in, the event has to be raised to send an alert and an audit. Once the login event is configured in Canvas Studio, the Java Handler triggers the event, thereby facilitating the means for receiving alerts. The following code snippet is a sample Java Handler to raise an event:

Code Block
languagejava
Event eventToBeRaised = Event.getEventFor(<EVENT_ID>); 
HashMap eventData = new HashMap(); 
EventDispatcher.getInstance().raiseEvent(eventToBeRaised , eventData);


To raise an event from the Java handler class, you must specify the event object and event type, as shown in the following code snippet:

Note

eventData serves as the map which contains the values for the keys of the audit data.


Code Block
languagejava
EventDispatcher.getInstance().raiseEvent(Event eventObj,Map eventData); // eventObj is the Object of the Event Type

The getEventFor and getEvent methods can be used to raise events from the handler classes, as shown in the following code snippet:

Code Block
languagejava
Event.getEventFor(String productCode,String subProductCode,String functionCode,String actionCode)
Event.getEvent(Long eventId)

To include the mandatory audit data in an event, specify the event mandatory data, as shown in the following code snippet: 

Note

The three following methods can be used to prepare mandatory audit data: 

  1. AuditConstants.MANDATORY_AUDIT_META_DATA
  2. AuditConstants.MANDATORY_AUDIT_META_DATA_OLD_STATE
  3. AuditConstants.MANDATORY_AUDIT_META_DATA_NEW_STATE


Code Block
languagejava
EventHandlerFrameworkConstants.getEventMandatoryDataFrom(CanvasRequestVO request,Event eventObj,String referenceNo