A Ruleset Method, like a Composite Rule, is used to group rules. An important difference however, is that the method includes Type parameters which correspond to data types in the source and target of the Ruleset. Methods can also be re-used within the Ruleset, thereby providing better maintainability.
- Methods can be called as either a simple rule, or as a Case in Switch Rules.
- Method parameters are defined as input.
- Methods must be created and defined in the Ruleset that they are being used.
The Methods panel, shown here, is available from the Ruleset editor, and displays any Method created for a particular Ruleset. Methods can be created, called, edited, and deleted from this panel.
Creating Methods for use in a Ruleset
Methods must be created and defined in the Ruleset that they are being used.
- Create a method using the Add Method button from the Methods view in the Ruleset editor. The Method Parameters screen appears.
- Select source and/or target method parameters from the available types, which have been queried from the Source/Target Schema. Use the add buttons to select from the available parameters (shown above). Build a list of source and target parameters based on their type.
Note: While at least one Source Type is required, Target Type is not. However, if your target is a generic reference, thereby requiring you to create a specific type, you can have the Studio create a target parameter. To do this, select the Create Target checkbox. When a type is selected, and Create Target is checked, this will create a StorageNode parameter of that root type. If Create Target is not checked, it will create a parameter of that specific root type.The difference between this Create Target option and the create in a Composite Rule is that there is additional type information available, and you can select the specific type for creation.Note: Currently a StorageNode variable cannot be created from a Schema’s root type for Source Parameters in the same manner (no checkbox). Follow the StorageNode path (select StorageNode) in the Method Wizard in order to create another StorageNode of a Schema Type. Additional steps are noted below.
- If using the StorageNodes parameter, you must select the type of Schema (JSON, XML, DB, etc) as well as the actual Schema object. Using the StorageNode parameter allows for the use of different source and target Schemas within the same Ruleset. Also see Changing a Transformation Connector in a Method.
- Name the Method (or just accept the default name). Click Finish to complete. The Method now appears and is available for use in the Ruleset editor.
Defining Multiple Sources and Targets for a Method
In addition to being able to define a StorageNode as the Source/Target of a Method, a user can define multiple sources and targets for a Method. This means that a user can map data from many sources to many targets within one Method. Rulesets can be used to produce multiple outputs in different formats. Many-to-many transformations are now possible using Ruleset Methods. Previously, this would have required several Methods and possibly additional Rulesets.Call and define the Method
Once you've created the Method, it must now be called and defined in your Ruleset. There are several ways to do this, depending on the type of rule (Simple or Switch Case) being used.
- Drag and drop the Method directly from the Methods pane to the rule in the Rules section of the Ruleset editor.
- For a Switch Case Rule, you can also drag and drop the Method to the Method tab in the Properties view.
- Define (map) the Method. To do this, you must open the Method by double-clicking it; a new tab (displayed as the actual Method name) will open in the editor. Note that an Execute tab still remains. This is the primary Ruleset, whereas the Method can be thought of as a Ruleset within the Ruleset.
In the example below, there are four move rules defined.
- Using the Properties view, continue to define the Method using the Rule and/or Conditions tabs, if needed.
All Method parameters are defined as input, which is slightly different from other Rules in that this allows you to map from the target schema to the targetParm input (if a target exists for the Method). Since the targetParm input parameter is a mapping from the target schema, the editor marks it with a cross-hair icon ( ).
Changing a Transformation Connector in a Method
In previous versions of the Studio, there were only two Transformation Connectors that could be changed; one for source, one for target. These were specific to the Execute method of the Ruleset, and could be changed via the Runtime tab in the Ruleset’s Property field under the Connectors section (shown below).
Now that a Ruleset Method may have multiple StorageNodes and may require multiple Transformation Connectors, the Transformation Connector can be modified per StorageNode. When switching to a Method, the Runtime tab displays each StorageNode parameter for that Method, along with the current Transformation Connector set for that StorageNode (shown below).
Please sign in to leave a comment.