de.folt.models.datamodel
Class DataSourceConfigurations

java.lang.Object
  extended by java.util.Observable
      extended by de.folt.models.documentmodel.document.XmlDocument
          extended by de.folt.models.datamodel.DataSourceConfigurations
All Implemented Interfaces:
java.io.Serializable

public class DataSourceConfigurations
extends XmlDocument

This class implements DataSourceConfigurations. DataSourceConfigurations basically are a list of different DataSources. DataSources are added or deleted when the DataSource createDataSource method is called. The class supplied various methods adding, deleting, retrieving DataSources. The data sources are stored in an xml file.

Author:
klemens
See Also:
Serialized Form

Constructor Summary
DataSourceConfigurations()
           
DataSourceConfigurations(java.lang.String configurationFileName)
          Creates DataSourceConfigurations based on a given configurationFileName.
 
Method Summary
 org.jdom.Element addConfiguration(java.lang.String configName)
          addConfiguration add a new configuration with the name configName
 org.jdom.Element addConfiguration(java.lang.String configName, java.lang.String dataSourceType, DataSourceProperties dataSourceProperties)
          addConfiguration add a new configuration with the name configName, a dataSourceType and the dataSourceProperties.
 void addPropertiesToDataModelProperties(java.lang.String name, DataSourceProperties dataModelProperties)
          addPropertiesToDataModelProperties add all the properties stored to the supplied DataSourceProperties
 boolean bDataSourceExistsInConfiguration(java.lang.String configName)
          bDataSourceExistsInConfiguration check if a specific data source give by its name is registered in the database configuration
static boolean createDataSourceConfiguration(java.lang.String pathName)
          createDataSourceConfiguration create a new data source configuration file
static boolean createDataSourceConfiguration(java.lang.String fileName, java.lang.String directory)
          createDataSourceConfiguration create a new data source configuration file
 org.jdom.Element getConfiguration(java.lang.String configName)
          getConfiguration returns a dataSourceConfiguration Element based on its name
 java.lang.String getConfigurationFileName()
          Get the name of file associated with the DataSourceConfigurations.
static java.lang.String getConfigurationFileName(java.util.Hashtable<java.lang.String,java.lang.Object> message)
          getConfigurationFileName get the configuration file name based on a given string.
static java.lang.String getConfigurationFileName(java.lang.String dataSourceConfigurationsFile)
          getConfigurationFileName get the configuration file name based on a given string.
 int getConfigurationIndex(java.lang.String configName)
          getConfigurationIndex gets the configuration index
 java.lang.String[] getDataSources()
          getDataSources get all the data sources names in the configuration
 java.lang.String[] getDataSources(boolean bSync)
           
 java.lang.String[] getDataSources(java.lang.String dataSourceType)
          getDataSources get all the data sources in the configuration of a specific data source type; e.g.
 java.lang.String[] getDataSources(java.lang.String dataSourceType, boolean bSync)
           
 java.util.Vector<java.lang.String[]> getDataSourcesWithType()
          Method returns for all data source name, type and sync property
 java.lang.String getDataSourceType(java.lang.String name)
          getDataSourceType returns the type of a data source stored in a data source configuration file
static java.lang.String getDefaultDataSourceConfigurationsFileName()
           
static java.util.Vector<java.lang.String> getOpenTMSDatabases()
          getOpenTMSDatabases returns all the existing OpenTMS data sources based on the OpenTMS Property "dataSourceConfigurationsFile"
It uses the function String configfile = OpenTMSProperties.getInstance().getOpenTMSProperty ("dataSourceConfigurationsFile"); to determine the configuration file
static java.util.Vector<java.lang.String[]> getOpenTMSDatabasesWithType()
          getOpenTMSDatabasesWithType returns all the existing OpenTMS data sources together with its type based on the OpenTMS Property "dataSourceConfigurationsFile"
It uses the function String configfile = OpenTMSProperties.getInstance().getOpenTMSProperty ("dataSourceConfigurationsFile"); to determine the configuration file
Example where tmxDatabases is a Vector(String[]) String name = tmxDatabases.get(i)[0]; String type = tmxDatabases.get(i)[1];
 java.lang.String getProperty(java.lang.String configName, java.lang.String property)
          getProperty returns a specific data configuration property based on the name heartsome
static void main(java.lang.String[] args)
          main Parameters: check if data source exists
