ilog.cpl.datasource
Class IlpAbstractHierarchyAdapter

java.lang.Object
  extended by ilog.cpl.datasource.IlpAbstractAdapter
      extended by ilog.cpl.datasource.IlpAbstractHierarchyAdapter
All Implemented Interfaces:
DataSourceListener, IlpRepresentationObjectMapper, EventListener
Direct Known Subclasses:
IlpAbstractNodeAdapter, IlpAbstractTreeAdapter

public abstract class IlpAbstractHierarchyAdapter
extends IlpAbstractAdapter

Abstract adapter for representing hierarchies of objects.

This class provides support for features that are common to the Tree, Network and Equipment adapters.

Since:
JTGO 3.0

Constructor Summary
IlpAbstractHierarchyAdapter()
          Default constructor.
IlpAbstractHierarchyAdapter(IlpContext context)
          Constructor.
 
Method Summary
protected  IlpExpansionStrategy createExpansionStrategy(IlpObject ilpObject)
          Returns the expansion strategy that will be used by the object created by this adapter to represent the given business object.
protected  void customizeAllObjects()
          Apply configuration to all objects.
protected abstract  void customizeObject(IlpObject object)
          This method is automatically called by createExpansionStrategy to guarantee that every new object (or updated) is customized before being added to this adapter.
protected  void doApplyConfiguration(Map properties)
          Apply the new configuration
 List getAcceptedClasses()
          Returns the list of accepted classes.
 IlpExpansionStrategyFactory getExpansionStrategyFactory()
          Returns the expansion strategy factory being used by this adapter.
 IlpExpansionType getExpansionType(IlpObject ilpObject)
          Retrieves the expansion type of a given business object.
 List getOrigins()
          Returns the list of origin identifiers.
protected  Collection getPossibleRoots()
          This method returns a list of possible root objects.
 List getRoots()
          Returns the list of root objects created by this adapter.
protected  boolean hasConfigurationChanged(Map properties)
          Checks if the new configuration has changed comparing with the current configuration.
protected  void initializeAcceptedClasses()
          Initializes the predefined list of accepted classes.
 boolean isEmptyOrigins()
          Returns true if the list of origin identifiers is empty.
 boolean isOrigin(Object id)
          Returns true if the identifier is part of the list of origins.
 boolean isShowingOrigin()
          Returns true if the origins are shown.
abstract  void loadChildren(IlpRepresentationObject representation)
          Loads the child objects of the given object, if they are not yet present in the representation model.
abstract  void releaseChildren(IlpRepresentationObject representation)
          Signals that the model and the attached views do not need the child objects of the given object anymore.
protected  IlpRepresentationObject removeRepresentation(Object id)
          Removes the representation object that corresponds to the given identifier.
protected  void replaceAcceptedClasses(List newInclusion)
          This method is called to replace the existing accepted class list with a new one.
 void resetOrigins()
          Resets the list of origin identifiers.
 void setAcceptedClasses(List newInclusion)
          Sets the list of business classes that should be accepted by this adapter.
 void setExpansionStrategyFactory(IlpExpansionStrategyFactory factory)
          Sets the expansion strategy that will be used by the representation objects created by this adapter.
protected  void setExpansionType(IlpObject ilpObject, IlpExpansionType expansion)
          Stores the expansion type for a given business object.
 void setOrigins(List newOrigins, boolean show)
          Sets the list of origin identifiers.
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 as a root object in the hierarchy.
 
Methods inherited from class ilog.cpl.datasource.IlpAbstractAdapter
addAdapterListener, addPropertyChangeListener, addPropertyChangeListener, addRepresentation, applyConfiguration, batchEnded, batchStarted, beginRepresentation, clearIdToRepresentationObjectMap, clearRepresentationObjects, createRepresentationObject, endBatch, fillModel, firePropertyChange, fireRepresentationObjectsAdded, fireRepresentationObjectsRemoved, getContext, getDataSource, getExcludedClasses, getFilter, getRepresentationObject, getRepresentationObject, getRepresentationObjects, getSyncStrategy, hasModel, hasRepresentationObject, hasRepresentationObjects, initializeExcludedClasses, initializeRepresentationObjects, isRepresenting, refilter, refilterObjects, removeAdapterListener, removePropertyChangeListener, removePropertyChangeListener, replaceExcludedClasses, setBatchable, setDataSource, setExcludedClasses, setFilter, startBatch, stopRepresentation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ilog.cpl.datasource.DataSourceListener
objectAttributeChanged, objectsAdded, objectsRemoved, objectStructureChanged
 

