public abstract class IlpAbstractSDMAdapter extends Object implements DataSourceListener
This class implements an adapter from a TGO business model
(IlpDataSource
) to an SDM model
(IlvSDMModel
).
The TGO business model is organized hierarchically from root objects down to child objects. The SDM model is also organized hierarchically, so the TGO hierarchy is preserved in the SDM model (see Limitations below).
TGO business objects IlpObject
have attributes and SDM
model objects have properties. TGO attributes can be fairly complex
(e.g.: IltObject.ObjectStateAttribute
) while SDM properties are
designed to be simpler (which facilitates styling). Therefore some
TGO attributes can be mapped into one or more SDM properties (e.g.:
IltObject.PositionAttribute
, which has to be decoded into SDM
properties x
and y
).
All logic required to map TGO business objects and their attributes
into SDM model objects and their properties is contained in this class.
Method getSDMModel()
returns an implementation of
IlvSDMModel
that corresponds to the business data
in the TGO data source.
The TGO business object class (IlpClass
) is mapped to the SDM
model symbolic type (or "tag").
There is no automatic mapping between the TGO attribute model
(IlpAttribute
) and the String/Object-based SDM property model.
Relevant TGO attributes must be bound to SDM properties through the
attribute binding API ((@link IlpAbstractAttributeBinding
).
Methods addAttributeBinding(IlpClass, IlpAbstractAttributeBinding)
and removeAttributeBinding(IlpClass, IlpAbstractAttributeBinding)
should be used to add attribute bindings to the TGO-SDM adapter.
Limitations:
IltLinkSet
is not supported as the SDM model does not
support this type of hierarchy.IltLinkBundle
is not supported as the SDM model does
not support this type of hierarchy.Constructor and Description |
---|
IlpAbstractSDMAdapter()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttributeBinding(IlpClass tgoClass,
IlpAbstractAttributeBinding binding)
Adds a TGO attribute binding.
|
void |
addAttributeBinding(String tgoClassName,
IlpAbstractAttributeBinding binding)
Adds a TGO attribute binding.
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a
PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Adds a
PropertyChangeListener for a specific property. |
void |
batchEnded(DataSourceEvent evt)
Called when a batch of modifications of the data source has ended.
|
void |
batchStarted(DataSourceEvent evt)
Called when a batch of modifications of the data source has started.
|
protected abstract void |
dataSourceAddObject(IlpObject object)
Adds a new object in the TGO data source.
|
protected abstract void |
dataSourceClear()
Clears the TGO data source completely.
|
protected abstract void |
dataSourceEndBatch()
Stops the TGO data source batching mode.
|
protected abstract void |
dataSourceRemoveObject(IlpObject object)
Removes an object from the TGO data source.
|
protected abstract void |
dataSourceSetLink(IlpObject link,
Object fromId,
Object toId)
Sets the link endpoint relationship between a link and two nodes in the
TGO data source.
|
protected abstract void |
dataSourceSetParent(IlpObject object,
IlpObject parent)
Sets a parent-child relationship in the TGO data source.
|
protected abstract void |
dataSourceStartBatch()
Starts the TGO data source batching mode.
|
protected void |
firePropertyChange(String property,
Object oldValue,
Object newValue)
Fires a property change event of the type
PropertyChangeEvent . |
List<IlpClass> |
getAcceptedClasses()
Returns the list of accepted classes.
|
Set<IlpAbstractAttributeBinding> |
getBindings(IlpClass tgoClass)
Accesses all attribute bindings for a given TGO class.
|
Set<IlpAbstractAttributeBinding> |
getBindings(String tgoClassName)
Accesses all attribute bindings for a given TGO class.
|
IlpDataSource |
getDataSource()
Returns the data source.
|
List<IlpClass> |
getExcludedClasses()
Returns the list of excluded classes.
|
IlpFilter |
getFilter()
Accesses the adapter filter.
|
protected Logger |
getSDMLogger()
Accesses the proper logger for handling log messages.
|
IlvSDMModel |
getSDMModel()
Access the SDM model implementation to be used with SDM views.
|
boolean |
isRepresenting()
Returns
true if the adapter is active, that is,
if it represents objects from a TGO data source in an SDM model. |
void |
objectAttributeChanged(DataSourceObjectEvent evt)
Called when an object attribute has changed.
|
void |
objectsAdded(DataSourceEvent evt)
Called when objects have been added to the data source.
|
void |
objectsRemoved(DataSourceEvent evt)
Called when objects have been removed from the data source.
|
void |
objectStructureChanged(DataSourceObjectEvent evt)
Called when an object structure has changed.
|
void |
refilter()
Enforces the current filtering settings (filter, inclusion, and
exclusion of business classes) in the adapter.
|
protected void |
refilterObjects()
Applies the filtering settings (filter, inclusion, and exclusion of
business classes) to the adapter.
|
void |
removeAllAttributeBindings(IlpClass tgoClass)
Removes all TGO attribute bindings for a given class.
|
void |
removeAllAttributeBindings(String tgoClassName)
Removes all TGO attribute bindings for a given class.
|
void |
removeAttributeBinding(IlpClass tgoClass,
IlpAbstractAttributeBinding binding)
Removes a TGO attribute binding.
|
void |
removeAttributeBinding(String tgoClassName,
IlpAbstractAttributeBinding binding)
Removes a TGO attribute binding.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a
PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Removes a
PropertyChangeListener for a given property name. |
void |
setAcceptedClasses(List<IlpClass> newInclusion)
Sets the list of business classes (
IlpClass that must be
accepted by this adapter. |
void |
setDataSource(IlpDataSource dataSource)
Sets the data source.
|
void |
setExcludedClasses(List<IlpClass> newExclusion)
Sets the list of business classes (
IlpClass that must be
excluded by this adapter. |
void |
setFilter(IlpFilter newfilter)
Sets a TGO filter (
IlpFilter to the adapter. |
protected boolean |
testObject(IlpObject ilpObject)
Tests whether a given TGO business object must be represented or
not, based on the filtering settings.
|
protected Logger getSDMLogger()
protected void firePropertyChange(String property, Object oldValue, Object newValue)
PropertyChangeEvent
.property
- Property that was changedoldValue
- Old valuenewValue
- New valuepublic void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
to the listener list.
The listener is registered for all properties.listener
- The PropertyChangeListener
to be added.public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
from the listener list.listener
- The PropertyChangeListener
to be removed.public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
PropertyChangeListener
for a specific property.
The listener is invoked only when a call to
firePropertyChange(String, Object, Object)
addresses the given
property name specifically.propertyName
- The name of the property to listen to.listener
- The PropertyChangeListener
to be added.public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
PropertyChangeListener
for a given property name.propertyName
- The name of the property that was listened to.listener
- The PropertyChangeListener
to be removed.public IlvSDMModel getSDMModel()
Access the SDM model implementation to be used with SDM views.
The returned SDM model implementation is a live representation of the business data in the TGO data source.
IlvSDMModel
interface representing
the TGO data sourcepublic boolean isRepresenting()
Returns true
if the adapter is active, that is,
if it represents objects from a TGO data source in an SDM model.
This is a bound property, which means that a property event
(PropertyChangeEvent
) is fired when the adapter
changes its representing state.
public void setDataSource(IlpDataSource dataSource)
Sets the data source.
This is a bound property, which means that a property event
(PropertyChangeEvent
) is fired when a data
source is set or updated in the adapter.
dataSource
- The data source to be used by this adapter.public IlpDataSource getDataSource()
Returns the data source.
This is a bound property, which means that a property event
(PropertyChangeEvent
) is fired when the adapter
changes its representing state.
public void batchEnded(DataSourceEvent evt)
DataSourceListener
batchEnded
in interface DataSourceListener
public void batchStarted(DataSourceEvent evt)
DataSourceListener
DataSourceEvent
and DataSourceObjectEvent
.batchStarted
in interface DataSourceListener
public void objectAttributeChanged(DataSourceObjectEvent evt)
DataSourceListener
objectAttributeChanged
in interface DataSourceListener
public void objectStructureChanged(DataSourceObjectEvent evt)
DataSourceListener
objectStructureChanged
in interface DataSourceListener
public void objectsAdded(DataSourceEvent evt)
DataSourceListener
objectsAdded
in interface DataSourceListener
public void objectsRemoved(DataSourceEvent evt)
DataSourceListener
objectsRemoved
in interface DataSourceListener
protected abstract void dataSourceStartBatch()
protected abstract void dataSourceEndBatch()
protected abstract void dataSourceSetParent(IlpObject object, IlpObject parent)
object
- The child objectparent
- The parent objectprotected abstract void dataSourceAddObject(IlpObject object)
object
- The object to be addedprotected abstract void dataSourceRemoveObject(IlpObject object)
object
- The object to be removedprotected abstract void dataSourceSetLink(IlpObject link, Object fromId, Object toId)
link
- The link being setfromId
- The identifier of the from endpointtoId
- The identifier of the to endpointprotected abstract void dataSourceClear()
public void addAttributeBinding(IlpClass tgoClass, IlpAbstractAttributeBinding binding) throws IlpInvalidBindingException
Adds a TGO attribute binding.
A TGO attribute binding is defined by
IlpAbstractAttributeBinding
and is used to bind a TGO attribute
and an SDM model property. The binding support can also apply conversions
and validations to the value.
The binding is associated with a TGO class (IlpClass
) in a way
that all instances of that class will share the same binding.
This method will try to validate the binding attribute type against the given TGO class, logging a warning message to indicate type inconsistencies (a type inconsistency does not necessarily means an error).
Note that attribute and property values are internally handled as
a generic Object
, so the binding type parameters are internally
treated as such.
Attribute binding is not allowed when the adapter is representing
(isRepresenting()
is true
).
tgoClass
- The TGO class for the bindingbinding
- The TGO attribute binding being addedIlpInvalidBindingException
- when adapter is currently representing
objects from a data source.public void addAttributeBinding(String tgoClassName, IlpAbstractAttributeBinding binding) throws IlpInvalidBindingException
Adds a TGO attribute binding.
A TGO attribute binding is defined by
IlpAbstractAttributeBinding
and is used to bind a TGO attribute
and an SDM model property. The binding support can also apply conversions
and validations to the value.
The binding is associated with a TGO class (IlpClass
) in a way
that all instances of that class will share the same binding.
This method should be used to bind attributes of custom TGO classes that have not yet been loaded, or that are dynamically declared. No type validation is performed.
Note that attribute and property values are internally handled as
a generic Object
, so the binding type parameters are internally
treated as such.
Attribute binding is not allowed when the adapter is representing
(isRepresenting()
is true
).
tgoClassName
- The string representing the TGO class for the bindingbinding
- The TGO attribute binding being addedIlpInvalidBindingException
- when adapter is currently representing
objects from a data source.public void removeAttributeBinding(IlpClass tgoClass, IlpAbstractAttributeBinding binding) throws IlpInvalidBindingException
Removes a TGO attribute binding.
Attribute binding is not allowed when the adapter is representing
(isRepresenting()
is true
).
tgoClass
- The TGO class for the bindingbinding
- The TGO attribute binding being addedIlpInvalidBindingException
- when the adapter is currently representing
objects from a data source.public void removeAttributeBinding(String tgoClassName, IlpAbstractAttributeBinding binding) throws IlpInvalidBindingException
Removes a TGO attribute binding.
Attribute binding is not allowed when the adapter is representing
(isRepresenting()
is true
).
tgoClassName
- The TGO class name for the bindingbinding
- The TGO attribute binding being addedIlpInvalidBindingException
- when the adapter is currently representing
objects from a data source.public void removeAllAttributeBindings(IlpClass tgoClass) throws IlpInvalidBindingException
Removes all TGO attribute bindings for a given class.
Attribute binding is not allowed when the adapter is representing
(isRepresenting()
is true
).
tgoClass
- The TGO class for the bindingIlpInvalidBindingException
- when the adapter is currently representing
objects from a data source.public void removeAllAttributeBindings(String tgoClassName) throws IlpInvalidBindingException
Removes all TGO attribute bindings for a given class.
Attribute binding is not allowed when the adapter is representing
(isRepresenting()
is true
).
tgoClassName
- The TGO class name for the bindingIlpInvalidBindingException
- when the adapter is currently representing
objects from a data source.public Set<IlpAbstractAttributeBinding> getBindings(IlpClass tgoClass)
Accesses all attribute bindings for a given TGO class.
Please note that the binding type parameters are internally
cast to Object
, which is the same type used for attribute
and property values.
tgoClass
- The TGO class for the bindingSet
of all TGO attribute bindings for the given classpublic Set<IlpAbstractAttributeBinding> getBindings(String tgoClassName)
Accesses all attribute bindings for a given TGO class.
Please note that the binding type parameters are internally
cast to Object
, which is the same type used for attribute
and property values.
tgoClassName
- The TGO class name for the bindingSet
of all TGO attribute bindings for the given classpublic void setFilter(IlpFilter newfilter)
Sets a TGO filter (IlpFilter
to the adapter.
The new filter is only applied if it is different from the existing
filter. To perform this validation, the method equals
is
used in the filter instances.
The data source objects are filtered so that only IlpObject
instances
that pass through the filter are added to the model.
Modifying the list of excluded classes forces all objects to be removed and re-inserted into the adapter.
This is a bound property, which means that a property event
(PropertyChangeEvent
) is fired when the adapter
filter is set and/or updated.
newfilter
- The filter to be used to filter business objects. This
parameter can be null
, which means that the business
objects are not filtered.public IlpFilter getFilter()
Accesses the adapter filter
.This is a bound property, which means that a property event
(PropertyChangeEvent
) is fired when the adapter
filter is set and/or updated.
setFilter(IlpFilter)
public void setExcludedClasses(List<IlpClass> newExclusion)
Sets the list of business classes (IlpClass
that must be
excluded by this adapter.
By default, the list is empty, which means that all business objects are accepted. The objects that do not match the current filter criteria are excluded.
Business class exclusion follows the object hierarchy, so that any subclass of an excluded business class is also excluded.
Modifying the list of excluded classes forces all objects to be removed and re-inserted in the adapter.
This is a bound property, which means that a property event
(PropertyChangeEvent
) is fired when the
business class exclusion list of the adapter is set and/or updated.
newExclusion
- The list of IlpClass
. Note that
this list is copied to the internal list of excluded
classes.public List<IlpClass> getExcludedClasses()
Returns the list of excluded classes.
This is a bound property, which means that a property event
(PropertyChangeEvent
) is fired when the
business class exclusion list of the adapter is set and/or updated.
public void setAcceptedClasses(List<IlpClass> newInclusion)
Sets the list of business classes (IlpClass
that must be
accepted by this adapter.
By default, the list is empty. This means that all business objects are accepted by the adapter. The objects that do not match the current filter criteria are excluded.
Business class inclusion follows the object hierarchy, so that any subclass of an included business class is also included.
Modifying the list of accepted classes forces all objects to be removed and re-inserted into the adapter.
This is a bound property, which means that a property event
(PropertyChangeEvent
) is fired when the
business class inclusion list of the adapter is set and/or updated.
newInclusion
- The list of IlpClass
. Note that
this list is copied to the internal list of included
classes.public List<IlpClass> getAcceptedClasses()
Returns the list of accepted classes.
This is a bound property, which means that a property event
(PropertyChangeEvent
) is fired when the
business class inclusion list of the adapter is set and/or updated.
public void refilter()
Enforces the current filtering settings (filter, inclusion, and exclusion of business classes) in the adapter.
The filtering is only applied if the objects are being
represented (isRepresenting()
).
The default implementation calls refilterObjects
.
protected void refilterObjects()
Applies the filtering settings (filter, inclusion, and exclusion of business classes) to the adapter.
protected boolean testObject(IlpObject ilpObject)
Tests whether a given TGO business object must be represented or not, based on the filtering settings.
true
if there is no filtering or
if the IlpObject
passes through the filter and the
excluded class list.setFilter(IlpFilter)
,
setExcludedClasses(List)
,
setAcceptedClasses(List)
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.