Alfresco 5: Customizing facet filter for future dates

From Alfresco 5, faceted search is available in Share web app.

However, when using dates, only past facets are available (yesterday, last week…). When using future dates in customized metadata, some modifications are required.

Following instructions can be deployed as an standard Repository extension project  by using Alfresco SDK.

Overriding date facets Spring beans from Alfresco to add extra classification must be included in service-context.xml

<!-- Include your own customized properties from content model: futureDate -->
<bean id="facet.dateFacetFields" class="org.springframework.beans.factory.config.SetFactoryBean">
   <property name="sourceSet">
      <set>
         <value>@{http://www.alfresco.org/model/content/1.0}created</value>
         <value>@{http://www.alfresco.org/model/content/1.0}modified</value>
         <value>@{http://www.keensoft.es/model/document/1.0}futureDate</value>
      </set>
   </property>   
</bean>

<!-- Include different categories for future dates: next year, next six months... -->
<bean id="facet.dateBuckets" class="org.springframework.beans.factory.config.MapFactoryBean">
   <property name="sourceMap">
            <map>
               <entry key="[NOW/DAY+1DAY TO NOW/DAY+1YEAR]" value="Next year" />
               <entry key="[NOW/DAY+1DAY TO NOW/DAY+6MONTHS]" value="Next six months" />
               <entry key="[NOW/DAY+1DAY TO NOW/DAY+1MONTH]" value="Next month" />
               <entry key="[NOW/DAY+1DAY TO NOW/DAY+7DAYS]" value="Next week" />
               <entry key="[NOW/DAY-1DAY TO NOW/DAY+1DAY]" value="faceted-search.date.one-day.label" />
               <entry key="[NOW/DAY-7DAYS TO NOW/DAY+1DAY]" value="faceted-search.date.one-week.label" />
               <entry key="[NOW/DAY-1MONTH TO NOW/DAY+1DAY]" value="faceted-search.date.one-month.label" />
               <entry key="[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]" value="faceted-search.date.six-months.label" />
               <entry key="[NOW/DAY-1YEAR TO NOW/DAY+1DAY]" value="faceted-search.date.one-year.label" />
            </map>
   </property>
</bean>

Once this module is deployed, future dates are classified in the future in faceted search Alfresco page.

alfresco-faceted-search-future

This functionality may be modified in the future. This article has only been tested with Alfresco CE 5.0.d

 

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s