Configuration Data Class

The class ConfigData provides global application data which are stored in static (shared) variables.

Overview

ConfigData
...()
ActiveGroup: ActiveGroup
ActiveGroupTableName: String
FilterAnalysis: Hashtable
FilterMining: Hashtable
Icon(): Icon
closeAllForms()
DependentForm_Closing(...)
formatDate(ByRef InputDate: Date): String
formatDate(ByVal InputDate: String): Date
getColorFromDialog(ByRef DefaultColor: Color): Color
getDatabaseConnection(): IDbConnection
getDatabaseEngine(): String
getDeletionWildCard(): String
getGeneralWildCard(): String
getImportFilter(Name: String): ImportFilterData
getImportFilterNames(): String()
getNextInsertID(Table: String): Integer
getQuotes(): String
getSharedDatabaseConnection(ByRef con: IDbConnection)
getSystemGroupNewName(): String
getSystemGroupNewID(): Integer
handleException(ByRef exc: Exception)
handleForm(ByRef DependentForm: Form): void
quoteString(input: String): String
unquoteString(input: String): String
removeActiveGroupTableFromDB(): void
saveImage(ByRef BitmapImage: Bitmap): void
start(): void
translateBooleanToString(InputValue: Boolean): String
translateStringToBoolean(InputValue: String): Boolean

Programming Language

  • Microsoft Visual Basic .Net.

Availability

Constructors

Since all data and functions of this class are meant to be global, they are all declared static (=shared). Hence, no constructor is available.

Interfaces

The class does not implement any interfaces.

Enumerations

The class does not provide enumerations.

Properties

Public Shared Property ActiveGroup as ActiveGroup

Gets or sets the presently selected group or subgroup of patients in the CyDAS application.

Property Value

  • the presently selected group or subgroup of patients

Remarks

  • The value is set from the CyDAS application when a group is opened or closed.
  • Any CyDAS window may access this group through the ConfigData class.

Public Shared ReadOnly Property ActiveGroupTableName as String

Gets the name of the database table for the ActiveGroup for this session.

Property Value

  • the name of the database table for the ActiveGroup.

Remarks

  • The name of the database table for the ActiveGroup is valid for a whole session. A temporary table is created on the database for each session in order to allow for a simultaneous multi-user access.
  • The table name is created in the private function createTableForActiveGroup(). It has the following structure: After the initial characters "AG" follows the date, an "N", and a digit. Generally, this table is removed when the CyDAS application is closed via the removeActiveGroupTableFromDB() function.

Public Shared Property FilterAnalysis as Hashtable

Gets or sets the general paramters for data analysis.

Property Value

  • the general paramters for data analysis.

Remarks

  • The value is set from the CyDAS main window.
  • Any CyDAS analysis window receives its default paramters through this property. If the parameters are changed inside an analysis window, a new hashtable is created there, thus not influencing other windows.

Public Shared Property FilterMining as Hashtable

Gets or sets the general parameters for data mining.

Property Value

  • the general paramters for data mining.

Remarks

  • The value is set from the CyDAS main window.
  • Any CyDAS mining window receives its default paramters through this property. If the parameters are changed inside a mining window, a new hashtable is created there, thus not influencing other windows.

Public Shared Property Icon as Icon

Gets or sets the default icon for the windows of the CyDAS application.

Property Value

  • the default icon of the CyDAS application

Remarks

  • The value is set during the instantiation of the CyDAS main window (Form1).
  • Other windows get it from this position during their instantiation process.

Methods

When accessing any of the functions below, a call to the private function init(see also start()) is made in order to ensure the correct initialisation of all values.

Public Shared Sub closeAllForms()

Closes all forms pertaining to the presently active group.

Return Value

  • None.

Parameters

  • None.

Remarks

  • The forms to be closed are added to an internal collection of dependent forms with the handleForm() function.
  • If a dependent form is closed from its menu or via this function, it is removed from that collection in the DependentForm_Closing function.

Private Shared Sub DependentForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)

This function handles the Form_Closing event of dependent forms. It removes the closing form from the collection of dependent forms.

Return Value

  • None.

Parameters

  • sender, e: as passed from the Form_Closing event.

Remarks

  • In  the handleForm() function, the Form_Closing event handler was set to this function.

Public Shared Function formatDate(ByRef InputDate As Date) As String

Formats a date into a string in "YYYYMMDD" format.

Return Value

  • a date string in "YYYYMMDD" format.

Parameters

