DataView manager
DataViews provide a mechanism for exposing a view of application data to remote clients, such as Apama dashboards. CMF-based applications are free to use the standard DataView support events supplied with the Apama CEP platform and documented in Developing Apama Applications. However, the CMF provides an alternative support framework for generating DataViews, based around an event object that applications interact with by calling event actions rather than by routing events. This approach is likely to be more efficient than the standard one in applications that make heavy use of DataViews.
The DataView Manager component is part of the Data View bundle. Typically, an instance of the com.apama.dataview.DataViewManager event object will be embedded within another object to create a specific DataView, such as the market data DataViews described in a later section. To create a custom DataView, a CMF application should create a Manager object and then call its define() actions to define the characteristics of the DataView:
com.apama.dataview.DataViewManager dvManager :=
new com.apama.dataview.DataViewManager;
com.apama.dataview.DataViewResult dvResult;
sequence<string> fieldNames := ["symbol", "avgPrice"];
sequence<string> fieldTypes := ["string", "float"];
sequence<string> keyFieldsNames := ["symbol" ];
dvResult := dvManager.define(
"ExampleDataView", // dataview name
"Example DataView", // display name
"A sample DataView to demonstrate the CMF DataView Publisher",// description
fieldNames, // field names
fieldTypes, // field types
keyFieldsNames, // key fields
context.current() ); // main context
// The contents of the DataView can then be manipulated using the
// addDataViewItem, addOrUpdateDataViewItem, addOrDeltaUpdateDataViewItem,
// updateFullDataViewItem and deleteDataViewItemByKeyFields actions:
// Define field values and add a row to the DataView
sequence<string> row := ["EUR/GBP", "0.89"];
dvResult := dvManager.addDataViewItem("admin", -1.0, row);
// Add a second row
row := ["GBP/USD", "1.52"];
dvResult := dvManager.addOrUpdateDataViewItem("admin", -1.0, row);
// Update fields in an existing row
row := ["EUR/GBP", "0.88"];
dvResult := dvManager.updateFullDataViewItem(-1, -1.0, row);
// Remove some rows
sequence<string> key := ["EUR/GBP"];
dvResult := dvManager.deleteDataViewItemByKeyFields(key);
dvManager.deleteAllDataViewItems();
If an application needs to completely remove a DataView definition, for example to ensure that it no longer appears in the Apama Scenario Browser, it should call the undefine() action on the Manager object.