Branch components affect the order in which the other components, such as, Connectors, Scripts, Functions, AttributeMaps and other Branch components, are executed in the Flow of the AssemblyLine.
Branches can appear anywhere in the Flow section, but there is no library folder for them in the Resources section of the workspace.
A Branch does not have to run to completion; the same script call is used to programmatically exit any type of Branch: system.exitBranch(). See Exiting a Branch (or Loop or the AssemblyLine Flow) for more information.
The three Branch component types are:
While each type of Branch lets you define alternate routes for AssemblyLine processing, this simplest form determines the action in case: "If this situation occurs, then take this action." You define what "situation occurs" means by setting up Conditions that must be met; for example, by comparing data values or checking the result of some operation. If the conditions are true, the components attached under this Branch are executed.
The Branch allows us to define Conditions based on any data in the TDI server: Attribute values, parameters settings, externally accessible properties, and any information available using JavaScript , such as operating system calls for disk or memory usage. Multiple Conditions are ANDed or ORed, depending on the Match Any check box setting.
This simplest form of Branch component also supports three subtype settings, IF, ELSE-IF and ELSE, that we can select.
As mentioned above, we can prematurely exit a Branch by means of scripting, using system.exitBranch().
The Loop component provides functionality for adding cyclic logic within an AssemblyLine. Loops can be configured for three modes of operation: based on Conditions, based on a Connector or based on the values of an Attribute:
Note that we have a parameter called Init Options with which we can instruct the AssemblyLine to either:
Note also that there is a Connector Parameters tab, which functions similarly to an Output Map in that we can select which Connector parameters are to be set from work Attribute values.
This brings us to the topic of how Looping with an Iterator differs from doing so based on Lookup mode. Both options perform searches that create a result set returned for looping. For Iterator mode, the result set is controlled exclusively by the parameter settings of this component. Lookup mode, on the other hand, uses Link Criteria to define search or match rules. Since it frees you from having to code Hooks like On No Match or On Multiple Found, this is the preferred way of doing searches that may not always return one (and just one) matched entry.
We can prematurely exit a Loop by means of scripting, using system.exitBranch().
In an AssemblyLine Switch-Case construct, multiple cases can be active at the same time. TDI checks each case, just as it would a series of standard IF Branches. The following example shows how multiple cases work:
work.setAttribute("test","abc"); Switch work.test Case startsWith("a"): this is true Case contains ("bc"): this is true Case length=3: this is trueThe three Switch work.test expressions that are true will trigger Switch execution.
We can prematurely exit a Switch-Case by means of scripting, using system.exitBranch();.
Parent topic: The AssemblyLine