Conditional Branch (Aspire 2)

From wiki.searchtechnologies.com
Jump to: navigation, search

For Information on Aspire 3.1 Click Here

Conditional Branch (Aspire 2)
Factory Name  com.searchtechnologies.aspire:aspire-tools
subType  conditionalBranch
Inputs  AspireObjects from earlier processing pipeline stages
Outputs  The input job, branched if appropriate

The Conditional Branch stage compares the contents of one of the elements in the incoming AspireObject against a set of conditions and if a match is found, branches the input job to an event. The pipeline manager receives the event, causing processing of the job to be diverted to another stage or pipeline.


Configuration

Element Type Default Description
targetElement String The Xpath to the element in the job's document that should be used for the comparison.
condition/@type String The type of the comparision to be performed. This attribute must be specified. Currently supported comparisons are:
  • targetExists - the field (node or attribute) exists. The value could still be null or empty
  • empty - the field is empty
  • equals - the field matches the given value (case sensitive)
  • equalsIgnoreCase - the field matches the given value (case insensitive)
  • regex - the field matches the given regular expression
  • exists - the field gives the path to a file or directory that exists on disk
  • isFile - the field gives the path to a file that exists on disk
  • isDirectory - the field gives the path to a directory that exists on disk

NOTE: for all but targetExists, the node must exist for the subsequent condition to be evaluated. Therefore any test on /doc/XXX where /doc/XXX does not exist will return false, even if not=true

condition/@not Boolean false If true, the result of the test is has a not applied to it (ie equals becomes not equals).
condition/@value String The value against to be used in the comparision. In the case of equals and equalsIgnoreCase, this is the value to compare against. In the case of regex, this will be the regular expression to match. In the case of exists, isFile and isDirectory, this is the path to check for.
condition/@event String The event to branch the job too, if the condition is satisfied. This event must be configured in the branches section of the pipeline manager.

Example Configurations

Simple Component Configuration

 <components>
   <component name="branchOnPG" subType="conditionalBranch" factoryName="aspire-tools">
     <targetElement>/doc/ENTITY_TYPE</targetElement>
     <condition type="equals" value="pg" event="onPost2Solr"/>
   </component>
 </components>

Complex Component Configuration

 <components>
   <component name="branchSomewhere" subType="conditionalBranch" factoryName="aspire-tools">
     <targetElement>/doc/type</targetElement>
     <condition type="empty" event="branchEmpty" />
     <condition type="equals" value="eqVal" event="branchEquals" />
     <condition type="equalsIgnoreCase" value="eqVal" event="branchEqualsIgnoreCase" />
     <condition type="regex" value="^regexVal.*" event="branchRegex" />
     <condition type="isFile" event="branchIsFile" />
     <condition type="isDirectory" event="branchIsDirectory" />
     <condition type="exists" event="branchExists" />
   </component>
 </components>

Example Pipeline Configuration

 <pipeline name="addPipeline" default="true">
   <stages>
     <!-- PG -->
     <stage component="getPGTitles" />
     <stage component="getPGDescriptions" />
     <stage component="getPGClassifications" />
     <stage component="getPGEpisodeCount" />
     <stage component="getPGClassificationNotes" />
 
     <stage component="refGetPGSubTypeText" />
 
     <stage component="branchOnPG"/> 
 
     <!-- P -->
     <stage component="getPTitles" />
     <stage component="getPDescriptions" />
     <stage component="getPClassifications" />
     <stage component="getPPublicationDates" />
     <stage component="getPProgramNumber" />
 
   </stages>
   <branches>
     <branch event="onPost2Solr" pipeline="post2Solr"/>
     <branch event="onComplete" pipeline="post2Solr"/>
     <branch event="onError" pipeline="errorPipeline" pipelineManager="/error/errorPipelineManager"/>
   </branches>
 </pipeline>