BuildFilterProcess

Top  Previous  Next

org.moremotion.mmcomp.reldb.BuildFilterProcess class existing in mmcomp_reldb.jar extends MoreMotion's org.moremotion.process.Process base class and it is used to build a filter expression out of the values entered to the process fields in a process form. The filter expression built can then be used in a WHERE clause of a SQL SELECT statement.

The values entered in to the process fields and the names of the fields are used to build expressions that are convenient to be used in WHERE clause and the built expression is assigned into the specified target symbol.

This process do not perform the query itself. The target symbol that contains the built expression can be used in a query parameter of RelDBQueryDataService or RelDBQueryProcess as follows:

SELECT * FROM products WHERE 
  @vof(v:filter)

 

 
It is possible to use logical operators inside the values of the process fields as follows.

BuildFilterProcess

 

The Process Configuration:

  <process name="BuildFilter" basedon="mor.RelDB.BuildFilterProcess">
    <param name="fields">*</param>
    <param name="exclfields">ID</param>
    <param name="opr">AND</param>
    <param name="tarsymbol">p:filter</param>
    <param name="upperfunc"></param>
  </process>

 
Parameters

fields (Accepts MScript)

This parameter is used to define which of the process fields that exist in the process block that this process is placed into.

The syntax of a field definition:

[data-type:]block-field-name[/sql-field-name]

 
data-type
This specifier is optional. The only valid value for it is "s" and it denotes that the data type of the field is string. If no data-type specifier is given then the data type is determined by analyzing the field value.

block-field-name

The name of the block input field to include into the filter.

sql-field-name
This specifier is also optional. It becomes necessary when the the block input field name and the name sql name are different.

Example:

PERSNAME/p.NAME

 

If all the block input fields in the process block should be included into the filter then "*" character can be used. To override the generic definitions implied by the "*", additional field definitions can be given after it.

Example:

*, s:PERSNAME/p.NAME, ID/c.ID

 

exclfields (Accepts MScript)

This parameter defines the list of the fields to exclude from the filtering.

Example:

  <process name="BuildFilter" basedon="mor.RelDB.BuildFilterProcess">
    <param name="fields">*</param>
    <param name="exclfields">PCAT_ID,CATNAME</param>
    ...
  </process>

 

opr (Accepts MScript)

The logical operator that ties the each comparison expression built. The choices are "AND" and "OR".

tarsymbol (Accepts MScript)

The target symbol that will contain the built filter expression.
 
Examples:
v:filter
p:filter
 

upperfunc (Accepts MScript)

This optional parameter can be used to define a database specific upper case function.

Example:
NLS_UPPER(@,'NLS_SORT=XGerman')

The @ character in the function definition represents either the column name or the field value.

 

Using this process for the blocks that have more than one record

Most commonly this process will be used for the blocks that have only one record. But the process is designed to process one or more records. In this case the filter expressions are tied up with "OR" operators.

How does the process work?

- prepare() method of the process retrieves the values of the process parameters
- processRecord() method builds a filter expression out of the passed process record and ties it up with the previous expressions with "or" operator
- finalizeProcess() method assigns the whole filter expression to the given target symbol.