close

Filter

loading table of contents...

Search Manual / Version 2512.0

Table Of Contents

5.4.3.1 Configuring the BeanMappingFeedablePopulator

The predefined BeanMappingFeedablePopulator can be configured to map content bean data to feedable elements. Its property beanMappings takes a list of mappings where each mapping applies to one bean class. A mapping for a single bean class is represented by class com.coremedia.cap.feeder.bean.BeanFeedableMapping, which can be configured to map data from a given content bean instance to a feedable element. The list of mappings is available as Spring bean caeFeederBeanMappings, to which you can add custom mappings in the Spring configuration as shown in the following example.

@Bean(autowireCandidate = false)
@Customize("caeFeederBeanMappings")
public BeanFeedableMapping<ContentBean> contentBeanFeedableMapping() {
  BeanFeedableMapping<ContentBean> mapping = new BeanFeedableMapping<>(ContentBean.class);
  mapping.addElement("documenttype", bean -> bean.getContent().getType().getName());
  mapping.addElement("freshness", bean -> bean.getContent().getModificationDate());
  return mapping;
}

@Bean(autowireCandidate = false)
@Customize("caeFeederBeanMappings")
public BeanFeedableMapping<CMLinkable> cmLinkableBeanFeedableMapping() {
  BeanFeedableMapping<CMLinkable> mapping = new BeanFeedableMapping<>(CMLinkable.class);
  mapping.addElement("keywords", CMLinkable::getKeywords, true);
  mapping.addElement("segment", CMLinkable::getSegment);
  return mapping;
}

Example 5.2. Example Content Bean to Feedable Mapping


The example defines two mappings, one for the superclass of all content beans com.coremedia.objectserver.beans.ContentBean, and one for CMLinkable beans. Similar more lengthy mappings exist in the Blueprint configuration in Spring configuration class CaeFeederBlueprintAutoConfiguration.

The first mapping for class ContentBean defines two elements documenttype and freshness with functions to compute their values from a given content bean. Values will be indexed in Solr fields with the same name, if such fields exist in the index. This mapping will be used for all content beans.

The second mapping for class CMLinkable configures feeding of bean properties keywords and segments into Solr index fields of the same name, if such fields exist in the Solr index. Keywords are also indexed in the Solr field textBody, as specified by the third parameter true of method addElement. This mapping will be used for all content beans that implement CMLinkable.

Of course, functions passed to addElement methods can use more complex logic than just calling content bean methods. They can convert values from content bean properties to a suitable format for indexing, provide default values, or use other custom logic as needed.

Note

Note

A content bean class can inherit from or extend other content beans classes, and multiple BeanFeedableMapping configurations can match for the class of a content bean. If so, all matching mappings will be used. However, it is an error to configure multiple matching mappings with the same element name. In such a case, a warning will be logged, and the configuration from the first BeanFeedableMapping in the list of mappings will be used. There is no mechanism to override the configuration for a Feedable element in a mapping for a content bean subclass.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.