The document loaders access property values through an implementation of the atg.repository.search.indexing.PropertyAccessor interface. This interface defines methods for getting property values from repository items. It defines separate methods for text properties and meta properties, as well as for properties that return child items. By default, the loaders use the atg.repository.search.indexing.PropertyAccessorImpl class, which simply invokes RepositoryItem.getPropertyValue(). You can write your own implementations of PropertyAccessor that use custom logic for determining the values of specific properties. The simplest way to do this is to subclass PropertyAccessorImpl.

In the definition file, you can specify a custom property accessor by using the property-accessor attribute. For example, suppose you have a Nucleus component named /MyStuff/MyPropertyAccessor, of a custom class that implements the PropertyAccessor interface. You can specify it in the definition file like this:

<property name="price" property-accessor="/MyStuff/MyPropertyAccessor"/>

The value of the property-accessor attribute is the absolute path of the Nucleus component. To simplify coding of the definition file, you can map PropertyAccessor Nucleus components to simple names, and use those names as the values of property-accessor attributes. For example, if you map the /MyStuff/MyPropertyAccessor component to the name myAccessor, the above tag becomes:

<property name="price" property-accessor="myAccessor"/>

You can perform this mapping by setting the propertyAccessorMap property of the IndexingOutputConfig component. This property is a Map in which the keys are the names and the values are PropertyAccessor Nucleus components that the names represent.

FirstWithLocalePropertyAccessor

The atg.repository.search.indexing.accessor package includes a subclass of PropertyAccessorImpl named FirstWithLocalePropertyAccessor. This property accessor works only with derived properties that are defined using the firstWithLocale derivation method. FirstWithLocalePropertyAccessor determines the value of the derived property by looking up the currentDocumentLocale property of the Context object. Typically, this property is set by the LocaleVariantProducer, as described in Accessing the Context Object.

You can specify this property accessor in your definition file using the attribute value firstWithLocale. (Note that you do not need to map this name to the property accessor in the propertyAccessorMap.) For example:

<property name="displayName" property-accessor="firstWithLocale"/>

For information about the firstWithLocale derivation method, and about derived properties in general, see the ATG Repository Guide.

 
loading table of contents...