Class DataSourceConfigurationManager
java.lang.Object
com.inet.report.config.datasource.DataSourceConfigurationManager
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.- Since:
- 7.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Deprecated.As of i-net Clear Reports 20.0static final int
This scope store the configuration in the persistence of the application.static final int
This scope does not store the configuration.static final int
This scope store the configuration in the system preferences.static final int
This scope store the configuration only in the memory.static final int
This scope store the configuration in the user preferences.static final int
This scope store the configuration in the servlet session. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Add here aDataSourceConfigurationChangeListener
to get informed when aDataSourceConfiguration
was edited.static DataSourceConfiguration
createDataSourceConfiguration
(String configurationName, int scope) Creates a newDataSourceConfiguration
using the first parameter as configuration name.static boolean
Checks if theDataSourceConfiguration
specified by the given configuration name does exist for user or system scope.static boolean
Checks if theDataSourceConfiguration
specified by the given configuration name does exist for the given scope.static void
exportDataSourceConfigurations
(DataSourceConfiguration[] configs, File exportFile) Exports data source configurations to the given file in an XML format.static void
exportDataSourceConfigurations
(DataSourceConfiguration[] configs, OutputStream stream) Exports data source configurations to the given file in an XML format.static void
forceImportDataSourceConfigurations
(int preferenceScope, File fileToImport) Imports data source configurations, replacing any existing ones with the same namestatic DataSourceConfiguration
getDataSource
(com.inet.id.GUID uid) Returns theDataSourceConfiguration
specified by the given uid.static DataSourceConfiguration
getDataSource
(String name) Returns theDataSourceConfiguration
specified by the given name.static DataSourceConfiguration
getDataSourceConfiguration
(String configurationName, int preferenceScope) Returns theDataSourceConfiguration
specified by the given configuration name and scope.Returns the list of listeners.static String[]
Returns the configuration names of allDataSourceConfiguration
s stored for user and system scope.static String[]
getDataSourceConfigurationNames
(int preferenceScope) Returns the configuration names of allDataSourceConfiguration
s stored for the given scope.static DataSourceConfiguration[]
getDataSourceConfigurations
(int scope) Returns theDataSourceConfiguration
objects stored for the given scope.static String
getUniqueName
(String configurationName, int preferenceScope) Creates a unique configuration name from the supplied name for the given scope.static void
importDataSourceConfigurations
(int preferenceScope, File importFile) Imports one or more data source configurations from an XML file.static void
importDataSourceConfigurations
(int preferenceScope, File importFile, boolean ignoreIfExist) Imports one or more data source configurations from an XML file.static DataSourceConfiguration[]
importDataSourceConfigurations
(int preferenceScope, InputStream importStream) Imports one or more data source configurations from an XML file.static DataSourceConfiguration[]
importDataSourceConfigurations
(int preferenceScope, InputStream importStream, 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 void
Removes the datasource configuration.static void
removeDatasourceConfiguration
(String configurationName, int preferenceScope) Deprecated.As of i-net Clear Reports 20.0, useremoveDatasourceConfiguration(DataSourceConfiguration)
insteadstatic void
Removes the listener from list.static void
removeDatasourceConfigurations
(DataSourceConfiguration[] configs, int preferenceScope) Removes a collection ofDataSourceConfiguration
s from the given scope.
-
Field Details
-
NO_STORE
public static final int NO_STOREThis scope does not store the configuration. It is for one time usage.- Since:
- 20.0
- See Also:
-
SYSTEM_PREFERENCES
public static final int SYSTEM_PREFERENCESThis scope store the configuration in the system preferences. The current user need the required rights.- See Also:
-
USER_PREFERENCES
public static final int USER_PREFERENCESThis 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:
-
ALL_PREFERENCES
Deprecated.As of i-net Clear Reports 20.0This scope is used to return all (withoutAPPLICATION
) configurations.- See Also:
-
TEMPORARY_PREFERENCES
public static final int TEMPORARY_PREFERENCESThis scope store the configuration only in the memory.- Since:
- 7.5
- See Also:
-
USER_SESSION
public static final int USER_SESSIONThis scope store the configuration in the servlet session. It is only in a servlet environment available.- Since:
- 11.1
- See Also:
-
APPLICATION
public static final int APPLICATIONThis scope store the configuration in the persistence of the application.- Since:
- 20.0
- See Also:
-
-
Method Details
-
getUniqueName
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.- Since:
- 7.5
-
getDataSourceConfigurationNames
Returns the configuration names of allDataSourceConfiguration
s stored for user and system scope.- Returns:
String[]
which contains the datasource configuration names.- Since:
- 7.5
- See Also:
-
getDataSourceConfigurationNames
Returns the configuration names of allDataSourceConfiguration
s 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:
IllegalArgumentException
- if the givenpreferenceScope
parameter is not equal to a valid parameter value listed below.- Since:
- 7.5
- See Also:
-
getDataSourceConfigurations
Returns theDataSourceConfiguration
objects stored for the given scope.- Parameters:
scope
- Possible values:- SYSTEM_PREFERENCES
- USER_PREFERENCES
- TEMPORARY_PREFERENCES
- USER_SESSION
- APPLICATION
- Returns:
DataSourceConfiguration[]
which contains the datasource configurations of the given scope.- Throws:
IllegalArgumentException
- if the givenpreferenceScope
parameter is not equal to a valid parameter value listed below.IllegalStateException
- If the scope is USER_SCOPE and no HttpSession is available.- Since:
- 7.5
- See Also:
-
getDataSourceConfiguration
public static DataSourceConfiguration getDataSourceConfiguration(String configurationName, int preferenceScope) Returns theDataSourceConfiguration
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:
IllegalArgumentException
- if the givenpreferenceScope
parameter is not equal to a valid parameter value listed below.IllegalStateException
- If the scope is USER_SCOPE and no HttpSession is available.- Since:
- 7.5
-
exists
Checks if theDataSourceConfiguration
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, otherwisefalse
.- Since:
- 7.5
- See Also:
-
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:
IllegalArgumentException
- if the givenpreferenceScope
parameter is not equal to a valid parameter value listed below.- Since:
- 7.5
-
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:
IllegalArgumentException
- if the givenpreferenceScope
parameter is not equal to a valid parameter value listed below.- Since:
- 7.5
-
exists
Checks if theDataSourceConfiguration
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.APPLICATION
- DataSourceConfigurationManager.TEMPORARY_PREFERENCES
- DataSourceConfigurationManager.USER_SESSION
- Returns:
true
if the datasource configuration exist for the given scope, otherwisefalse
.- Since:
- 7.5
- See Also:
-
createDataSourceConfiguration
public static DataSourceConfiguration createDataSourceConfiguration(String configurationName, int scope) throws SecurityException Creates a newDataSourceConfiguration
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 ornull
scope
- determines the scope for the new configuration.
Possible values:- DataSourceConfigurationManager.SYSTEM_PREFERENCES
- DataSourceConfigurationManager.USER_PREFERENCES
- DataSourceConfigurationManager.APPLICATION
- DataSourceConfigurationManager.TEMPORARY_PREFERENCES
- DataSourceConfigurationManager.USER_SESSION
- Returns:
DataSourceConfiguration
- a new datasource configuration object.- Throws:
NullPointerException
- If the supplied configuration name is null.IllegalArgumentException
- If the supplied configuration name is empty or if the givenpreferenceScope
parameter is not equal to a valid parameter value listed below.SecurityException
- if there is no write access to the given Java Preferences- Since:
- 7.5
- See Also:
-
save(DataSourceConfiguration, int)
DataSourceConfiguration
DatabaseTables.createDatasource(String)
-
removeDatasourceConfigurations
public static void removeDatasourceConfigurations(DataSourceConfiguration[] configs, int preferenceScope) Removes a collection ofDataSourceConfiguration
s from the given scope.- Parameters:
configs
- An array of DataSourceConfigurations to remove.preferenceScope
- Possible values:- DataSourceConfigurationManager.SYSTEM_PREFERENCES
- DataSourceConfigurationManager.USER_PREFERENCES
- DataSourceConfigurationManager.APPLICATION
- Since:
- 7.5
-
removeDatasourceConfiguration
@Deprecated public static void removeDatasourceConfiguration(String configurationName, int preferenceScope) throws IllegalArgumentException, SecurityException Deprecated.As of i-net Clear Reports 20.0, useremoveDatasourceConfiguration(DataSourceConfiguration)
insteadRemoves the datasource configuration from the given scope.- Parameters:
configurationName
- the unique name identifies the configuration.preferenceScope
- Possible values:- DataSourceConfigurationManager.SYSTEM_PREFERENCES
- DataSourceConfigurationManager.USER_PREFERENCES
- DataSourceConfigurationManager.APPLICATION
- DataSourceConfigurationManager.TEMPORARY_PREFERENCES
- DataSourceConfigurationManager.USER_SESSION
- Throws:
IllegalArgumentException
- If the supplied configuration name isSecurityException
- if you have no write rights to the preferences scope.null
or empty or if the givenpreferenceScope
parameter is not equal to a valid parameter value listed below.- Since:
- 7.5
- See Also:
-
removeDatasourceConfiguration
public static void removeDatasourceConfiguration(DataSourceConfiguration dsc) throws IllegalArgumentException, SecurityException Removes the datasource configuration. The method will take care of removing the datasource configuration from the scope it is currently stored in.- Parameters:
dsc
- the datasource configuration to remove- Throws:
IllegalArgumentException
- If the supplied configuration is nullSecurityException
- if you have no write rights to the preferences scope.null
or empty or if the givenpreferenceScope
parameter is not equal to a valid parameter value listed below.- Since:
- 20.0
- See Also:
-
forceImportDataSourceConfigurations
public static void forceImportDataSourceConfigurations(int preferenceScope, File fileToImport) throws ReportException, 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.APPLICATION
- 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.SecurityException
- if there is no write access to the given Java Preferences- Since:
- 10.0
- See Also:
-
importDataSourceConfigurations
public static void importDataSourceConfigurations(int preferenceScope, 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.APPLICATION
- 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.- Since:
- 7.5
- See Also:
-
importDataSourceConfigurations
public static void importDataSourceConfigurations(int preferenceScope, File importFile, boolean ignoreIfExist) throws ReportException, SecurityException Imports one or more data source configurations from an XML file.- Parameters:
preferenceScope
- Possible values:- DataSourceConfigurationManager.SYSTEM_PREFERENCES
- DataSourceConfigurationManager.USER_PREFERENCES
- DataSourceConfigurationManager.APPLICATION
- DataSourceConfigurationManager.TEMPORARY_PREFERENCES
- DataSourceConfigurationManager.USER_SESSION
importFile
- representation of the XML file which contains the data source configurations for importignoreIfExist
- 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.SecurityException
- if there is no write access to the given Java Preferences- Since:
- 7.5
- See Also:
-
importDataSourceConfigurations
public static DataSourceConfiguration[] importDataSourceConfigurations(int preferenceScope, InputStream importStream) 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
importStream
- input stream of the XML content which contains the data source configurations for import- Returns:
- returns the list of configurations found in the import file
- Throws:
ReportException
- If the file can't imported.- Since:
- 7.5
- See Also:
-
importDataSourceConfigurations
public static DataSourceConfiguration[] importDataSourceConfigurations(int preferenceScope, InputStream importStream, boolean ignoreIfExist) throws ReportException, 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
importStream
- input stream of the XML content which contains the data source configurations for importignoreIfExist
- 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.- Returns:
- returns the list of configurations found by the import
- Throws:
ReportException
- If the file can't import.SecurityException
- if there is no write access to the given Java Preferences- Since:
- 20.0
- See Also:
-
exportDataSourceConfigurations
public static void exportDataSourceConfigurations(DataSourceConfiguration[] configs, File exportFile) throws ReportException Exports data source configurations to the given file in an XML format.- Parameters:
configs
- Array which contains theDataSourceConfiguration
s for exportexportFile
- representation of the target XML file- Throws:
ReportException
- if any error occur on saving- Since:
- 7.5
- See Also:
-
exportDataSourceConfigurations
public static void exportDataSourceConfigurations(DataSourceConfiguration[] configs, OutputStream stream) throws ReportException Exports data source configurations to the given file in an XML format.- Parameters:
configs
- Array which contains theDataSourceConfiguration
s for exportstream
- the target XML output- Throws:
ReportException
- if any error occur on saving- Since:
- 20.0
- See Also:
-
addDataSourceConfigurationListener
Add here aDataSourceConfigurationChangeListener
to get informed when aDataSourceConfiguration
was edited.- Parameters:
dscl
- theDataSourceConfigurationChangeListener
that get informed about changes ofDataSourceConfiguration
objects.- Since:
- 7.5
-
getDataSourceConfigurationListeners
Returns the list of listeners. This can be used to fire own events to all registered listeners.- Returns:
- an array of DataSourceConfigurationChangeListener
- Since:
- 8.0
-
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.- Since:
- 7.5
-
getDataSource
Returns theDataSourceConfiguration
specified by the given name. The search order is session, temporary, application, user, system- Parameters:
name
- the name identifies the data source.- Returns:
DataSourceConfiguration
- the specified data source if exists ORnull
- Since:
- 20.0
-
getDataSource
Returns theDataSourceConfiguration
specified by the given uid. This method does not search in the session scope.- Parameters:
uid
- the unique id of the data source.- Returns:
DataSourceConfiguration
- the specified data source if exists ORnull
- Since:
- 20.0
-