Search Manual / Version 2307
Table Of ContentsThe BeanMappingFeedablePopulator class has two properties that you can use for customizing the mapping between content bean properties and Feedable.
beanPropertiesByClass
beanMappings
beanMappings
offers more powerful options. You can, for example, add
a property converter implementation that maps to a specific type.
Using beanPropertiesByClass
This configuration provides a simple way for bean properties which are mapped to feedable elements
with the same name. The values of these bean properties are written to an index field with the same name,
if it exists. Furthermore, the bean property values will always be appended to the textbody
index field.
In more detail, the property beanPropertiesByClass
of the
BeanMappingFeedablePopulator
takes a java.util.Map
object, which maps bean classes to comma-separated
strings of their indexed bean properties. This map is available in the Spring application
context under the name caeFeederBeanPropertiesByClass
and can be customized.
The following example defines the mapping for content beans of classes
com.coremedia.example.contentbeans.Text
and
com.coremedia.example.contentbeans.Download
. For content beans of class
Text
and subclasses, the Java bean properties headline
and
text
map to elements of the feedable. When constructing a feedable the
BeanMappingFeedablePopulator
calls the property methods getHeadline
and getText
of class
Text
to retrieve the values for these elements.
<customize:append id="caeFeederBeanPropertiesByClassCustomizer" bean="caeFeederBeanPropertiesByClass"> <map> <entry key="com.coremedia.example.contentbeans.Text" value="headline,text"/> <entry key="com.coremedia.example.contentbeans.Download" value="data"/> </map> </customize:append>
Using beanMappings
A more powerful configuration is available with the property beanMappings
of the
BeanMappingFeedablePopulator.
The new options are:
Define to which search field a content bean property is mapped
Define that a content bean property should not be mapped to the
textBody
field of SolrDefine your own property converter
Define a default value when a property returns null
Adding parameters to a feedable
The property beanMappings
takes a list of mappings where each mapping applies
to one bean class. You can customize this list of mappings as shown below. A mapping for a single bean class
is represented by a
com.coremedia.cap.feeder.bean.BeanFeedableMapping.
Each
BeanFeedableMapping
contains a list of mappings for Java bean properties of the bean class in the property
beanPropertyMappings
. A mapping for a single Java bean property to an element
of the Feedable is represented
by a
com.coremedia.cap.feeder.bean.BeanPropertyFeedableElementMapping.
See Example 5.5, “Example Content Bean to Feedable Mapping” for an example.
Note
A content bean can inherit from or extend other content beans. In this case, you might have different
BeanFeedableMapping elements that match for an instance of a content bean. If so, the order
of the BeanFeedableMapping
elements in the list of mappings is important: The first
mapping of a property that matches overwrites all following mappings that match.
Example 5.5, “Example Content Bean to Feedable Mapping” defines a mapping for the superclass of all content beans
com.coremedia.objectserver.beans.ContentBean.
The bean property content.modificationDate
maps to the feedable element named
freshness
. The default Solr index schema defines an index field with that name, to which the
bean property's value is written.
The bean property uses the syntax of Spring framework's bean wrapper
for nested properties. When constructing a feedable the
BeanMappingFeedablePopulator
calls the property methods getContent().getModificationDate()
of class
ContentBean
to retrieve the value for the element. Furthermore, the value is not added to the
textbody
index field.
Keep in mind, that if you define a mapping for freshness
for any other content bean class
and add it behind this example mapping to the list of mappings, it would be overwritten by our example definition and
you would get a warning in the log file. So, avoid this.
<customize:append id="caeFeederBeanMappingsCustomizer" bean="caeFeederBeanMappings"> <list> <ref local="exampleBeanFeedableMapping"/> </list> </customize:append> <bean id="exampleBeanFeedableMapping" class="com.coremedia.cap.feeder.bean.BeanFeedableMapping"> <property name="beanClass" value="com.coremedia.objectserver.beans.ContentBean"/> <property name="beanPropertyMappings"> <list> <bean class="com.coremedia.cap.feeder.bean. BeanPropertyFeedableElementMapping"> <property name="beanProperty" value="content.modificationDate"/> <property name="feedableElement" value="freshness"/> <property name="textBody" value="false"/> </bean> </list> </property> </bean>
Example 5.5. Example Content Bean to Feedable Mapping
See the API documentation for a description of all properties of the classes
BeanMappingFeedablePopulator,
BeanFeedableMapping
and
BeanPropertyFeedableElementMapping
in package com.coremedia.cap.feeder.bean
.