This content has been marked as final. Show 2 replies
Which API can be used to view all global attributes? Can anyone give example code code on how to do this?
When a session is created we are using a java plugin to create or seed an entity, this entity cannot be inferred because questions are asked directly about it. With our current implementation of the plugin we are using the OnSessionCreatedEvent handler to know when to create the entity, the problem is that the event handler is triggered when a session is loaded as well which causes the session to crash since the same entity already exists.
We also tried using the OnInvestigationStarted event handler and this is triggered on a load session as well.
Our idea was to determine within the rulebase whether the session is a new or load session by counting the entity instances and if they are greater than 0 then the session is a load session.
The problem is we have not been able to see this global attribute that is inferred, we have just been able to view screen data from the current screen.
The key to getting the values is getting a reference to the InterviewSession object. Once you have this reference you can access all the current session data.
Many event handlers provide this object, one way or another. The OnSessionCreatedEvent provides it directly, via its getCreatedSession() method.
A much better explanation than I could give on this is contained in the OPA Developer Help. Specifically on the page at:
InterviewSession myInterviewSession = OnSessionCreatedEvent.getCreatedSession();
An extensive code sample is provided on that page under the section "Sample code - Using Instance Data".