Implementing the TGO-SDM adapter
The TGO-SDM adapter is defined by the class
IlpAbstractSDMAdapter. This class defines the basic implementation required to adapt the JViews TGO business model with object attributes stored in the data source to an SDM model structure with corresponding object properties. A default instance is implemented by the class
IlpDefaultSDMAdapter and is based on a mutable data source (
IlpMutableDataSource) and a basic SDM model (
IlvBasicSDMModel).
The TGO-SDM adapter encapsulates a given TGO data source and provides an SDM model (
IlvSDMModel) façade that can be passed to a JViews Diagrammer component for further rendering. CSS styling and any other custom rendering is performed entirely by the JViews Diagrammer component with no relation to the JViews TGO visual representation.
The following code example illustrates a basic implementation of the TGO-SDM adapter:
// Obtain a reference to a TGO data source and Diagrammer component
IlpDefaultDataSource datasource = ...
IlvDiagrammer diagrammer = ...
// Instantiate a TGO-SDM Adapter
IlpDefaultSDMAdapter adapter = new IlpDefaultSDMAdapter();
// Configure the default attribute bindings
adapter.addDefaultBindings();
// Once adapter is configured, start representation by adding a data source
adapter.setDataSource(datasource);
// Set SDM Model from adapter in Diagrammer component
diagrammer.getView().setModel(adapter.getSDMModel());
This example shows that the constructor of the TGO-SDM adapter has no arguments and instantiates an empty adapter that is not yet ready to be used. After the adapter has been instantiated, the next step is to configure the attribute bindings by invoking the addDefaultBindings() method. This method provides a convenient way to configure the default TGO-SDM adapter with all the predefined attribute bindings. When configured, the adapter is ready to be used. Setting a data source enables the adapter representation, that is, the adapter creates an SDM model that corresponds to the data source hierarchy and attribute bindings.
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.