Field Mappings
Field Mappings are used to map the fields with the Sql parameters. Following is the list of different mappings defined for the reports.
SimpleMapping
Simple Mapping is used for mapping field types like STRING, DOUBLE, LONG, FLOAT, BOOLEAN, INTEGER where a field is mapped to one SQL parameter.
<
SimpleMapping
sqlName
=
"TITLE"
/>
DateRangeMapping
Date Range Mapping is used for mapping Date range fields. To configure the DateRange fields, toSqlName and fromSqlName must be mapped.
<
DateRangeMapping
fromSqlName
=
"PUBLISHING_PERIOD_START"
toSqlName
=
"PUBLISHING_PERIOD_END"
/>
ModelLinkMapping
Model Link Mapping is used to map a model link fields to the SQL parameters. To configure the model link mapping, the surrogate id and display fields should be in defined in the SQL. Following is the example to display the model link field in the table:
<
ModelLinkMapping
surrogateIdSqlName
=
"SYS_SALES_REP_ID"
displayFieldSqlName
=
"SALES_REP"
/>
By default, model links are rendered as hyperlinks. To disable these hyperlinks, add the DisableHyperLink tag:
<
ModelLinkMapping
surrogateIdSqlName
=
"SYS_SALES_REP_ID"
displayFieldSqlName
=
"SALES_REP"
>
<
DisableHyperLink
>true</
DisableHyperLink
>
</
ModelLinkMapping
>
An editable Model link field can be configured to auto-complete. Auto-complete for a model link can be configured in one of the two ways:
AutoCompleteSqlDefName. This can be used when there is a sql def for auto-completion.
<
ModelLinkMapping
surrogateIdSqlName
=
"SYS_ORG_ID"
displayFieldSqlName
=
"TEST_MODEL_LINK"
>
<
AutoCompleteSqlDefName
>PTA.AutoCompleteSql.GetOrganization</
AutoCompleteSqlDefName
>
<
PickerSize
height
=
"250"
/>
</
ModelLinkMapping
>
Key points to be noted:
Autocomplete SQL definition name is prefixed by Module Id.
In the above example, AutoCompleteSql is the group name and GetOrganization is the SQL definition name.
AutoCompleteSql. When one may wish to define the auto-complete SQL directly in the report, we can use this.
<
ModelLinkMapping
surrogateIdSqlName
=
"SYS_ORG_ID"
displayFieldSqlName
=
"TEST_MODEL_LINK"
>
<
AutoCompleteSql
>
SELECT org.sys_org_id, org.org_name FROM ORGANIZATION org
WHERE UPPER(org.org_name) LIKE UPPER $TYPED_VALUE$ || '%'
</
AutoCompleteSql
>
<
PickerSize
height
=
"250"
/>
</
ModelLinkMapping
>
Key points to be noted:
Autocomplete SQL has a parameter called $TYPED_VALUE$. This is the input to the auto-complete sql.
Following is the schema definition for the ModelLinkMapping:
Table 7.1. Model Link Mapping schema definition
Name |
Attribute/Element |
Required/Optional |
Description |
surrogateIdSqlName |
Attribute |
Required |
To bind the surrogate id sql as a filter. The surrogate id will be non-null when the user chooses an auto-complete or picker dialog value. |
displayFieldSqlName |
Attribute |
Required |
To bind the display field value as a filter. The display field value will be non-null when the user types a value in the field without accepting an auto-complete value. As a consequence, you should provide SQL which filters against both your surrogateIdSqlName and displayFieldSqlName, applying the one which is not null. For example: ${filterIfNotNull:SYS_ORG_ID,ORG.SYS_ORG_ID = $SYS_ORG_ID$} and ${filterIfNotNull:TEST_MODEL_LINK,ORG.ORG_NAME like $TEST_MODEL_LINK$} |
multiSelectMode |
Attribute |
Optional(default is false) |
This is used to specify if multiple selections is allowed for this field. If this is set to true, then surrogate Id in the where clause of the sql must have IN clause. (For example ORG.SYS_ORG_ID in $SYS_ORG_ID$.) This will set the selection as checkboxes as opposed to radio buttons in the picker dialog box and also auto-complete will allow picking multiple fields. |
exactMode |
Attribute |
Optional(default is false) |
Default is false for filtering and true for the retrieval criteria. This is used to specify if this search needs to be exact or wild card. Exact search mode will show an error if the field is not selected from the auto-complete or the picker. |
AutoCompleteSqlDefName |
Element |
Optional |
To customize the auto-complete SQL and point it to the SQL definition |
AutoCompleteSql |
Element |
Optional |
To customize the auto-complete SQL and point it to the SQL definition |
PickerSize |
Element |
Optional |
To customize the picker dialog width and height. |
PickerReport |
Element |
Optional |
This element is used to define another report to be used for filter or retrieval field picker dialog. |