-list - list all data sources from getDefaultDataSourceConfigurationsFileName
-remove - removes the data source
if getDefaultDataSourceConfigurationsFileName file name does not exist it will be created and method returns
static void mainold(java.lang.String[] args)
          main
 boolean removeConfiguration(java.lang.String configName)
          removeConfiguration remove a configuration from the data source configurations
 boolean saveToXmlFile(java.lang.String filename)
          saveToXmlFile writes the document to the given file name
 void setConfigurationFileName(java.lang.String configurationFileName)
          Explicitly set the name if DataSourceConfigurations
 
Methods inherited from class de.folt.models.documentmodel.document.XmlDocument
bIsXmlDocument, bIsXmLFile, buildElement, createDocument, elementContentToString, elementContentToString, elementToString, getCatalogueDirectory, getDocument, getNamespace, getNamespacelist, getRoot, getRootElementName, getRootElementName, getsubElementFromElementAttributeNameValue, getsubElementFromElementAttributeNameValueRegExp, getXmlDocumentName, getXmlOutputter, getXmlURL, isBExpandExternalEntities, isValidElement, loadXmlFile, loadXmlFile, quoteXMLString, saveToXmlFile, saveToXmlFile, setBExpandExternalEntities, setCatalogueDirectory, setDocument, setNamespace, setNamespacelist, setXmlDocumentName, setXmlURL
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceConfigurations

public DataSourceConfigurations()

DataSourceConfigurations

public DataSourceConfigurations(java.lang.String configurationFileName)
Creates DataSourceConfigurations based on a given configurationFileName. Basically it reads the associated xml file and creates an XMLDocument from that.

Parameters:
configurationFileName - the configuration file to use
Method Detail

createDataSourceConfiguration

public static boolean createDataSourceConfiguration(java.lang.String pathName)
createDataSourceConfiguration create a new data source configuration file

Parameters:
pathName - the full path name of the data source configuration

createDataSourceConfiguration

public static boolean createDataSourceConfiguration(java.lang.String fileName,
                                                    java.lang.String directory)
createDataSourceConfiguration create a new data source configuration file

Parameters:
fileName - the file name of the data source configuration
directory - the directory of the data source configuration

getConfigurationFileName

public static java.lang.String getConfigurationFileName(java.util.Hashtable<java.lang.String,java.lang.Object> message)
getConfigurationFileName get the configuration file name based on a given string. Methods checks if file exists; if not check for getDefaultDataSourceConfigurationsFileName() and OpenTMSProperties.getInstance ().getOpenTMSProperty("dataSourceConfigurationsFile")

Parameters:
message - the message containing the proposed name as key / value pair for message.get("dataSourceConfigurationsFile");
Returns:
the dataSourceConfigurationsFile name or null if not found

getConfigurationFileName

public static java.lang.String getConfigurationFileName(java.lang.String dataSourceConfigurationsFile)
getConfigurationFileName get the configuration file name based on a given string. Methods checks if file exists; if not check for getDefaultDataSourceConfigurationsFileName() and OpenTMSProperties.getInstance ().getOpenTMSProperty("dataSourceConfigurationsFile")

Parameters:
dataSourceConfigurationsFile - the proposed configuration file name
Returns:
the dataSourceConfigurationsFile name or null if not found

getDefaultDataSourceConfigurationsFileName

public static java.lang.String getDefaultDataSourceConfigurationsFileName()
Returns:
the defaultDataSourceConfigurationsFileName

getOpenTMSDatabases

public static java.util.Vector<java.lang.String> getOpenTMSDatabases()
getOpenTMSDatabases returns all the existing OpenTMS data sources based on the OpenTMS Property "dataSourceConfigurationsFile"
It uses the function String configfile = OpenTMSProperties.getInstance().getOpenTMSProperty ("dataSourceConfigurationsFile"); to determine the configuration file

Returns:
a sorted vector with all the names of the data sources.

getOpenTMSDatabasesWithType

public static java.util.Vector<java.lang.String[]> getOpenTMSDatabasesWithType()
getOpenTMSDatabasesWithType returns all the existing OpenTMS data sources together with its type based on the OpenTMS Property "dataSourceConfigurationsFile"
It uses the function String configfile = OpenTMSProperties.getInstance().getOpenTMSProperty ("dataSourceConfigurationsFile"); to determine the configuration file
 Example where tmxDatabases is a Vector(String[])
 String name = tmxDatabases.get(i)[0];
 String type = tmxDatabases.get(i)[1];
 

Returns:
a vector of a two dimensional array where the first element contains the name and the second the type of the data sources.

main

public static void main(java.lang.String[] args)
main Parameters: check if data source exists
-list - list all data sources from getDefaultDataSourceConfigurationsFileName
-remove - removes the data source
if getDefaultDataSourceConfigurationsFileName file name does not exist it will be created and method returns

