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 private String_idprivate SQLDatabaseTypeExtensionPoint_sqlDatabaseTypeExtensionPointprivate SQLDataSourceManager_sqlDataSourceManagerstatic List<String>QUERY_CONFIGURATION_PARAMETERSQuery configuration parameters.static StringQUERY_CONFIGURATION_QUERYSTRINGQuery string configuration parameter.
-
Constructor Summary
Constructors Constructor Description SqlDataSourceFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SqlQuerybuildQuery(String id, String type, String name, String description, Query.ResultType resultType, String dataSourceId, Map<String,String> additionalConfiguration)Build a query with the specified information.SqlQueryResultexecute(SqlQuery query, Map<String,String> parameterValues)Execute the query with the specified parameter values.SqlQueryResultexecute(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.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 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.
-
_sqlDatabaseTypeExtensionPoint
private SQLDatabaseTypeExtensionPoint _sqlDatabaseTypeExtensionPoint
-
_sqlDataSourceManager
private SQLDataSourceManager _sqlDataSourceManager
-
-
Constructor Detail
-
SqlDataSourceFactory
public SqlDataSourceFactory()
-
-
Method Detail
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
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
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getHandledTypes
public Collection<DataSourceClientInteraction.DataSourceType> 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
public Collection<String> getQueryConfigurationParameters(String type)
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 DataInclusionException
Description 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 DataInclusionException
Description 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 DataInclusionException
Description 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
-
-