public class ContentSearchHelper extends AbstractLogEnabled implements Component, Serviceable, Contextualizable
Modifier and Type | Field and Description |
---|---|
protected ContentHelper |
_contentHelper
The content helper.
|
protected ContentTypesHelper |
_contentTypesHelper
Content Types helper
|
private Context |
_context |
protected ContentTypeExtensionPoint |
_cTypeEP
The content type extension point.
|
protected ContentTypesHelper |
_cTypeHelper
The content type helper.
|
protected I18nUtils |
_i18nUtils
i18n Utils
|
protected SAXParser |
_parser
SAX parser
|
protected AmetysObjectResolver |
_resolver
The ametys object resolver.
|
protected SystemPropertyExtensionPoint |
_sysPropEP
The system property extension point.
|
protected UserHelper |
_userHelper
The user helper
|
static String |
ROLE
The component role.
|
Constructor and Description |
---|
ContentSearchHelper() |
Modifier and Type | Method and Description |
---|---|
private Object |
_getCompositeRepeaterValues(Content content,
CompositeMetadata metadataHolder,
MetadataDefinition definition,
Locale locale,
boolean resolveReferences,
String[] pathSegments,
String prefix,
String metadataName) |
private Object |
_getContentRepeaterValues(Content content,
CompositeMetadata metadataHolder,
MetadataDefinition definition,
String metadataPath,
Locale defaultLocale,
boolean resolveReferences,
String[] pathSegments,
String metadataName) |
private Object |
_getRepeaterRepeaterValue(Content content,
CompositeMetadata metadataHolder,
MetadataDefinition definition,
Locale locale,
boolean resolveReferences,
String[] pathSegments,
String prefix,
String metadataName) |
private Object |
_getRepeaterValues(Content content,
CompositeMetadata metadataHolder,
MetadataDefinition definition,
String prefix,
String metadataPath,
Locale defaultLocale,
boolean resolveReferences) |
private SearchField |
_getSearchField(MetadataDefinition def,
List<String> joinPaths) |
protected SearchField |
_getSearchField(MetadataIndexingField indexingField,
String[] remainingPathSegments,
List<String> joinPaths,
boolean addLast)
Get the search field from the indexing field and compute the join paths.
|
private Object |
_transformValue(Content content,
Content value,
Locale defaultLocale) |
private Object |
_transformValue(Content content,
String metadataPath,
BinaryMetadata binary) |
Object |
_transformValue(Content content,
String metadataPath,
Object rawValue,
Enumerator enumerator,
Locale defaultLocale)
Transform the raw value into a JSONified value, understandable for search UI
|
private Object |
_transformValue(MultilingualString multilingualString) |
private Object |
_transformValue(Resource resource) |
private Object |
_transformValue(RichText richText) |
private Object |
_transformValue(UserIdentity user) |
void |
contextualize(Context context) |
SearchField |
getMetadataSearchField(List<String> joinPaths,
String metadataPath,
MetadataType metadataType)
Get a
SearchField corresponding to a metadata. |
SearchField |
getMetadataSearchField(String metadataPath,
MetadataType metadataType)
Get a
SearchField corresponding to a metadata. |
Object |
getMetadataValue(Content content,
String metadataPath,
Locale defaultLocale)
Get the value(s) of a metadata - transformed into JSONified value - of a content at given path.
|
Object |
getMetadataValue(Content content,
String metadataPath,
Locale defaultLocale,
boolean resolveReferences)
Get the value(s) of a metadata - transformed into JSONified value - of a content at given path.
|
Object |
getMetadataValue(Content content,
String fullMetadataPath,
MetadataType type,
boolean multiple,
Enumerator enumerator,
Locale defaultLocale,
boolean full)
Get the value(s) of a metadata - transformed into JSONified value - of a content at given path.
|
Map<String,Object> |
getMetadataValues(Content content,
Collection<String> metadataPaths,
Locale defaultLocale)
Get metadata values by their path
|
Map<String,Object> |
getMetadataValues(String contentId,
Collection<String> metadataPath,
Locale defaultLocale)
Get metadata values by their path
|
SearchField |
getSearchField(Collection<String> contentTypes,
String fieldPath)
Get a
SearchField from a field name in a batch of content types. |
MetadataIndexingField |
getTitleMetadataIndexingField()
Get the metadata indexing field for the "title" standard metadata.
|
void |
service(ServiceManager manager) |
getLogger, setLogger
protected ContentTypeExtensionPoint _cTypeEP
protected ContentTypesHelper _cTypeHelper
protected ContentHelper _contentHelper
protected SystemPropertyExtensionPoint _sysPropEP
protected AmetysObjectResolver _resolver
protected UserHelper _userHelper
protected ContentTypesHelper _contentTypesHelper
protected I18nUtils _i18nUtils
public ContentSearchHelper()
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public MetadataIndexingField getTitleMetadataIndexingField()
public SearchField getMetadataSearchField(String metadataPath, MetadataType metadataType)
SearchField
corresponding to a metadata.metadataPath
- The metadata path.metadataType
- The metadata type.public SearchField getMetadataSearchField(List<String> joinPaths, String metadataPath, MetadataType metadataType)
SearchField
corresponding to a metadata.joinPaths
- The join pathsmetadataPath
- The metadata path.metadataType
- The metadata type.public SearchField getSearchField(Collection<String> contentTypes, String fieldPath)
SearchField
from a field name in a batch of content types.contentTypes
- The content types, can be empty to search on any content type.
In that case, only the title metadata and system properties will be usable in sort and facets specs.fieldPath
- The field path, can be either a system property ID or a indexing field name or path.SearchField
corresponding to theprotected SearchField _getSearchField(MetadataIndexingField indexingField, String[] remainingPathSegments, List<String> joinPaths, boolean addLast)
indexingField
- The initial indexing fieldremainingPathSegments
- The path to access the metadata or an another indexing field from the initial indexing fieldjoinPaths
- The consecutive's path in case of joint to access the field/metadataaddLast
- true
to add the last join path element to the list, false
otherwise.private SearchField _getSearchField(MetadataDefinition def, List<String> joinPaths)
public Map<String,Object> getMetadataValues(String contentId, Collection<String> metadataPath, Locale defaultLocale)
contentId
- The id of contentmetadataPath
- The path of metadata to retrievedefaultLocale
- The default locale to resolve multilingual values if the content's language is null. Can be null.public Map<String,Object> getMetadataValues(Content content, Collection<String> metadataPaths, Locale defaultLocale)
content
- The initial contentmetadataPaths
- The path of metadata to retrieve, slash-separated.defaultLocale
- The default locale to resolve multilingual values if the content's language is null. Can be null.public Object getMetadataValue(Content content, String metadataPath, Locale defaultLocale)
content
- The contentmetadataPath
- The path to the metadata, separated by '/'defaultLocale
- The default locale to resolve multilingual values if the content's language is null. Can be null.public Object getMetadataValue(Content content, String metadataPath, Locale defaultLocale, boolean resolveReferences)
content
- The contentmetadataPath
- The path to the metadata, separated by '/'defaultLocale
- The default locale to resolve multilingual values if the content's language is null. Can be null.resolveReferences
- true
true to resolve referencespublic Object getMetadataValue(Content content, String fullMetadataPath, MetadataType type, boolean multiple, Enumerator enumerator, Locale defaultLocale, boolean full)
content
- The initial content.fullMetadataPath
- The path to the metadata, separated by '/'type
- The metadata type.multiple
- true
if the metadata is multiple.enumerator
- The metadata enumerator. Can be null.defaultLocale
- The default locale to resolve multilingual values if the content's language is null. Can be null.full
- true
to generate full representation of metadata's values : the references will be resolved and the label of enumerated values will be returned.public Object _transformValue(Content content, String metadataPath, Object rawValue, Enumerator enumerator, Locale defaultLocale)
content
- the contentmetadataPath
- The path to the metadata, separated by '/'rawValue
- The typed valueenumerator
- The enumerator. Can be nulldefaultLocale
- Locale to use for localized values if content's language is null.private Object _transformValue(Resource resource)
private Object _transformValue(Content content, Content value, Locale defaultLocale)
private Object _transformValue(UserIdentity user)
private Object _transformValue(MultilingualString multilingualString)
private Object _transformValue(Content content, String metadataPath, BinaryMetadata binary)
private Object _transformValue(RichText richText)
private Object _getRepeaterValues(Content content, CompositeMetadata metadataHolder, MetadataDefinition definition, String prefix, String metadataPath, Locale defaultLocale, boolean resolveReferences)
private Object _getContentRepeaterValues(Content content, CompositeMetadata metadataHolder, MetadataDefinition definition, String metadataPath, Locale defaultLocale, boolean resolveReferences, String[] pathSegments, String metadataName)
private Object _getCompositeRepeaterValues(Content content, CompositeMetadata metadataHolder, MetadataDefinition definition, Locale locale, boolean resolveReferences, String[] pathSegments, String prefix, String metadataName)
private Object _getRepeaterRepeaterValue(Content content, CompositeMetadata metadataHolder, MetadataDefinition definition, Locale locale, boolean resolveReferences, String[] pathSegments, String prefix, String metadataName)