public abstract class IlpAbstractAdapter extends Object implements DataSourceListener, IlpRepresentationObjectMapper
Provides support for the association with a data source, filtering, and JavaBean property change events.
This abstract adapter assumes that representation objects are created only when there is a data source AND a model. If one of those is removed, all representation objects are cleared.
Constructor and Description |
---|
IlpAbstractAdapter()
Default constructor.
|
IlpAbstractAdapter(IlpContext context)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addAdapterListener(AdapterListener l)
Adds a listener to the adapter.
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a
PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Adds a
PropertyChangeListener for a specific property. |
protected void |
addRepresentation(IlpRepresentationObject ro)
Adds the representation object.
|
void |
applyConfiguration(Map<String,Object> properties)
Applies the given configuration to the adapter.
|
void |
batchEnded(DataSourceEvent e)
Called when a batch of modifications of the data source has ended.
|
void |
batchStarted(DataSourceEvent e)
Called when a batch of modifications of the data source has started.
|
protected void |
beginRepresentation()
Will start representing objects if this was not being done and there is
a model and a data source.
|
protected void |
clearIdToRepresentationObjectMap()
Clears all the representation objects from the adapter.
|
protected abstract void |
clearRepresentationObjects()
Called when all representation objects should be cleared.
|
protected abstract IlpRepresentationObject |
createRepresentationObject(IlpObject ilpObject)
This method creates a representation object
and stores it in the identifier-to-RO map.
|
protected void |
doApplyConfiguration(Map<String,Object> properties)
Applies the new configuration to this adapter.
|
protected void |
endBatch()
Tells the model that a temporary inhibition of events
is terminated and sends the events buffered since
the last call to
startBatch . |
protected abstract void |
fillModel()
Fills the model with the representation objects.
|
protected void |
firePropertyChange(String property,
Object oldValue,
Object newValue)
Fires a property change event.
|
void |
fireRepresentationObjectsAdded(List<IlpRepresentationObject> representationObjects)
Fires a representation object added event for a list of objects.
|
void |
fireRepresentationObjectsRemoved(List<IlpRepresentationObject> representationObjects)
Fires a representation object removed event for a list of objects.
|
IlpContext |
getContext()
Returns the context.
|
IlpDataSource |
getDataSource()
Returns the data source.
|
List<IlpClass> |
getExcludedClasses()
Returns the list of excluded classes.
|
IlpFilter |
getFilter()
Returns the filter.
|
protected Collection<IlpObject> |
getPossibleRoots()
This method returns a list of possible root objects.
|
IlpRepresentationObject |
getRepresentationObject(IlpObject ilpObject)
Returns the
IlpRepresentationObject used to
represent the given IlpObject . |
IlpRepresentationObject |
getRepresentationObject(Object identifier)
Returns the
IlpRepresentationObject used to
represent a business object identified by the given identifier. |
Collection<IlpRepresentationObject> |
getRepresentationObjects()
Returns all the representation objects.
|
protected IlSynchronizationStrategy |
getSyncStrategy()
Returns the synchronization strategy used by this adapter.
|
protected boolean |
hasConfigurationChanged(Map<String,Object> properties)
Checks if the configuration has changed in comparison
with the current configuration.
|
abstract boolean |
hasModel()
Returns
true if the adapter is connected to a model. |
boolean |
hasRepresentationObject(IlpRepresentationObject ro)
Returns
true if the given
IlpRepresentationObject is contained in this map. |
boolean |
hasRepresentationObjects()
Returns
true if the adapter contains representation objects. |
protected void |
initializeExcludedClasses()
Initializes the predefined list of excluded classes.
|
protected void |
initializeRepresentationObjects()
Identifies all root objects and creates their representation,
starting to feed the representation model with new objects.
|
boolean |
isRepresenting()
Returns
true if the adapter is active, that is, representing
objects from a data source in a model. |
void |
refilter()
Applies the current filter to the adapter objects.
|
protected void |
refilterObjects()
Applies the filter to the objects that exist in the attached
datasource.
|
void |
removeAdapterListener(AdapterListener l)
Removes a listener from the adapter.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a
PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Removes a
PropertyChangeListener for a specific property. |
protected IlpRepresentationObject |
removeRepresentation(Object id)
Removes the representation object that corresponds to the given
identifier.
|
protected void |
replaceExcludedClasses(List<IlpClass> newExclusion)
This method is called to replace the existing excluded class list
with a new one.
|
protected void |
setBatchable(IlvBatchable batchable)
Sets the batch modification delegate used by this adapter.
|
void |
setDataSource(IlpDataSource dataSource)
Sets the data source.
|
void |
setExcludedClasses(List<IlpClass> newExclusion)
Sets the list of business classes that should be excluded by
this adapter.
|
void |
setFilter(IlpFilter newfilter)
Sets the filter.
|
protected void |
startBatch()
Tells the model temporarily not to send events.
|
protected void |
stopRepresentation()
Will stop representing objects.
|
protected boolean |
testObject(IlpObject ilpObject)
Returns
true if an object of the data source should be
represented. |
protected boolean |
testRootObject(IlpObject ilpObject)
Returns
true if an object of the data source should be
represented when iterating on all data source objects. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
objectAttributeChanged, objectsAdded, objectsRemoved, objectStructureChanged
public IlpAbstractAdapter(IlpContext context)
Creates an adapter that uses the context.
context
- The context used by this adapter.public IlpAbstractAdapter()
Creates an adapter using the default context.
IlpSystem.GetDefaultContext()
public IlpContext getContext()
public void addAdapterListener(AdapterListener l)
l
- The listener to add.public void removeAdapterListener(AdapterListener l)
l
- The listener to remove.public void fireRepresentationObjectsAdded(List<IlpRepresentationObject> representationObjects)
representationObjects
- The representation objects that have been
added.
Cannot be null
.public void fireRepresentationObjectsRemoved(List<IlpRepresentationObject> representationObjects)
representationObjects
- The representation objects that have been
removed.
Cannot be null
).public IlpRepresentationObject getRepresentationObject(Object identifier)
IlpRepresentationObject
used to
represent a business object identified by the given identifier.identifier
- The identifier of the IlpObject
for which the representation object is required.public IlpRepresentationObject getRepresentationObject(IlpObject ilpObject)
IlpRepresentationObject
used to
represent the given IlpObject
.getRepresentationObject
in interface IlpRepresentationObjectMapper
ilpObject
- The IlpObject
for which the representation
object is required.public boolean hasRepresentationObject(IlpRepresentationObject ro)
true
if the given
IlpRepresentationObject
is contained in this map.hasRepresentationObject
in interface IlpRepresentationObjectMapper
ro
- The IlpRepresentationObject
.public boolean hasRepresentationObjects()
true
if the adapter contains representation objects.protected void clearIdToRepresentationObjectMap()
public Collection<IlpRepresentationObject> getRepresentationObjects()
protected void addRepresentation(IlpRepresentationObject ro)
ro
- Representation objectprotected IlpRepresentationObject removeRepresentation(Object id)
id
- Object identifierpublic boolean isRepresenting()
true
if the adapter is active, that is, representing
objects from a data source in a model.
This is a bound property.
public abstract boolean hasModel()
true
if the adapter is connected to a model.public void setDataSource(IlpDataSource dataSource)
The representation objects are created if the adapter also has model. Note that the adapter also waits for a model to listen to data source events.
This is a bound property.
dataSource
- The data source used by adapter.public IlpDataSource getDataSource()
This is a bound property.
public void setFilter(IlpFilter newfilter)
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 only IlpObject
s
that pass through the filter are added to the model.
This is a bound property.
Note: This property can be customized using CSS, as illustrated below:
Adapter { filter: @+filterDef; } Subobject#filterDef { ... }
newfilter
- The filter to use to filter business objects. This
parameter may be null
, meaning the business
objects are not filtered.public IlpFilter getFilter()
This is a bound property.
setFilter(IlpFilter)
public void setExcludedClasses(List<IlpClass> newExclusion)
By default, the list is empty. This means that all business objects will be converted to representation objects. However, this does not include the ones that do not match the current filter criteria.
If you specify business classes in the list, business objects from the given classes or from one of its subclasses will be automatically filtered. Their representation will not be created in the associated representation model.
The current implementation is not very efficient, as it removes all representation objects and recreates them.
Note:This property can be customized using CSS, as illustrated below:
Adapter { excludedClasses: "business class A, business class B"; }
To represent all classes:
Adapter { excludedClasses: ''; }
newExclusion
- The list of IlpClass
. Note that
this list is copied to the internal list of excluded
classes.public List<IlpClass> getExcludedClasses()
It may well be an empty list.
protected void initializeExcludedClasses()
protected void replaceExcludedClasses(List<IlpClass> newExclusion)
newExclusion
- New exclusion list.setExcludedClasses(java.util.List<ilog.cpl.model.IlpClass>)
public void batchStarted(DataSourceEvent e)
batchStarted
in interface DataSourceListener
public void batchEnded(DataSourceEvent e)
batchEnded
in interface DataSourceListener
protected void setBatchable(IlvBatchable batchable)
protected void startBatch()
endBatch
.
This method ensures that the startBatch
method of the
model is called with the correct synchronization strategy; that is, in
the event thread in a regular application.
Note: The adapter needs a model for this method to work.
Note: Use
IlpAbstractDataSource.startBatch()
instead.
IlpAbstractDataSource.startBatch()
,
endBatch()
protected void endBatch()
startBatch
.
This method ensures that the endBatch
method of the
model is called with the correct synchronization strategy; that is, in
the event thread in a regular application.
Note:The adapter needs a model for this method to work.
Note:Use
IlpAbstractDataSource.endBatch()
instead.
IlpAbstractDataSource.endBatch()
,
startBatch()
protected void firePropertyChange(String property, Object oldValue, Object newValue)
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.
This removes a PropertyChangeListener
that was registered
for all properties.listener
- The PropertyChangeListener
to be removed.public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
PropertyChangeListener
for a specific property. The
listener will be invoked only when a call to
firePropertyChange
names that specific property.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 specific property.propertyName
- The name of the property that was listened to.listener
- The PropertyChangeListener
to be removed.protected IlSynchronizationStrategy getSyncStrategy()
The synchronization strategy is used each time an object is inserted into or removed from the model.
The synchronization strategy is obtained from the context.
protected boolean testObject(IlpObject ilpObject)
true
if an object of the data source should be
represented.
By default, it returns true
if there is no filtering or
if the IlpObject
passes through the filter and the
excluded class list.
protected boolean testRootObject(IlpObject ilpObject)
Returns true
if an object of the data source should be
represented when iterating on all data source objects.
An object is represented during this iteration if this method
returns true
and the testObject(IlpObject)
method returns true
.
By default, this method returns true
.
protected void refilterObjects()
The default implementation calls clearRepresentationObject
and then initializeRepresentationObject
.
public void refilter()
The filter is only applied if the objects are being
represented (isRepresenting()
).
The default implementation calls refilterObjects
.
protected Collection<IlpObject> getPossibleRoots()
protected void stopRepresentation()
protected void beginRepresentation()
protected void initializeRepresentationObjects()
beginRepresentation()
protected abstract void fillModel()
protected abstract void clearRepresentationObjects()
protected abstract IlpRepresentationObject createRepresentationObject(IlpObject ilpObject)
null
in which case it does
not store anything in the map.public void applyConfiguration(Map<String,Object> properties)
properties
- protected boolean hasConfigurationChanged(Map<String,Object> properties)
properties
- true
if one of the properties being set is different
from the current value in the adapter.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.