ilog.server.jsds
Class IlsDataSource

java.lang.Object
  |
  +--ilog.server.jsds.IlsDataSource
All Implemented Interfaces:
IlDataSource, IlDataSourceEditor, IlsDSConnection
Direct Known Subclasses:
IlsGanttDataSource, IlsGraphDataSource, IlsListDataSource, IlsSDMDataSource, IlsTableDataSource, IlsTreeDataSource

public abstract class IlsDataSource
extends java.lang.Object
implements IlDataSource, IlDataSourceEditor, IlsDSConnection

Abstract class to be shared by all data sources. Provides support for batch and property-change listeners and for data source connection/disconnection listeners.

Provides also support for editing data source properties and managing batch updates to the back-end. Note that the execution of all methods prefixed with ds are asynchronous and, therefore, may not be immediately reflected in the local model. A data source is identified by its label and view name.

See Also:
IlDataSource, IlDataSourceEditor, IlsDataSourceContainer

Field Summary
protected  java.util.Map _properties
          Properties of the data source.
protected  java.beans.PropertyChangeSupport _propertyChangeListeners
          Support for PropertyChangeListener.
 
Constructor Summary
protected IlsDataSource()
          Instantiate a new data source.
 
Method Summary
 void addBatchListener(BatchListener l)
          Adds a listener for all batch events
 void addDataSourceListener(DataSourceListener l)
          Adds a listener for all data-source object events.
 void addDSConnectionListener(DSConnectionListener l)
          Adds a listener for all data-source connection/disconnection events.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener for a specific property.
protected  void dataSourceChange(java.lang.Object dso, java.util.Map properties)
          Invoked by subclasses to notify that properties on the data source have changed.
 void dataSourceConnected(IlsDSMainObject dso)
          This method is invoked when the data source is connected (view is opened).
 void dataSourceDisconnected()
          This method is invoked when the data source is disconnected (view is closed).
 void dsClose()
          Close the view represented by the container that contains the data source.
 void dsDereference(java.lang.Object object, java.lang.String propertyName, IlsDataSourceContainer dsc, boolean force)
          Excluded.  
 void dsDereference(java.lang.Object object, java.lang.String propertyName, int dscIndex, boolean force)
          Excluded.  
 void dsEndBatch()
          Notifies the datasource that the updates are finished.
 boolean dsExecCallback(java.lang.String funName, MvValue[] argv)
          This method executes a given function in asynchronous mode on the Server object associated with the data source representation object.
 boolean dsExecDuplexCallback(java.lang.String funName, MvValue[] argv, java.lang.String duplexFunName, MvValue[] duplexArgv)
          Same as dsExecDuplexCallback(funName, argv, duplexFunName, duplexArgv, 0, true)
 boolean dsExecDuplexCallback(java.lang.String funName, MvValue[] argv, java.lang.String duplexFunName, MvValue[] duplexArgv, int resultIndex)
          Same as dsExecDuplexCallback(funName, argv, duplexFunName, duplexArgv, resultIndex, true)
 boolean dsExecDuplexCallback(java.lang.String funName, MvValue[] argv, java.lang.String duplexFunName, MvValue[] duplexArgv, int resultIndex, boolean inTrans)
          This callback executes an asynchronous call to the funName function on the Server object associated with the assocoated representation object.
 void dsStartBatch()
          Notifies the datasource that some updates will take place.
 void dsUpdateProperty(java.lang.String name, java.lang.Object value)
          Requests the server to update a data source property.
 void endBatch()
          Excluded.  
 IlsDataSourceContainer getDataSourceContainer()
           
 int getDSBatchLevel()
          Gets the level to which outgoing batches are currently nested.
 IlsDSComponent getDSComponent()
           
abstract  IlsDSMainObject getDSMainObject()
           
 java.util.Map getDSProperties()
          Access all the datasource properties
 java.lang.Object getDSProperty(java.lang.String propertyName)
          Get value of specified property.
 IlsDSRepresentation getDSRepresentation()
           
 java.lang.String getLabel()
           
 java.lang.String getViewName()
           
protected  boolean isDSObjectPropertyEditable(java.lang.Object obj, java.lang.String propertyName)
           
protected  boolean isDSObjectPropertyHRef(java.lang.Object obj, java.lang.String propertyName)
           
 boolean isEditable()
          Gets whether the data source is read only or not
 boolean isInEdition()
           
 void removeBatchListener(BatchListener l)
          Removes a listener for all batch events
 void removeDataSourceListener(DataSourceListener l)
          Removes a listener for all data-source object events.
 void removeDSConnectionListener(DSConnectionListener l)
          Removes a listener for all data-source connection/disconnection events.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 void setDataSourceContainer(IlsDataSourceContainer dsc)
          Set the container of the data source.
 void setLabel(java.lang.String name)
          Set the label of the data source.
 void setRpStatus(int rpStatus)
          Set the representation status of the associated representation object.
 void setViewName(java.lang.String viewName)
          Set the data source view name.
 void startBatch()
          Excluded.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_propertyChangeListeners

