Conditional Branch 0.4

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

For Information on Aspire 3.1 Click Here

Aspire / Aspire Components / Conditional Branch

Conditional Branch
Description: Compares the contents of one of the elements against a set of conditions and if a match is found, branches the input job to an event.
Inputs: Jobs
Outputs: The input job, branched if appropriate
Factory: aspire-tools
Sub Type: conditionalBranch
Object Type: AspireDocument

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:
  • 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 on disk
  • isFile - the field gives the path to a file on disk
  • isDirectory - the field gives the path to a directory on disk
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">
     <config>
       <targetElement>/doc/ENTITY_TYPE</targetElement>
       <condition type="equals" value="pg" event="onPost2Solr"/>
     </config>
   </component>
 </components>

Complex Component Configuration

 <components>
   <component name="branchSomewhere" subType="conditionalBranch" factoryName="aspire-tools">
     <config>
       <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>
     <stage component="getPGTitles" />
     <stage component="getPGDescriptions" />
     <stage component="getPGClassifications" />
     <stage component="getPGEpisodeCount" />
     <stage component="getPGClassificationNotes" />
 
     <stage component="refGetPGSubTypeText" />
 
     <stage component="branchOnPG"/> 
 
     <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>