public class JcrQueryDao extends AbstractLogEnabled implements QueryDao, Serviceable, Component
Modifier and Type | Field and Description |
---|---|
protected CurrentUserProvider |
_currentUserProvider
The current user provider
|
protected DataSourceFactoryExtensionPoint |
_dataSourceFactoryEP
The Data Source factory extension point.
|
protected ObservationManager |
_observationManager
The observation manager
|
protected Repository |
_repository
The JCR repository.
|
protected SiteManager |
_siteManager
The Site manager.
|
static String |
DATASOURCES_NODE
Data sources node name.
|
static String |
PLUGIN_NODE
Plugin root node name.
|
static String |
PLUGINS_NODE
Plugins root node name.
|
static String |
PROPERTY_CONF_PREFIX
Configuration properties prefix.
|
static String |
PROPERTY_DATASOURCE
"Type" property name.
|
static String |
PROPERTY_DESCRIPTION
"Description" property name.
|
static String |
PROPERTY_NAME
"Name" property name.
|
static String |
PROPERTY_TYPE
"Type" property name.
|
static String |
QUERIES_NODE
Queries node name.
|
static String |
QUERY_PROPERTY_PARAMETERS
Query "parameters" property name.
|
static String |
QUERY_PROPERTY_QUERYSTRING
Query "query string" property name.
|
static String |
QUERY_PROPERTY_RESULTTYPE
Query "resultType" property name.
|
static String |
ROOT_REPO
JCR relative path to root node.
|
Constructor and Description |
---|
JcrQueryDao() |
Modifier and Type | Method and Description |
---|---|
protected Query |
_extractQuery(Node node)
Create a data source from a node.
|
protected void |
_fillQueryNode(Query query,
Node node)
Store the query properties into the JCR node.
|
protected Map<String,String> |
_getAdditionalConf(Node node)
Get additional configuration from properties.
|
protected Collection<String> |
_getMultipleProperty(Node node,
String propertyName)
Get the values of a string array property.
|
protected String |
_getNotExistingNodeName(Node container,
String baseName)
Get a name for a node which doesn't already exist in this node.
|
protected Node |
_getPluginNode(String siteName)
Get the plugin root node in a site storage space.
|
protected Node |
_getQueriesNode(String siteName)
Get the queries root node.
|
protected Query.ResultType |
_getResultType(Node node,
Query.ResultType defaultValue)
Get a single property value.
|
protected Query.ResultType |
_getResultType(String value,
Query.ResultType defaultValue)
Get a a result type
|
protected String |
_getSingleProperty(Node node,
String propertyName,
String defaultValue)
Get a single property value.
|
private boolean |
_matchQuery(Query query,
String dataSourceId,
DataSourceClientInteraction.DataSourceType dsType,
Query.ResultType resultType) |
Map<String,String> |
addQuery(String siteName,
Map<String,Object> parameters)
Adds a query.
|
String |
addQuery(String siteName,
Query query)
Add a query and set its id.
|
Map<String,String> |
deleteQuery(String siteName,
String id)
Deletes a query.
|
Map<String,Query> |
getDataSourceQueries(String siteName,
String dataSourceId)
Get all the queries of a site.
|
Map<String,Query> |
getDataSourceQueries(String siteName,
String dataSourceId,
DataSourceClientInteraction.DataSourceType dataSourceType,
Query.ResultType resultType)
Get all the queries of a site of a specific result type
|
Map<String,Query> |
getDataSourceQueries(String siteName,
String dataSourceId,
Query.ResultType resultType)
Get all the queries of a site of a specific result type
|
Map<String,Query> |
getQueries(String siteName)
Get all the queries of a site.
|
Map<String,Query> |
getQueries(String siteName,
DataSourceClientInteraction.DataSourceType type)
Get all the queries of a site.
|
Query |
getQuery(String siteName,
String id)
Get a query from its id.
|
Map<String,Object> |
getQueryProperties(String id,
String siteName)
Get the query properties.
|
void |
removeQuery(String siteName,
String id)
Remove a query.
|
void |
service(ServiceManager serviceManager) |
Map<String,String> |
updateQuery(String siteName,
Map<String,Object> parameters)
Updates a query.
|
void |
updateQuery(String siteName,
Query query)
Update a query.
|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
public static final String ROOT_REPO
public static final String PLUGINS_NODE
public static final String PLUGIN_NODE
public static final String DATASOURCES_NODE
public static final String QUERIES_NODE
public static final String PROPERTY_NAME
public static final String PROPERTY_DESCRIPTION
public static final String PROPERTY_TYPE
public static final String PROPERTY_DATASOURCE
public static final String PROPERTY_CONF_PREFIX
public static final String QUERY_PROPERTY_QUERYSTRING
public static final String QUERY_PROPERTY_PARAMETERS
public static final String QUERY_PROPERTY_RESULTTYPE
protected DataSourceFactoryExtensionPoint _dataSourceFactoryEP
protected Repository _repository
protected SiteManager _siteManager
protected CurrentUserProvider _currentUserProvider
protected ObservationManager _observationManager
public JcrQueryDao()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
ServiceException
public Map<String,Query> getQueries(String siteName) throws DataInclusionException
QueryDao
getQueries
in interface QueryDao
siteName
- the site name.DataInclusionException
- if an error occurs while manipulating the data sourcespublic Map<String,Query> getQueries(String siteName, DataSourceClientInteraction.DataSourceType type) throws DataInclusionException
QueryDao
getQueries
in interface QueryDao
siteName
- the site name.type
- the query typeDataInclusionException
- if an error occurs while manipulating the data sourcespublic Map<String,Query> getDataSourceQueries(String siteName, String dataSourceId) throws DataInclusionException
QueryDao
getDataSourceQueries
in interface QueryDao
siteName
- the site name.dataSourceId
- the id of the data sourceDataInclusionException
- if an error occurs while manipulating the data sourcespublic Map<String,Query> getDataSourceQueries(String siteName, String dataSourceId, Query.ResultType resultType) throws DataInclusionException
QueryDao
getDataSourceQueries
in interface QueryDao
siteName
- the site name.dataSourceId
- the id of the data sourceresultType
- Filter on result typeDataInclusionException
- if an error occurs while manipulating the data sourcespublic Map<String,Query> getDataSourceQueries(String siteName, String dataSourceId, DataSourceClientInteraction.DataSourceType dataSourceType, Query.ResultType resultType) throws DataInclusionException
QueryDao
getDataSourceQueries
in interface QueryDao
siteName
- the site name.dataSourceId
- the id of the data sourcedataSourceType
- the query typeresultType
- Filter on result typeDataInclusionException
- if an error occurs while manipulating the data sourcesprivate boolean _matchQuery(Query query, String dataSourceId, DataSourceClientInteraction.DataSourceType dsType, Query.ResultType resultType)
public Query getQuery(String siteName, String id) throws DataInclusionException
QueryDao
getQuery
in interface QueryDao
siteName
- the site name.id
- the query id.DataInclusionException
- if an error occurs while manipulating the data sourcespublic Map<String,Object> getQueryProperties(String id, String siteName) throws DataInclusionException
QueryDao
getQueryProperties
in interface QueryDao
id
- The query idsiteName
- The site nameDataInclusionException
- if an error occurs while manipulating the data sourcespublic Map<String,String> addQuery(String siteName, Map<String,Object> parameters) throws Exception
QueryDao
public String addQuery(String siteName, Query query) throws DataInclusionException
QueryDao
addQuery
in interface QueryDao
siteName
- the site namequery
- the query to add. The id member doesn't need to be specified.DataInclusionException
- if an error occurs while manipulating the data sourcespublic Map<String,String> updateQuery(String siteName, Map<String,Object> parameters) throws Exception
QueryDao
updateQuery
in interface QueryDao
siteName
- The site nameparameters
- The params needed to update the queryException
- if an error occurs when updating the querypublic void updateQuery(String siteName, Query query) throws DataInclusionException
QueryDao
updateQuery
in interface QueryDao
siteName
- the site namequery
- the query to update.DataInclusionException
- if an error occurs while manipulating the data sourcespublic Map<String,String> deleteQuery(String siteName, String id) throws Exception
QueryDao
deleteQuery
in interface QueryDao
siteName
- the site nameid
- The id of the query to deleteException
- if an error occurs when deleting the querypublic void removeQuery(String siteName, String id) throws DataInclusionException
QueryDao
removeQuery
in interface QueryDao
siteName
- the site nameid
- the query id.DataInclusionException
- if an error occurs while manipulating the data sourcesprotected Query _extractQuery(Node node) throws RepositoryException, DataInclusionException
node
- the data source node.RepositoryException
- if an error occurs when exploring the repositoryDataInclusionException
- if an error occurs while manipulating the data sourcesprotected String _getSingleProperty(Node node, String propertyName, String defaultValue) throws RepositoryException
node
- the JCR node.propertyName
- the name of the property to get.defaultValue
- the default value if the property does not exist.RepositoryException
- if a repository error occurs.protected Query.ResultType _getResultType(String value, Query.ResultType defaultValue) throws RepositoryException
value
- the valuedefaultValue
- the default result typeRepositoryException
- if an error occurs when exploring the repositoryprotected Query.ResultType _getResultType(Node node, Query.ResultType defaultValue) throws RepositoryException
node
- the nodedefaultValue
- the default result typeRepositoryException
- if an error occurs when exploring the repositoryprotected Collection<String> _getMultipleProperty(Node node, String propertyName) throws RepositoryException
node
- the node.propertyName
- the name of the property to get.RepositoryException
- if a repository error occurs.protected Map<String,String> _getAdditionalConf(Node node) throws RepositoryException
node
- the nodeRepositoryException
- if a repository error occurs.protected void _fillQueryNode(Query query, Node node) throws RepositoryException
query
- the querysnode
- the query nodeRepositoryException
- if a repository error occurs.protected String _getNotExistingNodeName(Node container, String baseName) throws RepositoryException
container
- the container node.baseName
- the base wanted node name.RepositoryException
- if a repository error occurs.protected Node _getPluginNode(String siteName) throws RepositoryException
siteName
- the site name.RepositoryException
- if a repository error occurs.protected Node _getQueriesNode(String siteName) throws RepositoryException
siteName
- the name of the siteRepositoryException
- if a repository error occurs.