Thursday, October 30, 2014

Reindex in SOLR4 in Alfresco

In Alfresco 5.0.b har been introduced which has a different (better!) SOLR folder layout. It is slightly different, so to reindex a SOLR4 instance in Alfresco 5.0.b. You should delete or move alf_data/solr4/*. This takes care of cached content nodes, models, and index.

SOLR data/indexes
<ALF_DATA>/solr4 or normally <ALFRESCO_HOME>/alf_data/solr4


BTW SOLR4 configuration is now in alfresco root <ALFRESCO_HOME>/solr4

Wednesday, October 22, 2014

Faceted forms - form based on node state (metadata)

A nice thing about Alfresco Share is that, you get a lot of functionality for free and it is very adaptable. But often you want more client-side adaptability and the first think that comes into mind is client-side Javascript. To avoid client-side javascript customization on Share I made a special form evaluator, which gives you the power to have different forms for the same node type, depending on the state/metadata values.

Normally you define a node type form for view and edit of existing nodes:

 <config evaluator="node-type" condition="my:nodeType"> ...

This is one time solution for alle nodes of this type and lifecycle. To use a facetted approach, you could now add form configuration depending on a metadata property, like:

  <config evaluator="facet-node-type" condition="my:nodeType,my:state=open">

and another

  <config evaluator="facet-node-type" condition="my:nodeType,my:state=closed">

This means (given this facet-node-type exists and works :) you should have a resulting form configuration of the 'node-type' and one 'facet-node-type' given your node either have state 'open' or 'closed'

This evaluation is done Share-server-side, so the state (my:state) should preferable be read-only in the resulting forms.

In my example we could have a text field for an 'open' node and none for a 'closed' on.

To make this work we need to define the 'facet-node-type' in the form-config xml

<alfresco-config>
  <plug-ins>
    <evaluators>
      <evaluator id="facet-node-type" class="com.redpill-linpro.alfresco.web.config.forms.FacetNodeTypeEvaluator" />
       </evaluators>
  </plug-ins>

...

and mainly the java code Source FacetNodeTypeEvaluator.java

Finally lets show the full 'condition' definition available:

General format

condition="<node-type>,<property-evals>"

Where <node-type> is the prefix-nodetype  like in the standard node-type evaluator ...

Where <property-evals> is of the format:

 <property-eval>[,<property-eval>]*

And <property-eval> is of the format

<property-name>=<property-value>[|<property-value>]*


So I could write the following to select only 'my:node-type' nodes with 'my:state' 'open' or 'closed' and 'my:color' set to 'blue'

condition="my:nodeType,my:state=open|closed,my:color=blue"

This can be used to have a form definition where one-large common form (section) is defined and various small modifications of this is in facet-node-type sections depending on the metadata of the node.