Remarks

  • Different databases require different date formats. Hence, all dates are transformed into an eight-character string of format "YYYYMMDD".
  • This function is the reversal of the other formatDate() function.

Public Shared Function formatDate(ByVal InputDate As String) As Date

Instantiates a date object from a string representation of the date.

Return Value

  • a date value resembling the textual description.

Parameters

  • InputDate: a textual description of the date in "YYYYMMDD" format.

Remarks

  • Different databases require different date formats. Hence, all dates are transformed into an eight-character string of format "YYYYMMDD".
  • This function is the reversal of the other formatDate() function.

Public Shared Function getColorFromDialog(ByRef DefaultColor As Color) As Color

Opens a standard windows color dialog and retrieves the user selection from it.

Return Value

  • the user selected color.
  • the DefaultColor, if the user cancelled the selection from the dialog.

Parameters

  • DefaultColor: the color to start the selection.

Remarks

  • If the user cancels the selection from the standard dialog, he will be asked in a message box if he wants to set the color to transparent or if he really wants cancel; thus, also Color.Transparent can be selected.

Public Shared Function getDatabaseConnection() As IDbConnection

Establishes a new database connection and returns it.

Return Value

  • a connection to the CyDAS database.

Parameters

  • None.

Remarks

  • The return type is IDbConnection instead of a specific type (i.e. OleDbConnection for MS Access, SqlConnection for MS SQL-Server, OdbcConnection for MySQL; originally, objects of these types are instantiated but returned as IDbConnection) in order to render the handling easy.
  • Other database engines were not yet tested with CyDAS; they might be accessible with the OdbcConnection section used with MySQL.

Public Shared Function getDatabaseEngine() As String

Returns the name of the database engine as stated in the CyDAS.ini file.

Return Value

  • the name of the database engine.

Parameters

  • None.

Remarks

  • It is not checked if the name of the database engine is useful.

Public Shared Function getDeletionWildCard() As String

Returns the wild card character to be used in an SQL DELETE statement.

Return Value

  • "*", for MS Access databases.
  • empty string, for other databses.

Parameters

  • None.

Remarks

  • The type of wild card is determined during the start up procedure in the private function readIniFile.

Public Shared Function getGeneralWildCard() As String

Returns the wild card character to be used in an SQL LIKE statement for a non-defined number of characters.

Return Value

  • "*", for MS Access and SQL server databases.
  • "%", for MySQL databases.

Parameters

  • None.

Remarks

  • The type of wild card is determined during the start up procedure in the private function readIniFile.

Public Shared Function getImportFilter(ByVal Name As String) As ImportFilterData

Returns an ImportFilterData object representing the import filter given by Name.

Return Value

Parameters

Remarks

  • The import filters are read during the start up process in the private function readInputFilter.
  • A file with the Name of the filter and the extension ".cif" (= CyDAS Import Filter) must be present in the CyDAS directory.

Public Shared Function getImportFilterNames() As String()

Returns a string array with the names of all available import filters.

Return Value

  • a string array with the names of all available import filters.

Parameters

  • None.

Remarks

Public Shared Function getNextInsertID(ByVal Table As String) As Integer

CyDAS database tables use an integer number as an internal data row identifier; it is always named "ID". With this function, the next higher value for such an ID can be retrieved.

Return Value

  • the next higher value for the ID value in a given CyDAS database table.

Parameters

  • Table: the name of the database table.

Remarks

  • Though some database engines provide special parameters for querying the next insert id, a generic statement is used: "Select Max(ID) From <Table>", thereafter 1 is added.

Public Shared Function getQuotes() As String

Returns the quotation marks to be used with the current database engine.

