| Developing with the SDK > Using and Writing Data Models > Deciding Your Data Model Strategy |
Deciding Your Data Model Strategy |
INDEX
PREVIOUS
NEXT
|
First you should decide which classes in the model package are appropriate, depending on the characteristics of your existing business data and your requirements.
There are five levels of data model implementation, each appropriate for certain situations:
IlvDefaultSDMNode and IlvDefaultSDMLink. . These objects have an arbitrary set of user-defined properties, so the default model can represent all kinds of objects.
model package provides a specific SDM model for this case: ilog.views.sdm.model.IlvJDBCSDMModel. This model uses the JDBC API to access the database. All you need to do is configure the model with the database URL, the names of the tables containing the nodes and links, and a few other parameters.
get and set) for each Bean property.
ilog.views.sdm.model.IlvJavaBeanSDMModel. This model uses your JavaBeans as the nodes and links of a graph, so there is no duplication or additional memory consumption. The properties of nodes and links are read and written using the JavaBeans API. All you have to do is supply the set of JavaBeans that will make up your graph. For an example, see JavaBeans Example.
IlvAbstractSDMModel, and wrap your objects into new objects that implement the IlvSDMNode and IlvSDMLink interfaces. This requires an extra object allocation because of the indirection, but allows you to make use of the predefined interfaces for nodes and links. For an example, see NonJavaBeans Example: Abstract Model Variant.
ilog.views.sdm.model.IlvBasicSDMModel, and implement the methods that list the objects and retrieve the properties of each object. This requires more work but is more open, and may be preferable if all objects already exist. For an example, see NonJavaBeans Example: Basic Model Variant.
Table 2.1 summarizes the strategies described in this section.
Data Characteristics |
Recommended Class |
|---|---|
New or from XML | |
Database (display only) | |
JavaBeans | |
Java classes or other existing objects (for example, Swing) | |
If the graphic objects are to be moved interactively, SDM tries to store the new object locations as x,y properties in the model. However, the model can refuse to set the x,y properties, for example when it is a read-only model. To cope with such a case, the SDM library provides a metadata system that manages new properties as if they were stored in the true model.
To enable metadata, call ilog.views.sdm.IlvSDMEngine.setMetadataEnabled(true). Metadata is saved only in XML files. Other persistant mechanisms are responsible for saving metadata if they need to.
The default model does not need metadata.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |