i-net Clear Reports

com.inet.report.config.datasource
Class DataSourceConfigurationManager

java.lang.Object
  extended by com.inet.report.config.datasource.DataSourceConfigurationManager

public class DataSourceConfigurationManager
extends java.lang.Object

This is the main class to manage data source configurations in i-net Clear Reports. A datasource configuration defines from which location/ by which way the data for a report will set. For GUI application you can open the DataSource-Manager dialog with DataSourceConfigurationManager.openDataSourceManagerDialog(Frame,DataSourceConfiguration). If a data source configuration is already created, it is easy to configure a report to use this configuration. The datasource configuration will be stored by using java.util.prefs.Preferences.

See Also:
DataSourceConfiguration, Datasource

Field Summary
static int ALL_PREFERENCES
          This scope is used to return all configurations.
static int SYSTEM_PREFERENCES
          This scope store the configuration in the system preferences.
static int TEMPORARY_PREFERENCES
          This scope store the configuration only in the memory.
static int USER_PREFERENCES
          This scope store the configuration in the user preferences.
static int USER_SESSION
          This scope store the configuration in the servlet session.
 
Method Summary
static void addDataSourceConfigurationListener(DataSourceConfigurationChangeListener dscl)
          Add here a DataSourceConfigurationChangeListener to get informed when a DataSourceConfiguration was edited.
static DataSourceConfiguration createDataSourceConfiguration(java.lang.String configurationName, int preferenceScope)
          Creates a new DataSourceConfiguration using the first parameter as configuration name.
static boolean exists(java.lang.String configurationName)
          Checks if the DataSourceConfiguration specified by the given configuration name does exist for user or system scope.
static boolean exists(java.lang.String configurationName, int preferenceScope)
          Checks if the DataSourceConfiguration specified by the given configuration name does exist for the given scope.
static void exportDataSourceConfigurations(DataSourceConfiguration[] configs, java.io.File exportFile)
          Exports data source configurations.
static void forceImportDataSourceConfigurations(int preferenceScope, java.io.File fileToImport)
          Imports data source configurations, replacing any existing ones with the same name
static DataSourceConfiguration getDataSourceConfiguration(java.lang.String configurationName, int preferenceScope)
          Returns the DataSourceConfiguration specified by the given configuration name and scope.
static DataSourceConfigurationChangeListener[] getDataSourceConfigurationListeners()
          Returns the list of listeners.
static java.lang.String[] getDataSourceConfigurationNames()
          Returns the configuration names of all DataSourceConfigurations stored for user and system scope.
static java.lang.String[] getDataSourceConfigurationNames(int preferenceScope)
          Returns the configuration names of all DataSourceConfigurations stored for the given scope.
static DataSourceConfiguration[] getDataSourceConfigurations(int preferenceScope)
          Returns the DataSourceConfiguration objects stored for the given scope.
static java.lang.String getUniqueName(java.lang.String configurationName, int preferenceScope)
          Creates a unique configuration name from the supplied name for the given scope.
static void importDataSourceConfigurations(int preferenceScope, java.io.File importFile)
          Imports one or more data source configurations from an XML file.
static void importDataSourceConfigurations(int preferenceScope, java.io.File importFile, boolean ignoreIfExist)
          Imports one or more data source configurations from an XML file.
static boolean isReadable(int preferenceScope)
          Check if the scope is readable.
static boolean isWriteable(int preferenceScope)
          Check if the scope is writable.
static DataSourceConfiguration openDataSourceConfigurationDialog(java.awt.Frame owner, DataSourceConfiguration dsc, java.lang.String suffix)
          Deprecated. As of i-net Crystal-Clear 10.0, use openDataSourceManagerDialog(Frame, DataSourceConfiguration)
static void openDataSourceManagerDialog(java.awt.Frame owner, DataSourceConfiguration dsc)
          Executes the data source manager dialog to manage the dataource configurations.
static void openDataSourceManagerDialog(java.awt.Dialog owner, DataSourceConfiguration dsc)
          Executes the data source manager dialog to manage the dataource configurations.
static void removeDataSourceConfigurationListener(DataSourceConfigurationChangeListener dscl)
          Removes the listener from list.
static void removeDatasourceConfiguration(java.lang.String configurationName, int preferenceScope)
          Removes the datasource configuration.
