DataStage fields and ruleset parameters mapping
The ILOG® JRules connector converts the records available in the input link into Java™ objects. The connector must understand the mapping between the connector stage fields and the ruleset parameters, in order to complete the conversion.
The mapping can also be identified automatically by using the configuration wizard. The following sections describe how the InfoSphere® DataStage® fields are mapped to the ruleset parameters.
- The methods present in the ruleset parameter class
- The ruleset parameter name and data type (if it is of basic Java type).
For more information about basic Java types, refer to the topic Basic Java types and methods. If the ruleset parameter conforms to the conditions specified in the Automatic mapping section, then the mapping is done automatically based on the Column name attribute of the field. Otherwise, the mapping is done by using a mapping specification provided in the Description attribute of the field.
ILOG JRules connector can automatically identify the mapping between the link fields and the ruleset parameter if any of the following conditions are met:
- If the ruleset parameter is of one of the basic Java types supported by the connector, then the Column name must correspond to the name of the ruleset parameter. The SQL Type of the field must be compatible with the basic Java type of the ruleset parameter. For more information about mapping or compatibility of data types, refer to topics DataStage type to Java type mapping and Java type to DataStage type mapping. In this case, the field is directly mapped to the ruleset parameter.
- If the ruleset parameter is not of a basic Java type and the link is an input link, then the ruleset parameter class must have a method named setFieldName(), where FieldName is the Column name of the field. The comparison of the Column name and the method name is not case-sensitive. The method must not have any return type and must have a single argument and the SQL type of the field on the input link must be compatible with the data type of the argument expected by the method. For example the field firstName of type VarChar(10) on an input link maps to the first and only argument of the method void setFirstName(String name). In this case, the input field is mapped to the argument expected by the method.
- If the ruleset parameter is not of a basic Java type and the link is an output link, then the ruleset parameter class must have a method named getFieldName(), where FieldName is the Column name of the field. The comparison of the Column name and the method name is not case-sensitive. A special case is when the method is of boolean or java.lang.Boolean return type, and in that case the method is expected to be named isFieldName(). The return value from the method must be compatible with the SQL type of the field present on the output link. In this case, the field is mapped to the return value of the method.
If there is a field on the input link for which there is no method in the ruleset parameter class conforming to the second condition (and the Description attribute is empty) then the field values are not passed to ILOG JRules. Similarly, if there is a field in the output link for which there is no method in the ruleset parameter class conforming to the third condition (and the Description attribute is empty) then the field value is not set by the ILOG JRules connector.
Mapping using Description specification
If the ruleset parameter does not follow the conditions for automatic mapping, then the ILOG JRules connector provides a mechanism to specify the method to be invoked for setting or getting each field value in the InfoSphere DataStage input and output records. This is specified in the Description attribute of the schema fields on the Columns tab of the stage editor. For every field in the link schema, the Description carries information about the method to be invoked on the Java class associated with the link, to set, or get that field value. If no information is present in the Description attribute for any of the fields, then the ruleset parameter is assumed to conform to the specification mentioned in the Automatic mapping section.
input link columns, the value of their Description attribute
consists of one more concatenated expression, where each expression
is in the
CC_JRules(methodName, parameterIndex); format.
methodName specifies the name of the method to
be invoked on the ruleset parameter object for this column. The
is an integer greater than or equal to 1 which specifies the index
of the parameter (for the method) to which the column maps to.
example, a Java object has a
setFullName(String firstName, String lastName) and
the DataStage record contains
two fields, firstName and lastName.
In this case, the Description attribute for firstName is
that for lastName is
The firstName field value from a DataStage record is used for the first
setFullName method and the lastName field
value from the same record is used for the second argument.
The methodName can
also be a constructor. If the firstName column
in the example is also used for the first argument of the constructor
for the class
Customer, then the Description
attribute for the firstName is
the output links, the method is called to get the value of the field
from the Java object. Hence,
the field does not expect any parameter. As a result, for fields on
the output links, the parameter index is not required. The syntax
of the Description attribute for the fields
on the output link is:
each field, there must be only one method that can be called. If more
than one method exists, then the ILOG JRules connector logs
an error and the job fails.
When a single column on the link
represents the entire ruleset parameter value, the Description attribute
for the column has the
CC_JRules(); value. This is
the case when the ruleset parameter is of one of the basic Java types supported by the connector.
Dynamic XOMIf a InfoSphere DataStage record field contains an XML document which is to be sent to the ruleset based on the Dynamic XOM, then the Description attribute for the field can contain the
CC_JRules();value. When there are multiple fields in the InfoSphere DataStage record, the value is necessary to specify which of them contains the XML document.
If there is a single field in the record, then that field is automatically assumed to be the field containing the XML document and the Description attribute of the field can be left empty. The field that contains the XML document must be any of the InfoSphere DataStage character-based data types such as Char, NChar, VarChar, NVarChar, LongVarChar or LongNVarChar.