Skip to content

Commit

Permalink
Add documentation on fn:filter RQL functions
Browse files Browse the repository at this point in the history
Signed-off-by: David Schwilk <david.schwilk@bosch.io>
  • Loading branch information
DerSchwilk committed Feb 11, 2022
1 parent 2a54748 commit b96807e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions documentation/src/main/resources/pages/ditto/basic-placeholders.md
Expand Up @@ -195,12 +195,28 @@ The following functions are provided by Ditto out of the box:

| Name | Signature | Description | Examples |
|-----------------------|------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| `fn:filter` | `(String filterValue, String rqlFunction, String comparedValue)` | Removes the result of the previous expression in the pipeline unless the condition specified by the parameters is satisfied.<br/>The first parameter `filterValue` may also be omitted in which case the 2 passed parameters will be appplied on the previous pipeline expression. | `fn:filter('ne','blocklist1|foobar|exclude')` <br/>`fn:filter(header:response-required,'eq','true')` <br/> `fn:filter(header:response-required,'exists')` <br/> `fn:filter(header:response-required,'exists','false')` |
| `fn:filter` | `(String filterValue, String rqlFunction, String comparedValue)` | Removes the result of the previous expression in the pipeline unless the condition specified by the parameters is satisfied.<br/>The first parameter `filterValue` may also be omitted in which case the 2 passed parameters will be appplied on the previous pipeline expression. | `fn:filter('like','allowlist1|foobar|include')` <br/>`fn:filter(header:response-required,'eq','true')` <br/> `fn:filter(header:response-required,'exists')` <br/> `fn:filter(header:response-required,'exists','false')` |
| `fn:default` | `(String defaultValue)` | Provides the passed `defaultValue` when the previous expression in a pipeline resolved to `empty` (e.g. due to a non-defined `header` placeholder key).<br/>Another placeholder may be specified which is resolved to a String and inserted as `defaultValue`. | `fn:default('fallback')`<br/>`fn:default("fallback")`<br/>`fn:default(thing:id)` |
| `fn:substring-before` | `(String givenString)` | Parses the result of the previous expression and passes along only the characters _before_ the first occurrence of `givenString`.<br/>If `givenString` is not contained, this function will resolve to `empty`. | `fn:substring-before(':')`<br/>`fn:substring-before(":")` |
| `fn:substring-after` | `(String givenString)` | Parses the result of the previous expression and passes along only the characters _after_ the first occurrence of `givenString`.<br/>If `givenString` is not contained, this function will resolve to `empty`. | `fn:substring-after(':')`<br/>`fn:substring-after(":")` |
| `fn:lower` | `()` | Makes the String result of the previous expression lowercase in total. | `fn:lower()` |
| `fn:upper` | `()` | Makes the String result of the previous expression uppercase in total. | `fn:upper()` |
| `fn:delete` | `()` | Deletes the result of the previous pipeline expression unconditionally. | `fn:delete()` |
| `fn:replace` | `(String from, String to)` | Replaces a string with another using Java's `String::replace` method. | `fn:replace('foo', 'bar')` |
| `fn:split` | `(String separator)` | Splits the previous pipeline using the passed `separator` resulting an "array" pipeline output containing several elements.<br/>May only be used in combination with the [JWT placeholder](#scope-openid-connect-configuration) as input placeholder. | `fn:split(' ')`<br/>`fn:split(',')` |
| `fn:split` | `(String separator)` | Splits the previous pipeline using the passed `separator` resulting an "array" pipeline output containing several elements.<br/>May only be used in combination with the [JWT placeholder](#scope-openid-connect-configuration) as input placeholder. | `fn:split(' ')`<br/>`fn:split(',')` |

### RQL functions

The following RQL functions are available for `fn:filter`

| Name | Signatures | Description |
|-----------------------|--------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `eq` | `(String filterValue, 'eq', String comparedValue)`, <br/>`('eq', String comparedValue)` | If 3 parameters are passed in, the function filters on the first parameter being equal to the last. <br/>If 2 parameters are passed in, the function filters the previous pipeline element being equal to the last parameter. |
| `ne` | `(String filterValue, 'ne', String comparedValue)`, <br/>`('ne', String comparedValue)` | If 3 parameters are passed in, the function filters on the first parameter being not equal to the last. <br/>If 2 parameters are passed in, the function filters the previous pipeline element being not equal to the last parameter. |
| `exists` | `(String filterValue, 'exists', String true|false)`, <br/>`('exists', String true/false)`, <br/>`('exists')` | If 3 parameters are passed in, the function filters on the first parameter being existent/non-existent. <br/>If 2 parameters are passed in, the function filters the previous pipeline element being being existent/non-existent. <br/>If 1 parameter is passed in, the function filters the previous pipeline element being true. |
| `like` | `(String filterValue, 'like', String regex)`, <br/>`('like', String regex)` | If 3 parameters are passed in, the function filters on the first parameter matching the last. <br/>If 2 parameters are passed in, the function filters the previous pipeline element matching the last parameter. |

The `like` function can be used with different expressions:
* `*` : One or more arbitrary characters
* `?` : One arbitrary character
* `|` : Element prior to the operator OR element after the operator

0 comments on commit b96807e

Please sign in to comment.