de.fesenmeyer.dbnormalizer.core.configuration
Class ConfigurationReader

java.lang.Object
  extended by de.fesenmeyer.dbnormalizer.core.configuration.ConfigurationReader

public class ConfigurationReader
extends Object

Class which reads a session configuration from a XML file. Such a file contains FDs grouped by schema, catalog and table. Either a DB-Configuration for reading table information from a DB or attributes for each table are also contained in the file. A standard DB-Normalizer-file can be read with the read() method. To import FDs from Tobias Rafreiders tool "Tane-java", which uses a slightly different format, you can use the method readTaneJavaConfig().

Author:
DF
See Also:
ConfigurationWriter, SessionConfig

Field Summary
private  String fileName
          The name (and path) of the file to be read.
private  boolean hasDBConfig
          Flag which states whether the file contains a DB-Configuration or not.
private static DBNormalizerLogger logger
          The logger for this class.
 
Constructor Summary
ConfigurationReader(String fileName)
          Class constructor specifying the file to be read.
 
Method Summary
 SessionConfig read()
          Reads the configuration file into a session configuration object.
 SessionConfig readTaneJavaConfig()
          Can be used to import FDs from Tobias Rafreider's tool "TANE-java".
private  AttributeSetConfig retrieveAttributes(Element attributeSetNode)
          Reads the (table) attributes from a node containing (table) attributes.
private  Collection<TableContainerConfig> retrieveCatalogConfigs(Element parentNode)
          Reads the data from a catalog node.
private  DBConfig retrieveDBConfig(Element dbConfigElement)
          Reads the dbConfig node into a DB-Configuration object.
private  Collection<FDConfig> retrieveFDConfigs(Element fdsNode)
          Reads the FDs from a fds node.
private  Collection<TableContainerConfig> retrieveSchemaConfigs(Element parentNode)
          Reads the data from a schema node.
private  SessionConfig retrieveSessionConfig(Element configNode)
          Reads the whole file into a session configuration object.
private  Collection<TableConfig> retrieveTableConfigs(Element tableInfoNode, String catalogName, String schemaName)
          Reads the (tables') data from a tableInfo node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static DBNormalizerLogger logger
The logger for this class.


fileName

private String fileName
The name (and path) of the file to be read.


hasDBConfig

private boolean hasDBConfig
Flag which states whether the file contains a DB-Configuration or not.

Constructor Detail

ConfigurationReader

public ConfigurationReader(String fileName)
Class constructor specifying the file to be read.

Parameters:
fileName - the name (and) path of the file to be read
Method Detail

read

public SessionConfig read()
                   throws ConfigurationException
Reads the configuration file into a session configuration object. Before creating the session configuration object, the file is validated against the XML-Schema xsd/configuration.xsd.

Returns:
a session configuration object
Throws:
ConfigurationException - if an exception occurs while reading the file, e.g. if it is not valid

readTaneJavaConfig

public SessionConfig readTaneJavaConfig()
                                 throws ConfigurationException
Can be used to import FDs from Tobias Rafreider's tool "TANE-java". First performs an XSL-Transformation on the file (by using the XSL-file xsl/transform_tanejava2dbn.xsl), then validates the result against the XML-Schema xsd/configuration.xsd and creates a session configuration object.

Returns:
a session configuration object
Throws:
ConfigurationException - if an exception occurs during transformation or validation of the file

retrieveSessionConfig

private SessionConfig retrieveSessionConfig(Element configNode)
                                     throws ConfigurationException
Reads the whole file into a session configuration object.

Parameters:
configNode - the root node of the file
Returns:
the session configuration object
Throws:
ConfigurationException

retrieveDBConfig

private DBConfig retrieveDBConfig(Element dbConfigElement)
Reads the dbConfig node into a DB-Configuration object.

Parameters:
dbConfigElement - the dbConfig node
Returns:
a DB-Configuration object

retrieveSchemaConfigs

private Collection<TableContainerConfig> retrieveSchemaConfigs(Element parentNode)
                                                        throws ConfigurationException
Reads the data from a schema node.

Parameters:
parentNode - the parent node of the schema node
Returns:
a collection of TableContainerConfig objects
Throws:
ConfigurationException

retrieveCatalogConfigs

private Collection<TableContainerConfig> retrieveCatalogConfigs(Element parentNode)
                                                         throws ConfigurationException
Reads the data from a catalog node.

Parameters:
parentNode - the parent node of the catalog node
Returns:
a collection of TableContainerConfig objects
Throws:
ConfigurationException

retrieveTableConfigs

private Collection<TableConfig> retrieveTableConfigs(Element tableInfoNode,
                                                     String catalogName,
                                                     String schemaName)
                                              throws ConfigurationException
Reads the (tables') data from a tableInfo node.

Parameters:
tableInfoNode - the tableInfo node
catalogName - the name of the catalog containing the tables, may be null
schemaName - the name of the schema containing the tables, may be null
Returns:
a collection of TableConfig objects
Throws:
ConfigurationException

retrieveFDConfigs

private Collection<FDConfig> retrieveFDConfigs(Element fdsNode)
Reads the FDs from a fds node.

Parameters:
fdsNode - the fds node
Returns:
a collection of FDConfig objects

retrieveAttributes

private AttributeSetConfig retrieveAttributes(Element attributeSetNode)
Reads the (table) attributes from a node containing (table) attributes.

Parameters:
attributeSetNode - the node containing (table) attributes
Returns:
an AttributeSetConfig object