static void removeDatasourceConfigurations(DataSourceConfiguration[] configs, int preferenceScope)
          Removes a collection of DataSourceConfigurations.
 

Field Detail

SYSTEM_PREFERENCES

public static final int SYSTEM_PREFERENCES
This scope store the configuration in the system preferences. The current user need the required rights.

See Also:
Constant Field Values

USER_PREFERENCES

public static final int USER_PREFERENCES
This scope store the configuration in the user preferences. The current user need the required rights. In a not signed Java applet the user does not have the rights. On Windows the system account of a service has also not the rights.

See Also:
Constant Field Values

ALL_PREFERENCES

public static final int ALL_PREFERENCES
This scope is used to return all configurations.

See Also:
Constant Field Values

TEMPORARY_PREFERENCES

public static final int TEMPORARY_PREFERENCES
This scope store the configuration only in the memory.

Since:
7.5
See Also:
Constant Field Values

USER_SESSION

public static final int USER_SESSION
This scope store the configuration in the servlet session. It is only in a servlet environment available.

Since:
11.1
See Also:
Constant Field Values
Method Detail

getUniqueName

public static java.lang.String getUniqueName(java.lang.String configurationName,
                                             int preferenceScope)
Creates a unique configuration name from the supplied name for the given scope.

Parameters:
configurationName - the name that will be used as a basis for the unique name.
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.TEMPORARY_PREFERENCES
  • DataSourceConfigurationManager.USER_SESSION
  • DataSourceConfigurationManager.ALL_PREFERENCES
Returns:
String - a unique configuration name.

getDataSourceConfigurationNames

public static java.lang.String[] getDataSourceConfigurationNames()
Returns the configuration names of all DataSourceConfigurations stored for user and system scope.

Returns:
String[] which contains the datasource configuration names.
See Also:
getDataSourceConfigurationNames(int)

getDataSourceConfigurationNames

public static java.lang.String[] getDataSourceConfigurationNames(int preferenceScope)
Returns the configuration names of all DataSourceConfigurations stored for the given scope.

Parameters:
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.TEMPORARY_PREFERENCES
  • DataSourceConfigurationManager.USER_SESSION
  • DataSourceConfigurationManager.ALL_PREFERENCES
Returns:
String[] which contains the datasource configuration names.
Throws:
java.lang.IllegalArgumentException - if the given preferenceScope parameter is not equal to a valid parameter value listed below.
See Also:
getDataSourceConfigurationNames()

getDataSourceConfigurations

public static DataSourceConfiguration[] getDataSourceConfigurations(int preferenceScope)
Returns the DataSourceConfiguration objects stored for the given scope.

Parameters:
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.TEMPORARY_PREFERENCES
  • DataSourceConfigurationManager.USER_SESSION
  • DataSourceConfigurationManager.ALL_PREFERENCES
Returns:
DataSourceConfiguration[] which contains the datasource configurations of the given scope.
Throws:
java.lang.IllegalArgumentException - if the given preferenceScope parameter is not equal to a valid parameter value listed below.
java.lang.IllegalStateException - If the scope is USER_SCOPE and no HttpSession is available.
See Also:
getDataSourceConfiguration(String, int)

getDataSourceConfiguration

public static DataSourceConfiguration getDataSourceConfiguration(java.lang.String configurationName,
                                                                 int preferenceScope)
Returns the DataSourceConfiguration specified by the given configuration name and scope.

Parameters:
configurationName - the name identifies the datasource configuration.
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.ALL_PREFERENCES
Returns:
DataSourceConfiguration - the specified configuration if exists OR
null - if the specified configuration does not exist.
Throws:
java.lang.IllegalArgumentException - if the given preferenceScope parameter is not equal to a valid parameter value listed below.
java.lang.IllegalStateException - If the scope is USER_SCOPE and no HttpSession is available.

exists

public static boolean exists(java.lang.String configurationName)
Checks if the DataSourceConfiguration specified by the given configuration name does exist for user or system scope.

Parameters:
configurationName - the name identifies the datasource configuration.
Returns:
true - if the datasource configuration is known, otherwise false.
See Also:
exists(String, int)

isWriteable

public static boolean isWriteable(int preferenceScope)
Check if the scope is writable. The temporary scope is ever writable.

