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
Fields Modifier and Type Field Description static List<String>
QUERY_CONFIGURATION_PARAMETERS
Query configuration parameters.static String
QUERY_CONFIGURATION_QUERYSTRING
Query string configuration parameter.
-
Constructor Summary
Constructors Constructor Description SqlDataSourceFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SqlQuery
buildQuery(String id, String type, String name, String description, Query.ResultType resultType, String dataSourceId, Map<String,String> additionalConfiguration)
Build a query with the specified information.SqlQueryResult
execute(SqlQuery query, Map<String,String> parameterValues)
Execute the query with the specified parameter values.SqlQueryResult
execute(SqlQuery sqlQuery, Map<String,String> parameterValues, int offset, int limit)
Execute the query with the specified parameter values.Collection<DataSourceClientInteraction.DataSourceType>
getHandledTypes()
Get the types that the factory can build.Collection<String>
getQueryConfigurationParameters(String type)
The configuration parameters needed to build a Query of the specified type.void
service(ServiceManager manager)
void
setPluginInfo(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 Detail
-
QUERY_CONFIGURATION_QUERYSTRING
public static final String QUERY_CONFIGURATION_QUERYSTRING
Query string configuration parameter.- See Also:
- Constant Field Values
-
QUERY_CONFIGURATION_PARAMETERS
public static final List<String> QUERY_CONFIGURATION_PARAMETERS
Query configuration parameters.
-
-
Constructor Detail
-
SqlDataSourceFactory
public SqlDataSourceFactory()
-
-
Method Detail
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAware
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.- Specified by:
setPluginInfo
in 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
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getHandledTypes
public Collection<DataSourceClientInteraction.DataSourceType> getHandledTypes()
Description copied from interface:DataSourceFactory
Get the types that the factory can build.- Specified by:
getHandledTypes
in interfaceDataSourceFactory<SqlQuery,SqlQueryResult>
- Returns:
- the handled types as a Collection.
-
getQueryConfigurationParameters
public Collection<String> getQueryConfigurationParameters(String type)
Description copied from interface:DataSourceFactory
The configuration parameters needed to build a Query of the specified type.- Specified by:
getQueryConfigurationParameters
in 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 DataInclusionException
Description copied from interface:DataSourceFactory
Build a query with the specified information.- Specified by:
buildQuery
in 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 DataInclusionException
Description copied from interface:DataSourceFactory
Execute the query with the specified parameter values.- Specified by:
execute
in 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 DataInclusionException
Description copied from interface:DataSourceFactory
Execute the query with the specified parameter values.- Specified by:
execute
in 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
-
-