How to Create an Oracle CEP Event Type as a Tuple Using the Event Type Repository Editor

Overview of Oracle CEP Events 2-13 Figure 2–4 EPN Editor For more information, see Section 6.1, Opening the EPN Editor .

3. Click the Event Type tab.

The Event Type tab appears as Figure 2–5 shows. Figure 2–5 Event Type Repository Editor

4. Click Add Event Type green plus sign.

A new event is added to the Event Type Definitions list with default name newEvent as Figure 2–6 shows. 2-14 Oracle Complex Event Processing Developers Guide Figure 2–6 Event Type Repository Editor - Tuple Event

5. In the Event Type Definitions list, select newEvent.

The properties of this event appear in the Event Type Details area as Figure 2–6 shows.

6. Enter a name for this event in the Type name field.

7. Click Properties defined declaratively.

8. Add one or more event properties: ■ Click Add Event Property green plus sign. A new row is added to the Event Type Details table. ■ Click in the Name column of this row and enter a property name. ■ Click in the Type column of this row and select a data type from the pull down menu. When you design your event, you must restrict your design to the even data types that Section 2.1.3.3, Event Types Specified as a Tuple describes. ■ For char data type properties only, click in the ’char’ Length column of this row and enter a value for the maximum length of this char property. Optionally, you may used the length attribute to specify the maximum length of the char value. The default length is 256 characters. The maximum length is java.lang.Integer.MAX_VALUE. If you need more than 256 characters you should specify an adequate length.

9. Click the Save button in the Eclipse tool bar or type CTRL-S.

The event is now in the event type repository. You can use the event type repository editor: a. To view the corresponding event type definition in the EPN assembly file, double-click the event type in the Event Type Definitions area. b. To delete this event, select the event type in the Event Type Definitions area and click Delete Event Type red x. 10. Use the event type: Overview of Oracle CEP Events 2-15 ■ Reference the event types using the EventTypeRepository introspection interface EventType in the Java code of the adapters and business logic POJO in your application: Service public void setEventTypeRepositoryEventTypeRepository etr { etr_ = etr; } ... handle events public void onInsertEventObject event throws EventRejectedException { get the event type for the current event instance EventType eventType = etr_.getEventTypeevent; get the event type name String eventTypeName = eventType.getTypeName; get the event property names String[] propNames = eventType.getPropertyNames; test if property is present ifeventType.isPropertyfromRate { get property value Object propValue = eventType.getPropertyfromRate.getValueevent; } ... } For more information, see Section 2.7, Accessing the Event Type Repository . ■ Access the event types from Oracle CQL and EPL rules: The following Oracle CQL rule shows how you can reference the CrossRateEvent in a SELECT statement: query id=FindCrossRatesRule[CDATA[ select a.price b.price + 0.05 as internalPrice, a.fromRate as crossRate1, b.toRate as crossRate2 from FxQuoteStream [range 1] as a, FxQuoteStream [range 1] as b where NOT a.price IS NULL and NOT b.price IS NULL and a.toRate = b.fromRate ]]query

2.3.2 How to Create an Oracle CEP Event Type as a Tuple Manually

This procedure describes how to create and register an Oracle CEP event type declaratively in the EPN assembly file as a tuple. Oracle recommends that you create an Oracle CEP event type as a JavaBean see Section 2.2.2, How to Create an Oracle CEP Event Type as a JavaBean Manually . For more information on valid event type data types, see Section 2.1.3.3, Event Types Specified as a Tuple . 2-16 Oracle Complex Event Processing Developers Guide To create an Oracle CEP event type as a tuple: 1. Decide on the properties your event type requires. When you design your event, you must restrict your design to the even data types that Section 2.1.3.3, Event Types Specified as a Tuple describes. 2. Register your event type declaratively in the Oracle CEP event type repository: To register declaratively, edit the EPN assembly file using the wlevs:event-type-repository element wlevs:event-type child element as Example 2–8 shows. Example 2–8 EPN Assembly File event-type-repository wlevs:event-type-repository wlevs:event-type type-name=CrossRateEvent wlevs:properties wlevs:property name=price type=double wlevs:property name=fromRate type=char wlevs:property name=toRate type=char wlevs:properties wlevs:event-type wlevs:event-type-repository At runtime, Oracle CEP generates a bean instance of CrossRateEvent for you. The CrossRateEvent has three properties: price, fromRate, and toRate. For more information on the valid values of the type attribute, see Section 2.1.3.3, Event Types Specified as a Tuple . 3. Use the event type: ■ Reference the event types using the EventTypeRepository introspection interface EventType in the Java code of the adapters and business logic POJO in your application: Service public void setEventTypeRepositoryEventTypeRepository etr { etr_ = etr; } ... handle events public void onInsertEventObject event throws EventRejectedException { get the event type for the current event instance EventType eventType = etr_.getEventTypeevent; get the event type name String eventTypeName = eventType.getTypeName; get the event property names String[] propNames = eventType.getPropertyNames; test if property is present ifeventType.isPropertyfromRate { get property value Object propValue = eventType.getPropertyfromRate.getValueevent; } ... } For more information, see Section 2.7, Accessing the Event Type Repository .