Parameters:
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.TEMPORARY_PREFERENCES
  • DataSourceConfigurationManager.USER_SESSION
  • DataSourceConfigurationManager.ALL_PREFERENCES
Returns:
true if the scope is writable.
Throws:
java.lang.IllegalArgumentException - if the given preferenceScope parameter is not equal to a valid parameter value listed below.

isReadable

public static boolean isReadable(int preferenceScope)
Check if the scope is readable. The temporary scope and all scope are ever readable.

Parameters:
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.TEMPORARY_PREFERENCES
  • DataSourceConfigurationManager.USER_SESSION
  • DataSourceConfigurationManager.ALL_PREFERENCES
Returns:
true if the scope is readable.
Throws:
java.lang.IllegalArgumentException - if the given preferenceScope parameter is not equal to a valid parameter value listed below.

exists

public static boolean exists(java.lang.String configurationName,
                             int preferenceScope)
Checks if the DataSourceConfiguration specified by the given configuration name does exist for the given scope.

Parameters:
configurationName - the name identifies the datasource configuration.
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.ALL_PREFERENCES
Returns:
true if the datasource configuration exist for the given scope, otherwise false.
See Also:
exists(String)

createDataSourceConfiguration

public static DataSourceConfiguration createDataSourceConfiguration(java.lang.String configurationName,
                                                                    int preferenceScope)
                                                             throws java.lang.SecurityException
Creates a new DataSourceConfiguration using the first parameter as configuration name. Afterwards the configuration properties will be saved for user or system scope, considering the second parameter.
This method ensures that the name of each created configuration object is unique. If the given configuration name is already used by an existing configuration in the same scope, the name will be changed by appending a count.

Parameters:
configurationName - the name identifies the specific datasource configuration. Must not be empty or null
preferenceScope - determines the scope for the new configuration.
Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.TEMPORARY_PREFERENCES
  • DataSourceConfigurationManager.USER_SESSION
Returns:
DataSourceConfiguration - a new datasource configuration object.
Throws:
java.lang.NullPointerException - If the supplied configuration name is null.
java.lang.IllegalArgumentException - If the supplied configuration name is empty or if the given preferenceScope parameter is not equal to a valid parameter value listed below.
java.lang.SecurityException - if there is no write access to the given Java Preferences
See Also:
saveDataSourceConfiguration(DataSourceConfiguration, int), DataSourceConfiguration, DatabaseTables.createDatasource(String)

removeDatasourceConfigurations

public static void removeDatasourceConfigurations(DataSourceConfiguration[] configs,
                                                  int preferenceScope)
Removes a collection of DataSourceConfigurations.

Parameters:
configs - An array of DataSourceConfigurations to remove.
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES

removeDatasourceConfiguration

public static void removeDatasourceConfiguration(java.lang.String configurationName,
                                                 int preferenceScope)
Removes the datasource configuration.

Parameters:
configurationName - the unique name identifies the configuration.
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.TEMPORARY_PREFERENCES
  • DataSourceConfigurationManager.USER_SESSION
Throws:
java.lang.IllegalArgumentException - If the supplied configuration name is null or empty or if the given preferenceScope parameter is not equal to a valid parameter value listed below.
See Also:
createDataSourceConfiguration(String, int)

forceImportDataSourceConfigurations

public static void forceImportDataSourceConfigurations(int preferenceScope,
                                                       java.io.File fileToImport)
                                                throws ReportException,
                                                       java.lang.SecurityException
Imports data source configurations, replacing any existing ones with the same name

Parameters:
preferenceScope - scope to import into. Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.TEMPORARY_PREFERENCES
  • DataSourceConfigurationManager.USER_SESSION
fileToImport - representation of the XML file which contains the data source configurations for import
Throws:
ReportException - If the file can't be imported.
java.lang.SecurityException - if there is no write access to the given Java Preferences
See Also:
importDataSourceConfigurations(int, File)

importDataSourceConfigurations

public static void importDataSourceConfigurations(int preferenceScope,
                                                  java.io.File importFile)
                                           throws ReportException
Imports one or more data source configurations from an XML file. The supplied DataSourceConfiguration will be renamed if a DataSourceConfiguration with this name already exists.

Parameters:
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.TEMPORARY_PREFERENCES
  • DataSourceConfigurationManager.USER_SESSION