Return Value

  • """, for MS Access and SQL server databases.
  • "'", for MySQL and SQL server databases.

Parameters

  • None.

Remarks

  • The type of quotation marks is determined during the start up procedure in the private function readIniFile.

Public Shared Sub getSharedDatabaseConnection(ByRef con As IDbConnection)

Returns a reference to the database connection which is established during start up.

Return Value

  • None.

Parameters

  • a reference to a database connection.

Remarks

  • This special database connection is established already during the start up of CyDAS and re-used for many queries. This is intended to speed up performance since the creation and establishment of a connection takes some resources.
  • The connection is also passed by reference to ensure highest performance.

Known Problems

  • If an exception occurs while data are read via this connection, the IDbReader associated with it is not closed and hence the connection is blocked. A restart of CyDAS may be required. Visual Basic .NET does not offer a possibility to query the connection if an open reader is associated with it, so that a new connection could be established in such a case.

Public Shared Function getSystemGroupNewName() As String

Returns the name of the system group "New".

Return Value

  • "New".

Parameters

  • None.

Remarks

  • Upto now, the name for the system group "New" cannot be changed and is hard coded.

Public Shared Function getSystemGroupNewID() As Integer

Returns the internal number of the system group "New".

Return Value

  • 1.

Parameters

  • None.

Remarks

  • Upto now, the number for the system group "New" cannot be changed and is hard coded.

Public Shared Sub handleException(ByRef exc As Exception)

This function is generally used to handle exceptions caught by a Try ... Catch() clause in the CyDAS application. It displays the descriptions of the exception (Exception.Message) followed by the Stack Trace (Exception.StackTrace) in a message box to the user. If an Inner Exception is present, these items of information are also displayed for the inner exception(s) recursively.

Return Value

  • None.

Parameters

  • exc: the exception which occured somewhere in the CyDAS application.

Remarks

  • Generally, all event handler functions are equipped with the necessary Try ... Catch() blocks.

To do

  • Provide the user with some functionality to save this information and email it to the CyDAS developer team.

Public Shared Sub handleForm(ByRef DependentForm As Form)

When the acxtive group is changed or closed, all analysis and mining windows associated with the previously active group must be closed. This function stores all those windows in a collection and adds appropriate event handlers to them.

Return Value

  • None.

Parameters

  • DependentForm: a reference to a window to be controlled in the manner described above.

Remarks

Public Shared Function quoteString(ByVal input As String) As String

Replaces quotation marks by a neutral character.

When data containing quotes have to be stored in the database, these quotation marks would destroy the SQL query. Hence they are replaced by a neutral character (upto now hard-coded: "|").

Return Value

  • a string with the quotation marks replaced by a replacement character ("|").

Parameters

  • input: a string whose quotation marks have to be replaced.

Remarks

Public Shared Function unquoteString(ByVal input As String) As String

Re-introduces quotation marks into a string whose quotation marks had been replaced by a replacement character.

When data containing quotes have to be stored in the database, these quotation marks would destroy the SQL query. Hence they are replaced by a neutral character (upto now hard-coded: "|").

Return Value

  • a string containing quotation marks in position of a previous replacement character.

Parameters

  • input: a string whose quotation marks had previously been replaced.

Remarks

Public Shared Sub removeActiveGroupTableFromDB()

Removes the temporary table for the ActiveGroup from the database.

Return Value

  • None.

Parameters

  • None.

Remarks

  • The function is normally called when the CyDAS application is being closed.

Public Shared Sub saveImage(ByRef BitmapImage As Bitmap)

The function saves a bitmap into a disk file. A standard windows "save as" dialog is used for determining the file name.

Return Value

  • None:

Parameters

  • BitmapImage: a reference to a bitmap to be saved to disk.

Remarks

  • The following file types are supported:
    • portable networks graphics (png)
    • joint picture experts group (jpg)
    • graphics interchange format (gif)
    • btimap (bmp)
    • tagged image file (tif)
  • If the extension does not correspond to the format or is absent, the extensions shown above in brackets are added.

Public Shared Sub start()

Causes the initialisation of the variables of the class.

The initialisation is delegated to the private function init(). It checks if initialisation has already been performed. Then it sets up the collections for the import filters and the dependent forms, and reads the configuration file and the import filters. There after, the shared database connection is established and opened.

Return Value

  • None.

Parameters

  • None.

Remarks

  • Internally, the work is done bythe private function init() which is called from start().

Friend Shared Function translateBooleanToString(ByVal InputValue As Boolean) As String

Translates a boolean value into a string ("Y" / "N").

Return Value

  • "Y" if InputValue is true.
  • "N" if InputValue is false.

Parameters

  • InputValue: a boolean value to be translated.

Remarks

  • Not all database engines support the boolean datatype. Hence, boolean data are translated into a string of length 1.
  • The function is reversed by translateStringToBoolean().

Friend Shared Function translateStringToBoolean(ByVal InputValue As String) As Boolean

Translates a string ("Y" / "N") into a boolean value.

Return Value

  • true, if InputValue is "Y" or "y".
  • false, otherwise.

Parameters

  • InputValue: a string to be translated into a boolean value.

Remarks

  • The InputValue is not case sensitive.
  • Any values different from "Y" / "y" are simply translated into false instead of raising an error for nonsense input.
  • This function is the reversal of translateBooleanToString() which is required because not all database engines support the boolean datatype and hence boolean data are translated into a string of length 1.