Constructor Detail

IlpAbstractHierarchyAdapter

public IlpAbstractHierarchyAdapter()
Default constructor. An adapter built this way will use the IlpChild and IlpContainer interfaces.


IlpAbstractHierarchyAdapter

public IlpAbstractHierarchyAdapter(IlpContext context)
Constructor. An adapter built this way will use the IlpChild and IlpContainer interfaces.

Parameters:
context - The context used by this adapter.
Method Detail

resetOrigins

public void resetOrigins()
Resets the list of origin identifiers.

After a call to this method, the list is empty and isShowingOrigin() returns false. Thus, only the objects that do not have a parent are considered root objects.


setOrigins

public void setOrigins(List newOrigins,
                       boolean show)
Sets the list of origin identifiers.

By default, the list is empty and the origins are not shown, which means that only the objects that do not have a parent are considered root objects.

In the case where you specify identifiers in the list:

Note that, if you pass an empty list with showOrigin set to true, no object will be represented.

The current implementation is not very efficient, as it removes all representation objects and recreates them.

Note: The predefined adapters extending this class allow this property to be customized using CSS, as illustrated below:

 Adapter {
   origins[0]: NE1;
   origins[1]: NE2;
   showOrigin: true;
 }
 

Parameters:
newOrigins - The list of object origin identifiers. Note that this list is copied to the internal list of origins. This parameter cannot be null.
show - This Boolean indicates whether the origins as defined in the newOrigins parameter should be shown.

getRoots

public List getRoots()
Returns the list of root objects created by this adapter.

The returned list shall not be modified.

Returns:
List of root objects
Since:
JViews 7.5

getOrigins

public List getOrigins()
Returns the list of origin identifiers.

It may well be an empty list.

Returns:
A copy of the internal list of origins.

isEmptyOrigins

public boolean isEmptyOrigins()
Returns true if the list of origin identifiers is empty.

When this list is empty only the objects that do not have a parent are considered root objects.


isOrigin

public boolean isOrigin(Object id)
Returns true if the identifier is part of the list of origins.

Parameters:
id - The identifier to be checked.
Returns:
true if the identifier is included in the list of origins.

isShowingOrigin

public boolean isShowingOrigin()
Returns true if the origins are shown.

See Also:
setOrigins(List,boolean)

getPossibleRoots

protected Collection getPossibleRoots()
This method returns a list of possible root objects. These possible root objects will be checked against the filter criteria, accepted classes, excluded classes and all object possible tests in order to identify if they will be created in the representation model or no.

Overrides:
getPossibleRoots in class IlpAbstractAdapter
Returns:
Returns a new list with the business objects that will be root objects in the representation model.
Internal method or field: do not use!

testObject

protected boolean testObject(IlpObject ilpObject)
Returns 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.

Overrides:
testObject in class IlpAbstractAdapter
See Also:
IlpAbstractAdapter.setFilter(ilog.cpl.util.IlpFilter), IlpAbstractAdapter.setExcludedClasses(java.util.List)

testRootObject

protected boolean testRootObject(IlpObject ilpObject)
Returns true if an object of the data source should be represented as a root object in the hierarchy.

In fact, an object is represented during this iteration if this method returns true and the IlpAbstractAdapter.testObject(IlpObject) method returns true.

The behavior of this method depends on the list of origins. See setOrigins(List,boolean) for an explanation.

Overrides:
testRootObject in class IlpAbstractAdapter

setExpansionStrategyFactory

public void setExpansionStrategyFactory(IlpExpansionStrategyFactory factory)
Sets the expansion strategy that will be used by the representation objects created by this adapter. Changing the expansion strategy factory does not affect representation objects that were already created by this adapter.

Note: The predefined adapters extending this class allow this property to be customized using CSS, as illustrated below:

 Adapter {
   expansionStrategyFactory: @+factoryDef;
 }
 Subobject#factoryDef {
   class: ...;
 }
 

Since:
JTGO 4.0
See Also:
IlpExpansionStrategyFactory

getExpansionStrategyFactory

public IlpExpansionStrategyFactory getExpansionStrategyFactory()
Returns the expansion strategy factory being used by this adapter.

Since:
JTGO 4.0

createExpansionStrategy

protected IlpExpansionStrategy createExpansionStrategy(IlpObject ilpObject)
Returns the expansion strategy that will be used by the object created by this adapter to represent the given business object.

Returns:
An expansion strategy to be used by a representation object.
Since:
JTGO 4.0
See Also:
IlpExpansionStrategy

loadChildren

