Learn to configure the <filter_value_transform>
element for Pull Reports™ Ad Hoc
report and data service software.
Catalog Configuration Java API analog:
ColumnConfigurationBuilder#setFilterValueTransform
,
A <filter_value_transform>
contains a template to transform the
value when filtering on the parent <column>
in the Export Report REST API via database functions and/or operations.
Within the template, use the required ?
to reference the parameter value
just as one would in a SQL where
clause.
See also: <filter_column_transform>
To understand a <filter_value_transform>
, first understand how a <column>
configuration relates to a the Export Report REST API filter
parameter
without a <filter_value_transform>
.
Given this <column>
definition,
<table id="mytable" name="mytable" displayName="My Table"> <column id="foo" name="foo" displayName="Foo"/> </table>
and this Export Report REST API filter parameter,
&filter=/mytable@foo+like+'bar%'
the generated SQL where
clause associated with the filter is:
t0.foo like ?
However, after the addition a <filter_value_transform>
like so,
<table id="mytable" name="mytable" displayName="My Table"> <column id="foo" name="foo" displayName="Foo"> <filter_value_transform>lower(?)</filter_value_transform> </column> </table>
the generated SQL where clause becomes:
t0.foo like lower(?)
The <filter_value_transform>
transforms
the value reference in the filter from ?
to lower(?)
.
Since the value of <filter_value_transform>
is placed directly
within the SQL statement, be sure that all functions and operators are compatible with the underlying database,
and it is free from SQL injection risk.
<filter_value_transform>
s and the resulting SQLReport XML | Filter | Example SQL |
---|---|---|
<table id="table" displayName="Table" name="tname"> <column id="full_name" name="complete_name" displayName="Full Name"> <filter_column_transform> lower(${this}) </filter_column_transform> <filter_value_transform> lower('%' || ? || '%') </filter_value_transform> </column> </table> | @full_name like 'jack' | select t0.complete_name as t0_full_name from tname as t0 where |
This advanced example uses the OpenGIS Simple Features
<table id="table" displayName="Table" name="tname"> <column id="latitude" name="point_geom" displayName="Latitude"> <output_transform> ST_Y(${this}) </output_transform> <filter_column_transform> ST_Y(${this}) </filter_column_transform> <filter_value_transform> ST_Y(ST_GeomFromText(?)) </filter_value_transform> </column> </table> | @latitude > 'POINT(-100,40)' | select ST_Y(t0.point_geom) as t0_latitude from tname as t0
where |
<column>
|