Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PTL-1546 criteria matching #1987

Merged
merged 13 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
title: 'Criteria builder'
sidebar_label: 'Criteria builder'
id: criteria-builder
keywords: [foundation, ui, comms, resource, criteria, filtering, formatters, groovy, filtering, charts, grids]
tags:
- connected
- ui
- comms
- criteria
- resource
- filtering
- formatters
- groovy
- filtering
- charts
- grids
---

The [CriteriaBuilder](./docs/api/foundation-criteria.criteriabuilder.md) is a utility class designed to build objects used in creating query criteria in a Groovy expression format. These criteria can be used in requests to backend services.

## Methods

:::info

The examples for these methods use a simple expression which checks `TRADE_ID` equals a certain value.

```ts
const tradeIdEqualsExpression = new ExpressionBuilder()
.withField('TRADE_ID')
.withValue('TR1234')
.withSerialiser(Serialisers.EQ)
.build()
```
:::


<table>
patrickoneill-genesis marked this conversation as resolved.
Show resolved Hide resolved
<thead>
<tr>
<th>Method</th>
<th>Description</th>
<th>Params</th>
<th>Return value</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>withExpression</td>
<td>Sets an expression in the criteria</td>
<td>ValidExpressionType, ExpressionOptions, Join (default Join.And)</td>
<td>CriteriaBuilder</td>
<td>

```ts
new CriteriaBuilder().withExpression(tradeIdEqualsExpression)
```

</td>
</tr>
<tr>
<td>And</td>
<td>Sets an expression with an And clause</td>
<td>ValidExpressionType, ExpressionOptions</td>
<td>CriteriaBuilder</td>
<td>

```ts
new CriteriaBuilder()
.And(tradeIdEqualsExpression)
```

</td>
</tr>
<tr>
<td>Or</td>
<td>Sets an expression with an Or clause</td>
<td>ValidExpressionType, ExpressionOptions</td>
<td>CriteriaBuilder</td>
<td>

```ts
new CriteriaBuilder().OR(tradeIdEqualsExpression)
```

</td>
</tr>
<tr>
<td>Not</td>
<td>Sets an expression with a Not clause</td>
<td>ValidExpressionType, ExpressionOptions</td>
<td>CriteriaBuilder</td>
<td>

```ts
new CriteriaBuilder().NOT(tradeIdEqualsExpression)
```

</td>
</tr>
<tr>
<td>Build</td>
<td>Creates a string representation of based on the set expressions in the object</td>
<td>none</td>
<td>string</td>
<td>

```ts
new CriteriaBuilder()
.withExpression(tradeIdEqualsExpression)
.build();
```

</td>
</tr>
</tbody>
</table>

patrickoneill-genesis marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: 'Expression builder'
sidebar_label: 'Expression builder'
id: expression-builder
keywords: [foundation, ui, comms, resource, criteria, filtering, formatters, groovy, filtering, charts, grids]
tags:
- connected
- ui
- comms
- criteria
- resource
- filtering
- formatters
- groovy
- filtering
- charts
- grids
---

The [ExpressionBuilder](./docs/api/foundation-criteria.expressionbuilder.md) is a utility class to build criteria objects that are used with the `CriteriaBuilder`

## Methods

<table>
patrickoneill-genesis marked this conversation as resolved.
Show resolved Hide resolved
<thead>
<tr>
<th>Method</th>
<th>Description</th>
<th>Params</th>
<th>Return value</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>withField</td>
<td>Sets the field in the expression object</td>
<td>string</td>
<td>ExpressionBuilder</td>
<td>

```ts
new ExpressionBuilder().withField('TRADE_ID')
```

</td>
</tr>
<tr>
<td>withValue</td>
<td>Sets the value the expression is tested against</td>
<td>unknown (can be string, boolean or number)</td>
<td>ExpressionBuilder</td>
<td>

```ts
new ExpressionBuilder().withValue('TR_1234') //checking a string
new ExpressionBuilder().withValue(500) //checking a number
new ExpressionBuilder().withValue(boolean) //checking a boolean
```

</td>
</tr>
<tr>
<td>withSerialiser</td>
<td>Sets the serialiser type on the expression</td>
<td>Serialiser</td>
<td>ExpressionBuilder</td>
<td>

```ts
new ExpressionBuilder().withSerialiser(Serialiser.EQ) // testing equals
new ExpressionBuilder().withSerialiser(Serialiser.GT) // testing greater than
new ExpressionBuilder().withSerialiser(Serialiser.GE) // testing greater
new ExpressionBuilder().withSerialiser(Serialiser.LT) // testing less than
new ExpressionBuilder().withSerialiser(Serialiser.LE) // testing less
```

</td>
</tr>
<tr>
<td>withGroup</td>
<td>ToDo What does group do</td>
<td>string</td>
<td>ExpressionBuilder</td>
<td>

```ts
new ExpressionBuilder().withGroup('group')
```

</td>
</tr>
<tr>
<td>Build</td>
<td>Creates an Expression object based on the values sret</td>
<td>none</td>
<td>Expression</td>
<td>

```ts
new ExpressionBuilder().build();
```

</td>
</tr>
</tbody>
</table>
Loading