importFile - representation of the XML file which contains the data source configurations for import
Throws:
ReportException - If the file can't imported.
See Also:
exportDataSourceConfigurations(DataSourceConfiguration[], File)

importDataSourceConfigurations

public static void importDataSourceConfigurations(int preferenceScope,
                                                  java.io.File importFile,
                                                  boolean ignoreIfExist)
                                           throws ReportException,
                                                  java.lang.SecurityException
Imports one or more data source configurations from an XML file.

Parameters:
preferenceScope - Possible values:
  • DataSourceConfigurationManager.SYSTEM_PREFERENCES
  • DataSourceConfigurationManager.USER_PREFERENCES
  • DataSourceConfigurationManager.TEMPORARY_PREFERENCES
  • DataSourceConfigurationManager.USER_SESSION
importFile - representation of the XML file which contains the data source configurations for import
ignoreIfExist - True if the supplied DataSourceConfiguration should be ignored if a DataSourceConfiguration with this name already exists or false if the supplied DataSourceConfiguration should be renamed if a DataSourceConfiguration with this name already exists.
Throws:
ReportException - If the file can't import.
java.lang.SecurityException - if there is no write access to the given Java Preferences
See Also:
exportDataSourceConfigurations(DataSourceConfiguration[], File)

exportDataSourceConfigurations

public static void exportDataSourceConfigurations(DataSourceConfiguration[] configs,
                                                  java.io.File exportFile)
Exports data source configurations.

Parameters:
configs - Array which contains the DataSourceConfigurations for export
exportFile - representation of the target XML file
See Also:
importDataSourceConfigurations(int, File)

addDataSourceConfigurationListener

public static void addDataSourceConfigurationListener(DataSourceConfigurationChangeListener dscl)
Add here a DataSourceConfigurationChangeListener to get informed when a DataSourceConfiguration was edited.

Parameters:
dscl - the DataSourceConfigurationChangeListener that get informed about changes of DataSourceConfiguration objects.

getDataSourceConfigurationListeners

public static DataSourceConfigurationChangeListener[] getDataSourceConfigurationListeners()
Returns the list of listeners. This can be used to fire own events to all registered listeners.

Returns:
an array of DataSourceConfigurationChangeListener

removeDataSourceConfigurationListener

public static void removeDataSourceConfigurationListener(DataSourceConfigurationChangeListener dscl)
Removes the listener from list. It will receive no notification after unregistering.

Parameters:
dscl - the listener to be removed.

openDataSourceManagerDialog

public static void openDataSourceManagerDialog(java.awt.Frame owner,
                                               DataSourceConfiguration dsc)
Executes the data source manager dialog to manage the dataource configurations. To get notified about made changes, you can register a DataSourceConfigurationChangeListener

Parameters:
owner - set an owner to open this dialog modal.
dsc - a DataSourceConfiguration for preselection OR null
See Also:
addDataSourceConfigurationListener(DataSourceConfigurationChangeListener)

openDataSourceManagerDialog

public static void openDataSourceManagerDialog(java.awt.Dialog owner,
                                               DataSourceConfiguration dsc)
Executes the data source manager dialog to manage the dataource configurations. To get notified about made changes, you can register a DataSourceConfigurationChangeListener

Parameters:
owner - set an owner to open this dialog modal.
dsc - a DataSourceConfiguration for preselection OR null
See Also:
addDataSourceConfigurationListener(DataSourceConfigurationChangeListener)

openDataSourceConfigurationDialog

@Deprecated
public static DataSourceConfiguration openDataSourceConfigurationDialog(java.awt.Frame owner,
                                                                                   DataSourceConfiguration dsc,
                                                                                   java.lang.String suffix)
Deprecated. As of i-net Crystal-Clear 10.0, use openDataSourceManagerDialog(Frame, DataSourceConfiguration)

Executes a dialog to select a DataSourceConfiguration for a new report or a new connection.

Parameters:
owner - set an owner to open this dialog modal.
dsc - a DataSourceConfiguration for preselection OR null
suffix - an optional suffix (can be null) which will be appended to the title in order to specify what the connection is intended for
Returns:
The DataSourceConfiguration which was selected in the dialog OR null if no configuration was selected.

i-net Clear Reports

Copyright © 1999-2015 by i-net software GmbH