Class SqlDataSourceFactory
java.lang.Object
org.ametys.plugins.externaldata.data.sql.SqlDataSourceFactory
- All Implemented Interfaces:
DataSourceFactory<SqlQuery,,SqlQueryResult> PluginAware,Serviceable
public class SqlDataSourceFactory
extends Object
implements DataSourceFactory<SqlQuery,SqlQueryResult>, PluginAware, Serviceable
SQL Data Source & Query Factory.
Must provide these additional configuration information for the Data Source :
- "driver" : JDBC driver.
- "url" : JDBC url.
- "user" : JDBC user.
- "password" : JDBC password.
Must provide these additional configuration information for the Query :
- "queryString" : the SQL query as a String, which can contain parameters in the form ${parameterName}.
-
Field Summary
FieldsModifier and TypeFieldDescriptionQuery configuration parameters.static final StringQuery string configuration parameter. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildQuery(String id, String type, String name, String description, Query.ResultType resultType, String dataSourceId, Map<String, String> additionalConfiguration) Build a query with the specified information.Execute the query with the specified parameter values.Execute the query with the specified parameter values.Get the types that the factory can build.The configuration parameters needed to build a Query of the specified type.voidservice(ServiceManager manager) voidsetPluginInfo(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.
-
Field Details
-
QUERY_CONFIGURATION_QUERYSTRING
Query string configuration parameter.- See Also:
-
QUERY_CONFIGURATION_PARAMETERS
Query configuration parameters.
-
-
Constructor Details
-
SqlDataSourceFactory
public SqlDataSourceFactory()
-
-
Method Details
-
setPluginInfo
Description copied from interface:PluginAwareSets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfoin interfacePluginAware- Parameters:
pluginName- Unique identifier for the plugin hosting the extensionfeatureName- Unique feature identifier (unique for a given pluginName)id- Unique identifier of this component
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getHandledTypes
Description copied from interface:DataSourceFactoryGet the types that the factory can build.- Specified by:
getHandledTypesin interfaceDataSourceFactory<SqlQuery,SqlQueryResult> - Returns:
- the handled types as a Collection.
-
getQueryConfigurationParameters
Description copied from interface:DataSourceFactoryThe configuration parameters needed to build a Query of the specified type.- Specified by:
getQueryConfigurationParametersin interfaceDataSourceFactory<SqlQuery,SqlQueryResult> - Parameters:
type- the type of the Query.- Returns:
- the configuration parameters as a Collection.
-
buildQuery
public SqlQuery buildQuery(String id, String type, String name, String description, Query.ResultType resultType, String dataSourceId, Map<String, String> additionalConfiguration) throws DataInclusionExceptionDescription copied from interface:DataSourceFactoryBuild a query with the specified information.- Specified by:
buildQueryin interfaceDataSourceFactory<SqlQuery,SqlQueryResult> - Parameters:
id- the Query ID.type- the Query type.name- the Query name.description- the Query description.resultType- the Query result type (single/multiple).dataSourceId- the id of data sourceadditionalConfiguration- additional query configuration parameter values as a Map<parameterName, parameterValue>.- Returns:
- the query.
- Throws:
DataInclusionException- if an error occurs trying to create the Query.
-
execute
public SqlQueryResult execute(SqlQuery query, Map<String, String> parameterValues) throws DataInclusionExceptionDescription copied from interface:DataSourceFactoryExecute the query with the specified parameter values.- Specified by:
executein interfaceDataSourceFactory<SqlQuery,SqlQueryResult> - Parameters:
query- The queryparameterValues- the parameter values as a Map (name -> value).- Returns:
- the query result.
- Throws:
DataInclusionException- if an error occurs while executing the query
-
execute
public SqlQueryResult execute(SqlQuery sqlQuery, Map<String, String> parameterValues, int offset, int limit) throws DataInclusionExceptionDescription copied from interface:DataSourceFactoryExecute the query with the specified parameter values.- Specified by:
executein interfaceDataSourceFactory<SqlQuery,SqlQueryResult> - Parameters:
sqlQuery- The queryparameterValues- the parameter values as a Map (name -> value).offset- The start index of searchlimit- The max number of result to return- Returns:
- the query result.
- Throws:
DataInclusionException- if an error occurs while executing the query
-