protected java.beans.PropertyChangeSupport _propertyChangeListeners
Support for PropertyChangeListener.

_properties

protected java.util.Map _properties
Properties of the data source.
Constructor Detail

IlsDataSource

protected IlsDataSource()
Instantiate a new data source.
Method Detail

addBatchListener

public void addBatchListener(BatchListener l)
Adds a listener for all batch events
Specified by:
addBatchListener in interface IlDataSource
Parameters:
l - the listener
See Also:
BatchListener

removeBatchListener

public void removeBatchListener(BatchListener l)
Removes a listener for all batch events
Specified by:
removeBatchListener in interface IlDataSource
Parameters:
l - the listener
See Also:
BatchListener

addDataSourceListener

public void addDataSourceListener(DataSourceListener l)
Adds a listener for all data-source object events.
Specified by:
addDataSourceListener in interface IlDataSource
Parameters:
l - the listener
See Also:
DataSourceListener

removeDataSourceListener

public void removeDataSourceListener(DataSourceListener l)
Removes a listener for all data-source object events.
Specified by:
removeDataSourceListener in interface IlDataSource
Parameters:
l - the listener
See Also:
DataSourceListener

addDSConnectionListener

public void addDSConnectionListener(DSConnectionListener l)
Adds a listener for all data-source connection/disconnection events.
Specified by:
addDSConnectionListener in interface IlsDSConnection
Parameters:
l - the listener
See Also:
DSConnectionListener

removeDSConnectionListener

public void removeDSConnectionListener(DSConnectionListener l)
Removes a listener for all data-source connection/disconnection events.
Specified by:
removeDSConnectionListener in interface IlsDSConnection
Parameters:
l - the listener
See Also:
DSConnectionListener

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.
Parameters:
listener - The PropertyChangeListener to be added

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property.
Parameters:
propertyName - The name of the property to listen on.
listener - The PropertyChangeListener to be added.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
Parameters:
The - PropertyChangeListener to be removed.

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property.
Parameters:
propertyName - The name of the property that was listened on.
listener - The PropertyChangeListener to be removed.

dsStartBatch

public void dsStartBatch()
Notifies the datasource that some updates will take place.
Specified by:
dsStartBatch in interface IlDataSourceEditor
See Also:
IlDataSourceEditor.dsStartBatch()

dsEndBatch

public void dsEndBatch()
Notifies the datasource that the updates are finished.
Specified by:
dsEndBatch in interface IlDataSourceEditor
See Also:
IlDataSourceEditor.dsEndBatch()

getDSBatchLevel

public int getDSBatchLevel()
Gets the level to which outgoing batches are currently nested.
Specified by:
getDSBatchLevel in interface IlDataSourceEditor
Returns:
The number of nested batches
See Also:
IlDataSourceEditor.getDSBatchLevel()

isInEdition

public boolean isInEdition()
Returns:
true if the data source is in edition. getDSBatchLevel() > 0
See Also:
getDSBatchLevel()

dsUpdateProperty

public void dsUpdateProperty(java.lang.String name,
                             java.lang.Object value)
Requests the server to update a data source property.
Specified by:
dsUpdateProperty in interface IlDataSourceEditor
Parameters:
name - The name of the property
value - The new value of the property
See Also:
IlDataSourceEditor.dsUpdateProperty(java.lang.String, java.lang.Object)

dsClose

public void dsClose()
Close the view represented by the container that contains the data source.
See Also:
IlsDataSourceContainer

startBatch

public void startBatch()
Excluded. 

endBatch

public void endBatch()
Excluded. 

dataSourceConnected

public void dataSourceConnected(IlsDSMainObject dso)
This method is invoked when the data source is connected (view is opened).
See Also:
DSConnectionListener

dataSourceDisconnected

public void dataSourceDisconnected()
This method is invoked when the data source is disconnected (view is closed).
See Also:
DSConnectionListener

dataSourceChange

protected void dataSourceChange(java.lang.Object dso,
                                java.util.Map properties)
Invoked by subclasses to notify that properties on the data source have changed. Fire a DataSourceEvent on all the data source listener.

getDSMainObject

public abstract IlsDSMainObject getDSMainObject()
Returns:
the origin representation object associated to the data source.

isEditable

public boolean isEditable()
Gets whether the data source is read only or not
Specified by:
isEditable in interface IlDataSourceEditor
Returns:
false is the data source is read only.
See Also:
IlDataSourceEditor.isEditable()

getLabel

public java.lang.String getLabel()
Returns:
the label of the data source.

setLabel

public void setLabel(java.lang.String name)
Set the label of the data source. This label is used when opening a view. It must be the same as the associated representation object.
Parameters:
name - the data source label
See Also:
IlsDSMainObject.match(ilog.server.jsds.IlsDataSource)

