Package org.opencms.search.fields
Class CmsMacroSearchFieldMapping
- java.lang.Object
-
- org.opencms.search.fields.CmsMacroSearchFieldMapping
-
- All Implemented Interfaces:
java.io.Serializable
,I_CmsSearchFieldMapping
public class CmsMacroSearchFieldMapping extends java.lang.Object implements I_CmsSearchFieldMapping
Field mapping to resolve macros as for gallery names. The main purpose is to use stringtemplates for special mappings to Solr fields. For this use case, define a parameter (viaxsd:annotation/xsd:appinfo/parameters/param
and use a stringtemplate as value. In the solr mapping, you just place%(stringtemplate:paramName)
. Example (there is some element "Type" and in the parameters section of the schema, there's a param "eventKind"):<searchsetting element="Type"> <solrfield targetfield="event-kind" sourcefield="*_s"> <mapping type="dynamic" class="org.opencms.search.fields.CmsSchemaParameterSearchFieldMapping">%(stringtemplate:eventKind)</mapping> </solrfield> </searchsetting>
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.commons.logging.Log
LOG
Logger for the class
-
Constructor Summary
Constructors Constructor Description CmsMacroSearchFieldMapping()
Public constructor for a new search field mapping.CmsMacroSearchFieldMapping(CmsSearchFieldMappingType type, java.lang.String param)
Public constructor for a new search field mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getDefaultValue()
Returns the default value used for this field mapping in case no content is available.java.lang.String
getParam()
Returns the mapping parameter.java.lang.String
getStringValue(CmsObject cms, CmsResource res, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
Returns the String value extracted form the provided data according to the rules of this mapping type.CmsSearchFieldMappingType
getType()
Returns the mapping type.void
setDefaultValue(java.lang.String defaultValue)
Sets the default value for this field mapping in case no content is available.void
setLocale(java.util.Locale locale)
Sets the locale, the mapping can examine when extracting the content.void
setParam(java.lang.String param)
Sets the mapping parameter.void
setType(java.lang.String type)
Sets the mapping type as a String.void
setType(CmsSearchFieldMappingType type)
Sets the mapping type.
-
-
-
Field Detail
-
LOG
protected static final org.apache.commons.logging.Log LOG
Logger for the class
-
-
Constructor Detail
-
CmsMacroSearchFieldMapping
public CmsMacroSearchFieldMapping()
Public constructor for a new search field mapping.
-
CmsMacroSearchFieldMapping
public CmsMacroSearchFieldMapping(CmsSearchFieldMappingType type, java.lang.String param)
Public constructor for a new search field mapping.- Parameters:
type
- the type to use, seesetType(CmsSearchFieldMappingType)
param
- the mapping parameter, seesetParam(String)
-
-
Method Detail
-
getDefaultValue
public java.lang.String getDefaultValue()
Description copied from interface:I_CmsSearchFieldMapping
Returns the default value used for this field mapping in case no content is available.- Specified by:
getDefaultValue
in interfaceI_CmsSearchFieldMapping
- Returns:
- the default value used for this field mapping in case no content is available
- See Also:
I_CmsSearchFieldMapping.getDefaultValue()
-
getParam
public java.lang.String getParam()
Description copied from interface:I_CmsSearchFieldMapping
Returns the mapping parameter.The parameter is used depending on the implementation of the rules of the selected
CmsSearchFieldMappingType
.- Specified by:
getParam
in interfaceI_CmsSearchFieldMapping
- Returns:
- the mapping parameter
- See Also:
I_CmsSearchFieldMapping.getParam()
-
getStringValue
public java.lang.String getStringValue(CmsObject cms, CmsResource res, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
Description copied from interface:I_CmsSearchFieldMapping
Returns the String value extracted form the provided data according to the rules of this mapping type.- Specified by:
getStringValue
in interfaceI_CmsSearchFieldMapping
- Parameters:
cms
- the OpenCms context used for building the search indexres
- the resource that is indexedextractionResult
- the plain text extraction result from the resourceproperties
- the list of all properties directly attached to the resource (not searched)propertiesSearched
- the list of all searched properties of the resource- Returns:
- the String value extracted form the provided data according to the rules of this mapping type
- See Also:
I_CmsSearchFieldMapping.getStringValue(org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.extractors.I_CmsExtractionResult, java.util.List, java.util.List)
-
getType
public CmsSearchFieldMappingType getType()
Description copied from interface:I_CmsSearchFieldMapping
Returns the mapping type.- Specified by:
getType
in interfaceI_CmsSearchFieldMapping
- Returns:
- the mapping type
- See Also:
I_CmsSearchFieldMapping.getType()
-
setDefaultValue
public void setDefaultValue(java.lang.String defaultValue)
Description copied from interface:I_CmsSearchFieldMapping
Sets the default value for this field mapping in case no content is available.- Specified by:
setDefaultValue
in interfaceI_CmsSearchFieldMapping
- Parameters:
defaultValue
- the default value to set- See Also:
I_CmsSearchFieldMapping.setDefaultValue(java.lang.String)
-
setLocale
public void setLocale(java.util.Locale locale)
Description copied from interface:I_CmsSearchFieldMapping
Sets the locale, the mapping can examine when extracting the content. NOTE: This method is called byCmsDefaultXmlContentHandler
when dynamic search field mappings are created. Overwrite this default implementation if you need to map locale specific in your dynamic mapping.- Specified by:
setLocale
in interfaceI_CmsSearchFieldMapping
- Parameters:
locale
- the locale of the index field that is filled by the mapping.- See Also:
I_CmsSearchFieldMapping.setLocale(java.util.Locale)
-
setParam
public void setParam(java.lang.String param)
Description copied from interface:I_CmsSearchFieldMapping
Sets the mapping parameter.The parameter is used depending on the implementation of the rules of the selected
CmsSearchFieldMappingType
.- Specified by:
setParam
in interfaceI_CmsSearchFieldMapping
- Parameters:
param
- the parameter to set- See Also:
I_CmsSearchFieldMapping.setParam(java.lang.String)
-
setType
public void setType(CmsSearchFieldMappingType type)
Description copied from interface:I_CmsSearchFieldMapping
Sets the mapping type.- Specified by:
setType
in interfaceI_CmsSearchFieldMapping
- Parameters:
type
- the type to set- See Also:
I_CmsSearchFieldMapping.setType(org.opencms.search.fields.CmsSearchFieldMappingType)
-
setType
public void setType(java.lang.String type)
Description copied from interface:I_CmsSearchFieldMapping
Sets the mapping type as a String.- Specified by:
setType
in interfaceI_CmsSearchFieldMapping
- Parameters:
type
- the name of the type to set- See Also:
I_CmsSearchFieldMapping.setType(java.lang.String)
-
-