Developer Transformation Guide > Expression Transformation > Port Selectors
  

Port Selectors

When a transformation has generated ports, you need to configure the transformation to run successfully when the generated ports change. You can use a port selector to determine which ports to use in a dynamic expression, a lookup condition, or a joiner condition.
A port selector is an ordered list of ports that you can reference in an expression. When the generated ports change in a dynamic mapping, the port selector can contain different ports.
For example, the following expression references a generated port in a dynamic mapping:
Salary * 12
You configure the mapping to use dynamic sources, but the column that contains salary information in each source file has a different name. The column names are Salary, Monthly_Salary, or Base_Salary.
You perform the following tasks to accommodate the different column names:
  1. 1. Create a port selector named "Salary_PortSelector."
  2. 2. Create a selection rule to accept any port name with the suffix "Salary."
  3. 3. Change the expression to include the port selector name instead of the salary column name. The expression has the following syntax:
  4. Salary_PortSelector * 12
The expression runs successfully with any of the salary port names.

Port Selector Configuration

When you configure a port selector, you define selection rules to determine which generated ports to include. The selection rules are similar to the input rules that you can configure for dynamic ports.
A port selector can include static or generated ports. Configure a port selector on the Port Selector tab.
The following image shows the Port Selector tab:
Configure the following properties for a port selector:
Name
Identifies the port selector. You can create multiple port selectors in a transformation and reference them in expressions.
Scope
Identifies a group of ports that the port selector applies to. You must choose the scope when you create a port selector for a Joiner or a Lookup transformation. These transformations have multiple input groups. The Joiner transformation has a Master or a Detail scope. The Lookup transformation has an Import or a Lookup scope. The Expression transformation has one input group. The scope is always All Ports.
Selection Rules
Determines the ports to include in the port selector. When you create the selection rules, the Port Preview panel shows the ports that qualify from the current input ports. These ports might change. Configure the selection rules to accommodate ports from different sources.

Selection Rules

The selection rules associated with a port selector determine the ports to include in the port selector.
When you create the selection rules, the Port Preview panel shows the ports that qualify from the current input ports. These ports might change. Configure the selection rules to accommodate ports from different sources.
Create selection rules based on the following criteria:
Operator
Includes or excludes the ports that selection rules return. Default is include. You must include ports before you can exclude ports.
Selection Criteria
The type of selection rule you want to create. You can create a rule based on the column name, port type, pattern, or complex data type definition. To include ports based on the column name, search for specific names or search for a pattern of characters in the name.
Detail
The values to apply to the selection criteria. If the selection criteria is by column name, configure the string or name to search for. If the selection criteria is by port type, select the port types to include.
The following table describes the selection criteria and how to specify the details for the criteria:
Selection Criteria
Description
Detail
All
Includes all ports.
No details required.
Name
Filters ports based on the port name.
Select the port names from a list of values or use a parameter of type Port or Port List.
Type
Filters ports based on the data type of each port.
Select data types from a list.
Pattern
Filters ports by a string of characters in the name or by a regular expression.
Choose prefix, suffix, or regular expression as the pattern type for the port name. Then, enter a value for the pattern or use a parameter of type String.
Complex Data Type Definition
Filters ports by a complex data type definition.
Choose prefix, suffix, or regular expression as the pattern type for the complex data type definition. Then, enter a value for the pattern or use a parameter of type String.

Creating a Port Selector

Create a port selector to determine which ports to use in a dynamic expression, a lookup condition, or a joiner condition.
    1. Click the Port Selectors tab.
    2. In the Port Selectors area, click New.
    The Developer tool creates a port selector with a default selection rule that includes all ports.
    3. In the Port Selectors area, change the port selector name to a unique name.
    4. If you are working on the Joiner transformation or the Lookup transformation, choose the scope.
    The available ports change based on the group of ports that you choose.
    5. In the Selection Rules area, select an Operator.
    6. Choose the Selection Criteria.
    The following image shows the Port Selector tab:
    The port selector tab shows a port selector called Join_Selector. The scope is Detail, which is the Detail input group of a Joiner transformation. The Operator is Include. The Selection Criteria is By Pattern. The Detail column says prefix: City. The Port preview column shows City and City2 ports.
    7. Click the Detail column.
    The Input Rule Detail dialog box appears.
    8. Select the values to filter ports by.
    The Port Preview area shows the ports in the port selector as you configure the rules.
    9. To reorder the ports in the port selector, select Reorder generated ports according to the input rule order.