Parameters:
args -
Throws:
org.jdom.input.JDOMParseException

mainold

public static void mainold(java.lang.String[] args)
                    throws org.jdom.input.JDOMParseException
main

Parameters:
args -
Throws:
org.jdom.input.JDOMParseException

addConfiguration

public org.jdom.Element addConfiguration(java.lang.String configName)
addConfiguration add a new configuration with the name configName

Parameters:
configName - the name of the unique configuration
Returns:
the new Element or null if the configuration already exists

addConfiguration

public org.jdom.Element addConfiguration(java.lang.String configName,
                                         java.lang.String dataSourceType,
                                         DataSourceProperties dataSourceProperties)
addConfiguration add a new configuration with the name configName, a dataSourceType and the dataSourceProperties. It copies all the key value from dataSourceProperties to the configuration (if they are of type String).

Parameters:
configName - the name of the unique configuration
dataSourceProperties - the dataSourceProperties of the unique configuration
dataSourceType - the type of the data source
Returns:
the new Element or null if the configuration already exists

addPropertiesToDataModelProperties

public void addPropertiesToDataModelProperties(java.lang.String name,
                                               DataSourceProperties dataModelProperties)
addPropertiesToDataModelProperties add all the properties stored to the supplied DataSourceProperties

Parameters:
name - name of the data source
dataModelProperties - the DataSourceProperties which should be enhanced with the properties

bDataSourceExistsInConfiguration

public boolean bDataSourceExistsInConfiguration(java.lang.String configName)
bDataSourceExistsInConfiguration check if a specific data source give by its name is registered in the database configuration

Parameters:
configName - the name of data source
Returns:
true if it exists otherwise false

getConfiguration

public org.jdom.Element getConfiguration(java.lang.String configName)
getConfiguration returns a dataSourceConfiguration Element based on its name

Parameters:
configName - the name of the configuration to find
Returns:
the Element configuration or null if not found

getConfigurationFileName

public java.lang.String getConfigurationFileName()
Get the name of file associated with the DataSourceConfigurations.

Returns:
the configurationFileName

getConfigurationIndex

public int getConfigurationIndex(java.lang.String configName)
getConfigurationIndex gets the configuration index

Parameters:
configName - the name of the configuration to find
Returns:
the index of the configuration (0..n) or -1 if not found

getDataSources

public java.lang.String[] getDataSources()
getDataSources get all the data sources names in the configuration

Returns:
a string array of data source names / null if root of data source configuration is null (actually means data source configuration does not exist)

getDataSources

public java.lang.String[] getDataSources(boolean bSync)
Parameters:
bSync - true / false if true sync databases will be returned in case of false the non sync databases
Returns:

getDataSources

public java.lang.String[] getDataSources(java.lang.String dataSourceType)
getDataSources get all the data sources in the configuration of a specific data source type; e.g. datasourcetype="de.folt.models.datamodel.sql.OpenTMSSQLDataSource"

Parameters:
dataSourceType -
Returns:
a string array of data source names of specific types

getDataSources

public java.lang.String[] getDataSources(java.lang.String dataSourceType,
                                         boolean bSync)
Parameters:
dataSourceType - the data source types to search for
bSync - true or false depending if sync or non snc databases should be returned
Returns:

getDataSourcesWithType

public java.util.Vector<java.lang.String[]> getDataSourcesWithType()
Method returns for all data source name, type and sync property

Returns:
a vector of string arrays

getDataSourceType

public java.lang.String getDataSourceType(java.lang.String name)
getDataSourceType returns the type of a data source stored in a data source configuration file

Parameters:
name - the data sorce name
Returns:
the data source type

getProperty

public java.lang.String getProperty(java.lang.String configName,
                                    java.lang.String property)
getProperty returns a specific data configuration property based on the name heartsome

Parameters:
configName - the configuration name
property - the property name
Returns:
the value of the property or null if not found

removeConfiguration

public boolean removeConfiguration(java.lang.String configName)
removeConfiguration remove a configuration from the data source configurations

Parameters:
databasename -
Returns:
true if removed otherwise false

saveToXmlFile

public boolean saveToXmlFile(java.lang.String filename)
Description copied from class: XmlDocument
saveToXmlFile writes the document to the given file name

Overrides:
saveToXmlFile in class XmlDocument
Parameters:
filename - the file anme for the output xml file
Returns:
true in case of success / false otherwise

setConfigurationFileName

public void setConfigurationFileName(java.lang.String configurationFileName)
Explicitly set the name if DataSourceConfigurations

Parameters:
configurationFileName - the configurationFileName to set