Class AbstractSolrExtractionComponent
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.extraction.component.AbstractExtractionComponent
-
- org.ametys.plugins.extraction.component.AbstractSolrExtractionComponent
-
- All Implemented Interfaces:
ExtractionComponent
,Configurable
,LogEnabled
,Serviceable
- Direct Known Subclasses:
AbstractGroupExtractionComponent
,MappingQueryExtractionComponent
public abstract class AbstractSolrExtractionComponent extends AbstractExtractionComponent
This class represents an extraction component with a solr query
-
-
Field Summary
Fields Modifier and Type Field Description protected List<ExtractionClause>
_clauses
The list of clausesprivate ContentHelper
_contentHelper
private ContentSearcherFactory
_contentSearcherFactory
protected Set<String>
_contentTypes
Content types concerned by the solr searchprotected GetQueryFromJSONHelper
_getQueryFromJSONHelper
Helper to resolve referenced query infosprotected JSONUtils
_jsonUtils
Util class to manipulate JSON Stringprivate QueryBuilder
_queryBuilder
protected String
_queryReferenceId
Reference id of a recorded queryprivate AmetysObjectResolver
_resolver
private SystemPropertyExtensionPoint
_systemPropertyExtensionPoint
private static String
EXTRACT_JOIN_VARIABLES_REGEX
Regex used to extract variables from a join expression: \$\{(\.\.(?:\/\.\.)*(?:\/[^\/}]+)?)\} a variable is inside a ${} variable starts with ..-
Fields inherited from class org.ametys.plugins.extraction.component.AbstractExtractionComponent
_contentTypeExtensionPoint, _contentTypesHelper, _subComponents, _tagName, _thesaurusDAO, EXTRACTION_ITEM_PATH_SEPARATOR, JOIN_HIERARCHY_ELEMENT, JOIN_HIERARCHY_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description AbstractSolrExtractionComponent()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void
_computeClausesInfos(ExtractionExecutionContext context)
(package private) List<ExtractionClauseGroup>
_extractGroupExpressionsFromClause(String expression)
(package private) List<String>
_extractVariableFromClauseExpression(String expression)
protected String
_getAttributeTypeId(String fieldPath, Collection<String> contentTypeIds)
Retrieves the field path's attribute type identifier from content types(package private) List<String>
_getClauseQueries(ExtractionExecutionContext context)
private Object
_getContentValue(Content content, String fieldPath, Locale defaultLocale)
private Collection<Object>
_getContentValuesFromVariable(Content content, String fieldPath, String attributeTypeId, boolean isAutoposting, Locale defaultLocale)
private ExtractionExecutionContextHierarchyElement
_getCurrentContextElementFromVariable(String variable, List<ExtractionExecutionContextHierarchyElement> context)
private String
_getValueAsString(Object value, String attributeTypeId, String fieldPath)
private Collection<Object>
_getValuesFromVariable(String fieldPath, String attributeTypeId, ExtractionExecutionContextHierarchyElement contextHierarchyElement, Locale defaultLocale)
private boolean
_hasVariablesOutsideGroups(String clauseExpression, Collection<String> groupExpressions)
private String
_resolveExpression(String expression, Map<String,String> queryVariables)
void
addClauses(String... expressions)
Add clauses to the component.void
addContentTypes(String... contentTypes)
Add content types to componentprotected void
computeReferencedQueryInfos(String refQueryContent)
Manages the stored query referenced by the componentvoid
configure(Configuration configuration)
void
executeComponent(ContentHandler contentHandler, ExtractionExecutionContext context)
Execute the extraction of the componentList<ExtractionClause>
getClauses()
Retrieves the component clausesMap<String,Object>
getComponentDetailsForTree()
Retrieves the details of the component for treeprotected Iterable<Content>
getContents(ExtractionExecutionContext context)
Gets the content results from Solrprotected ContentSearcherFactory.SimpleContentSearcher
getContentSearcher()
Retrieves the content searcher to use for solr searchSet<String>
getContentTypes()
Retrieves the list of content types defined for this componentString
getQueryReferenceId()
Retrieves the id of the referenced queryvoid
prepareComponentExecution(ExtractionExecutionContext context)
Prepare the execution of the componentprotected abstract void
processContents(Iterable<Content> contents, ContentHandler contentHandler, ExtractionExecutionContext context)
Process result contents to format the result documentvoid
service(ServiceManager serviceManager)
void
setQueryReferenceId(String queryReferenceId)
Sets the id of the referenced query-
Methods inherited from class org.ametys.plugins.extraction.component.AbstractExtractionComponent
addSubComponent, execute, executeSubComponents, getDefaultTagName, getLogsPrefix, getSubComponents, getTagName, setTagName
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
EXTRACT_JOIN_VARIABLES_REGEX
private static final String EXTRACT_JOIN_VARIABLES_REGEX
Regex used to extract variables from a join expression: \$\{(\.\.(?:\/\.\.)*(?:\/[^\/}]+)?)\} a variable is inside a ${} variable starts with .. (to get the direct parent), has several /.. (to get parent of parent of (...)) and can have a /metadataName (to specify the metadata to join on)- See Also:
- Constant Field Values
-
_contentTypes
protected Set<String> _contentTypes
Content types concerned by the solr search
-
_queryReferenceId
protected String _queryReferenceId
Reference id of a recorded query
-
_clauses
protected List<ExtractionClause> _clauses
The list of clauses
-
_getQueryFromJSONHelper
protected GetQueryFromJSONHelper _getQueryFromJSONHelper
Helper to resolve referenced query infos
-
_jsonUtils
protected JSONUtils _jsonUtils
Util class to manipulate JSON String
-
_resolver
private AmetysObjectResolver _resolver
-
_systemPropertyExtensionPoint
private SystemPropertyExtensionPoint _systemPropertyExtensionPoint
-
_contentHelper
private ContentHelper _contentHelper
-
_contentSearcherFactory
private ContentSearcherFactory _contentSearcherFactory
-
_queryBuilder
private QueryBuilder _queryBuilder
-
-
Constructor Detail
-
AbstractSolrExtractionComponent
public AbstractSolrExtractionComponent()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractExtractionComponent
- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classAbstractExtractionComponent
- Throws:
ConfigurationException
-
prepareComponentExecution
public void prepareComponentExecution(ExtractionExecutionContext context) throws Exception
Description copied from interface:ExtractionComponent
Prepare the execution of the component- Specified by:
prepareComponentExecution
in interfaceExtractionComponent
- Overrides:
prepareComponentExecution
in classAbstractExtractionComponent
- Parameters:
context
- context of the extraction component- Throws:
Exception
- if an error occurs
-
computeReferencedQueryInfos
protected void computeReferencedQueryInfos(String refQueryContent) throws QuerySyntaxException
Manages the stored query referenced by the component- Parameters:
refQueryContent
- referenced query content- Throws:
QuerySyntaxException
- if there is a syntax error in the referenced query
-
_computeClausesInfos
private void _computeClausesInfos(ExtractionExecutionContext context)
-
_resolveExpression
private String _resolveExpression(String expression, Map<String,String> queryVariables)
-
_hasVariablesOutsideGroups
private boolean _hasVariablesOutsideGroups(String clauseExpression, Collection<String> groupExpressions)
-
_extractGroupExpressionsFromClause
List<ExtractionClauseGroup> _extractGroupExpressionsFromClause(String expression)
-
_extractVariableFromClauseExpression
List<String> _extractVariableFromClauseExpression(String expression)
-
executeComponent
public void executeComponent(ContentHandler contentHandler, ExtractionExecutionContext context) throws Exception
Description copied from class:AbstractExtractionComponent
Execute the extraction of the component- Specified by:
executeComponent
in classAbstractExtractionComponent
- Parameters:
contentHandler
- result documentcontext
- context of the extraction component- Throws:
Exception
- if an error occurs
-
_getClauseQueries
List<String> _getClauseQueries(ExtractionExecutionContext context)
-
_getCurrentContextElementFromVariable
private ExtractionExecutionContextHierarchyElement _getCurrentContextElementFromVariable(String variable, List<ExtractionExecutionContextHierarchyElement> context)
-
_getAttributeTypeId
protected String _getAttributeTypeId(String fieldPath, Collection<String> contentTypeIds)
Retrieves the field path's attribute type identifier from content types- Parameters:
fieldPath
- the field pathcontentTypeIds
- the content types identifiers- Returns:
- the attribute type identifier
-
_getValuesFromVariable
private Collection<Object> _getValuesFromVariable(String fieldPath, String attributeTypeId, ExtractionExecutionContextHierarchyElement contextHierarchyElement, Locale defaultLocale)
-
_getContentValuesFromVariable
private Collection<Object> _getContentValuesFromVariable(Content content, String fieldPath, String attributeTypeId, boolean isAutoposting, Locale defaultLocale)
-
_getContentValue
private Object _getContentValue(Content content, String fieldPath, Locale defaultLocale)
-
_getValueAsString
private String _getValueAsString(Object value, String attributeTypeId, String fieldPath)
-
getContentSearcher
protected ContentSearcherFactory.SimpleContentSearcher getContentSearcher()
Retrieves the content searcher to use for solr search- Returns:
- the content searcher
-
getContents
protected Iterable<Content> getContents(ExtractionExecutionContext context) throws Exception
Gets the content results from Solr- Parameters:
context
- component execution context- Returns:
- the content results from Solr
- Throws:
Exception
- if an error occurs
-
processContents
protected abstract void processContents(Iterable<Content> contents, ContentHandler contentHandler, ExtractionExecutionContext context) throws Exception
Process result contents to format the result document- Parameters:
contents
- search resultscontentHandler
- result documentcontext
- component execution context- Throws:
Exception
- if an error occurs
-
getComponentDetailsForTree
public Map<String,Object> getComponentDetailsForTree()
Description copied from interface:ExtractionComponent
Retrieves the details of the component for tree- Specified by:
getComponentDetailsForTree
in interfaceExtractionComponent
- Overrides:
getComponentDetailsForTree
in classAbstractExtractionComponent
- Returns:
- a
Map
containing component details
-
getContentTypes
public Set<String> getContentTypes()
Description copied from interface:ExtractionComponent
Retrieves the list of content types defined for this component- Returns:
- a list of content types id
-
addContentTypes
public void addContentTypes(String... contentTypes)
Add content types to component- Parameters:
contentTypes
- Array of content types to add
-
getQueryReferenceId
public String getQueryReferenceId()
Retrieves the id of the referenced query- Returns:
- the id of the referenced query
-
setQueryReferenceId
public void setQueryReferenceId(String queryReferenceId)
Sets the id of the referenced query- Parameters:
queryReferenceId
- The id of the referenced query to set
-
getClauses
public List<ExtractionClause> getClauses()
Retrieves the component clauses- Returns:
- the component clauses
-
addClauses
public void addClauses(String... expressions)
Add clauses to the component. Do not manage clauses' groups- Parameters:
expressions
- Array clauses expressions to add
-
-