getViewName

public java.lang.String getViewName()
Returns:
the data source view name.

setViewName

public void setViewName(java.lang.String viewName)
Set the data source view name. This view name is used when opening a view. It must be the same as the associated representation object.
Parameters:
viewName - the data source view name
See Also:
IlsDSMainObject.match(ilog.server.jsds.IlsDataSource)

getDataSourceContainer

public IlsDataSourceContainer getDataSourceContainer()
Returns:
the container that contains the data source.

setDataSourceContainer

public void setDataSourceContainer(IlsDataSourceContainer dsc)
Set the container of the data source.
Parameters:
dsc - The new container.

getDSProperty

public java.lang.Object getDSProperty(java.lang.String propertyName)
Get value of specified property.
Specified by:
getDSProperty in interface IlDataSource
Parameters:
propertyName - the property name.
Returns:
Value of specified property.

getDSProperties

public java.util.Map getDSProperties()
Access all the datasource properties
Specified by:
getDSProperties in interface IlDataSource
Returns:
a Map containing all the property values indexed by their name.

getDSRepresentation

public IlsDSRepresentation getDSRepresentation()
Returns:
the representation associated to the data source.

getDSComponent

public IlsDSComponent getDSComponent()
Returns:
the component associated to the data source.

dsDereference

public void dsDereference(java.lang.Object object,
                          java.lang.String propertyName,
                          int dscIndex,
                          boolean force)
Excluded. 

setRpStatus

public void setRpStatus(int rpStatus)
Set the representation status of the associated representation object.
See Also:
RpObject.setRpStatus(int)

dsExecCallback

public boolean dsExecCallback(java.lang.String funName,
                              MvValue[] argv)
This method executes a given function in asynchronous mode on the Server object associated with the data source representation object.
Parameters:
funName - The function name.
argv - The arguments.
Returns:
false if the request callback couldn't be sent, true otherwise.
See Also:
RpObject.execCallback(java.lang.String, ilog.server.jcomp.MvValue[])

dsExecDuplexCallback

public boolean dsExecDuplexCallback(java.lang.String funName,
                                    MvValue[] argv,
                                    java.lang.String duplexFunName,
                                    MvValue[] duplexArgv,
                                    int resultIndex,
                                    boolean inTrans)
This callback executes an asynchronous call to the funName function on the Server object associated with the assocoated representation object. The result of the function is sent back to the caller through a call to the duplex global function duplexFunName.
Parameters:
funName - The function name to invoke
argv - The arguments passed to the function funName
duplexFunName - The duplex global function name
duplexArgv - The duplex global function arguments
resultIndex - The result of the funName function will be put at the resultIndex position in the array of arguments to the duplex function
inTrans - this parameter indicates if the callback must be executed using the transaction mechanism or not (see Transaction control in MvComponent). If equal to true and if no current transaction has been initialized, a new one is implicitly created and commited.
Returns:
false if the request callback couldn't be sent, true otherwise.
See Also:
RpObject.execDuplexCallback(java.lang.String, ilog.server.jcomp.MvValue[], java.lang.String, ilog.server.jcomp.MvValue[], int, boolean)

dsExecDuplexCallback

public boolean dsExecDuplexCallback(java.lang.String funName,
                                    MvValue[] argv,
                                    java.lang.String duplexFunName,
                                    MvValue[] duplexArgv,
                                    int resultIndex)
Same as dsExecDuplexCallback(funName, argv, duplexFunName, duplexArgv, resultIndex, true)
See Also:
dsExecDuplexCallback(String, MvValue[], String, MvValue[], int, boolean)

dsExecDuplexCallback

public boolean dsExecDuplexCallback(java.lang.String funName,
                                    MvValue[] argv,
                                    java.lang.String duplexFunName,
                                    MvValue[] duplexArgv)
Same as dsExecDuplexCallback(funName, argv, duplexFunName, duplexArgv, 0, true)
See Also:
dsExecDuplexCallback(String, MvValue[], String, MvValue[], int, boolean)

dsDereference

public void dsDereference(java.lang.Object object,
                          java.lang.String propertyName,
                          IlsDataSourceContainer dsc,
                          boolean force)
Excluded. 

isDSObjectPropertyEditable

protected boolean isDSObjectPropertyEditable(java.lang.Object obj,
                                             java.lang.String propertyName)
Parameters:
obj - The representation object RpObject.
propertyName - The property (attribute) name.
Returns:
true if the property (attribute) of the representation object is editable.
See Also:
RpObject.isEditable(int)

isDSObjectPropertyHRef

protected boolean isDSObjectPropertyHRef(java.lang.Object obj,
                                         java.lang.String propertyName)
Parameters:
obj - The representation object RpObject.
propertyName - The property (attribute) name.
Returns:
true if the property of a representation object is a hyper reference.
See Also:
RpObject.getAttributeType(int), MvDataType