public abstract class IlvGanttDataSource extends Object
A data source is an object that can read and (optionally) write
Gantt data through its read(ilog.views.gantt.IlvGanttModel)
and write(ilog.views.gantt.IlvGanttModel)
methods.
Predefined implementations of this abstract class are:
IlvGanttXMLDataSource
,
that reads and writes data from XML files,
IlvGanttJDBCDataSource
,
that reads data from a database through the JDBC API.
Data sources can be serialized inside "configuration files"
(see IlvGanttProjectConfiguration
).
Serializing a data source must not be confused with reading/writing
data represented by the data source. Serializing a data source means
writing its configuration parameters to an XML configuration file.
For example, a database source will have parameters like the database
URL, the SQL queries, and so forth. These parameters can be saved
(serialized) to an XML file and reloaded (deserialized) later to
recreate the data source. Serializing and deserializing data sources
is done through the serialize(org.w3c.dom.Element, java.net.URL)
and deserialize(org.w3c.dom.Element, java.net.URL)
methods.
Modifier | Constructor and Description |
---|---|
protected |
IlvGanttDataSource()
Protected constructor to prevent instantiation.
|
Modifier and Type | Method and Description |
---|---|
boolean |
areActivitiesConfigured()
Returns whether this data source defines a configuration for activity
data.
|
boolean |
areConstraintsConfigured()
Returns whether this data source defines a configuration for
constraint data.
|
boolean |
areReservationsConfigured()
Returns whether this data source defines a configuration for
reservation data.
|
boolean |
areResourcesConfigured()
Returns whether this data source defines a configuration for resource
data.
|
static IlvGanttDataSource |
deserialize(Element element,
URL baseURL)
Deserializes a data source from the specified DOM element.
|
protected abstract void |
deserializeImpl(Element element)
This method must be implemented by subclasses to read their parameters
from an XML configuration file.
|
protected URL |
getBaseURL()
Returns the base URL to or from which this data source is being
deserialized.
|
String |
getDescription()
Returns a description of this data source.
|
abstract void |
read(IlvGanttModel ganttModel)
Reads data from this data source into an
IlvGanttModel |
void |
serialize(Element element,
URL baseURL)
Serializes this data source to the specified DOM element.
|
protected abstract void |
serializeImpl(Element element)
This method must be implemented by subclasses to save their parameters
to the XML configuration file.
|
boolean |
supportsWrite()
Gets if this data source supports writing.
|
abstract void |
write(IlvGanttModel ganttModel)
Write data from an
IlvGanttModel to this data source. |
protected IlvGanttDataSource()
public abstract void read(IlvGanttModel ganttModel) throws Exception
IlvGanttModel
ganttModel
- The Gantt model that will contain the data read from
this data source.Exception
- If an exception occurs while reading data.public abstract void write(IlvGanttModel ganttModel) throws Exception
IlvGanttModel
to this data source.
This method may have an empty implementation if the data source is
read-only. Read-only data sources must return false
from
the supportsWrite()
method.
ganttModel
- The Gantt model that contains the data to be saved
to the data source.Exception
- If an exception occurs while writing data.public boolean supportsWrite()
false
.
The default implementation returns false
. This method
must be overridden by subclasses that support writing.
true
if this data source supports writing.public String getDescription()
This default implementation returns the URL from which the data source was deserialized.
public boolean areActivitiesConfigured()
true
.
Subclasses can override this method if the data source has certain
states in which activity data will not be read or
written to the Gantt data model. For example, a
JDBC data source might not have a query defined for activities or a
flat-file data source might not have a file defined for activity import.true
if this data source defines a configuration
for activity data.public boolean areResourcesConfigured()
true
.
Subclasses can override this method if the data source has certain
states in which resource data will not be read or
written to the Gantt data model. For example, a
JDBC data source might not have a query defined for resources or a
flat-file data source might not have a file defined for resource import.true
if this data source defines a configuration
for resource data.public boolean areConstraintsConfigured()
true
.
Subclasses can override this method if the data source has certain
states in which constraint data will not be read
or written to the Gantt data model. For example,
a JDBC data source might not have a query defined for constraints or
a flat-file data source might not have a file defined for constraint
import.true
if this data source defines a configuration
for constraint data.public boolean areReservationsConfigured()
true
.
Subclasses can override this method if the data source has certain
states in which reservation data will not be read
or written to the Gantt data model. For example,
a JDBC data source might not have a query defined for reservations or
a flat-file data source might not have a file defined for reservation
import.true
if this data source defines a configuration
for reservation data.public final void serialize(Element element, URL baseURL) throws Exception
Serializing a data source means saving its parameters to an XML configuration file. Serializing a data source must not be confused with requesting the data source to write the Gantt data model.
This method sets the "class"
attribute of the element
to the class name of this data source, and then calls
serializeImpl(org.w3c.dom.Element)
to let subclasses save their own configuration
parameters.
element
- The DOM element to which the data source parameters
are written.baseURL
- The URL to which the configuration is being saved.
This URL can be used to save URL parameters of the
data source as relative URLs.Exception
- If an exception occurs while serializing
the data source.protected abstract void serializeImpl(Element element) throws Exception
element
- The DOM element to which the data source parameters are
written.Exception
- If an exception occurs while serializing
the data source.public static IlvGanttDataSource deserialize(Element element, URL baseURL) throws Exception
Deserializing a data source means reading its parameters from an XML configuration file. Deserializing a data source must not be confused with requesting the data source to read the Gantt data model.
This method reads the data source's class name, creates an instance
of this class, and then calls
deserializeImpl(org.w3c.dom.Element)
to let subclasses read
their own configuration parameters.
element
- The DOM element from which the data source parameters
are read.baseURL
- The URL from which the configuration is being read.
URL parameters of this data source may be relative to
this base URL.IlvGanttDataSource
.Exception
- If an exception occurs while deserializing
the data source.protected abstract void deserializeImpl(Element element) throws Exception
element
- The DOM element to which the data source parameters are
written.Exception
- If an exception occurs while deserializing
the data source.protected URL getBaseURL()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.