public abstract void loadChildren(IlpRepresentationObject representation)
Loads the child objects of the given object, if they are not yet present in the representation model.

Expansion strategies use this method to load objects that are present in the data source into the representation model.

Since:
JTGO 4.0
See Also:
IlpExpansionStrategy

releaseChildren

public abstract void releaseChildren(IlpRepresentationObject representation)
Signals that the model and the attached views do not need the child objects of the given object anymore. The child objects can be removed (but need not be) from working memory.

Expansion strategies use this method to release objects that are present in the representation model.

Since:
JTGO 4.0
See Also:
IlpExpansionStrategy

getExpansionType

public IlpExpansionType getExpansionType(IlpObject ilpObject)
Retrieves the expansion type of a given business object.

Compatibility Note: In JViews 8.0, ilog.cpl.model.IlpObject.ExpansionType has been replaced by IlpExpansionType.

Parameters:
ilpObject - The business object containing the expansion type.
Returns:
The expansion type for this object.
Since:
JViews 8.0

setExpansionType

protected void setExpansionType(IlpObject ilpObject,
                                IlpExpansionType expansion)
Stores the expansion type for a given business object.

The only way to modify the expansion type of an existing representation object is by recreating it accordingly. This method does not do that, thus, it should be called immediately before creating the corresponding representation object - subclasses can modify this behavior.

Note: The predefined adapters extending this class allow this property to be customized using CSS, as illustrated below:

 object {
   expansion: NO_EXPANSION;
 }
 

Compatibility Note: In JViews 8.0, ilog.cpl.model.IlpObject.ExpansionType has been replaced by IlpExpansionType.

Parameters:
ilpObject - The business object.
expansion - The expansion type for the given object.
Since:
JViews 8.0

removeRepresentation

protected IlpRepresentationObject removeRepresentation(Object id)
Description copied from class: IlpAbstractAdapter
Removes the representation object that corresponds to the given identifier.

Overrides:
removeRepresentation in class IlpAbstractAdapter
Parameters:
id - Object identifier

setAcceptedClasses

public void setAcceptedClasses(List newInclusion)
Sets the list of business classes that should be accepted by this adapter.

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, only the business objects from the given classes or from one of its subclasses will be automatically filtered. Their representation will be created in the associated representation model.

Note: The predefined adapters extending this class allow this property to be customized using CSS, as illustrated below:

 Adapter {
   acceptedClasses[0]: "business class A";
   acceptedClasses[1]: "business class B";
 }
 

Parameters:
newInclusion - The list of IlpClass. Note that this list is copied to the internal list of accepted classes.
Since:
JTGO 4.0

getAcceptedClasses

public List getAcceptedClasses()
Returns the list of accepted classes.

It may well be an empty list.

Returns:
A copy of the internal list of origins.
Since:
JTGO 4.0

initializeAcceptedClasses

protected void initializeAcceptedClasses()
Initializes the predefined list of accepted classes. In general, this list is empty. This method is overridden in subclasses if the specific adapter does not handle some predefined classes.


replaceAcceptedClasses

protected void replaceAcceptedClasses(List newInclusion)
This method is called to replace the existing accepted class list with a new one.

Parameters:
newInclusion - New list. This is always a non-empty list.
See Also:
setAcceptedClasses(java.util.List)
Internal method or field: do not use!

customizeAllObjects

protected void customizeAllObjects()
Apply configuration to all objects.

This method should be called whenever a new style sheet is applied. At this adaptation level, the only thing to do is to update the expansionType structure. Subclasses of this adapter may require the updated objects to be removed and recreated.

Since:
JTGO 4.0
Internal method or field: do not use!

customizeObject

protected abstract void customizeObject(IlpObject object)
This method is automatically called by createExpansionStrategy to guarantee that every new object (or updated) is customized before being added to this adapter.

Parameters:
object - The object to be customized.
Since:
JTGO 4.0
Internal method or field: do not use!

hasConfigurationChanged

protected boolean hasConfigurationChanged(Map properties)
Checks if the new configuration has changed comparing with the current configuration.

Overrides:
hasConfigurationChanged in class IlpAbstractAdapter
Returns:
true if one of the properties being set is different from the current value in the adapter.
Since:
JTGO 4.0
See Also:
IlpAbstractAdapter
Internal method or field: do not use!

doApplyConfiguration

protected void doApplyConfiguration(Map properties)
Apply the new configuration

Overrides:
doApplyConfiguration in class IlpAbstractAdapter
Since:
JTGO 4.0
See Also:
IlpAbstractAdapter
Internal method or field: do not use!


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.