### started by() Function Examples
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Demonstrates the usage of the 'started by' function for temporal comparisons between ranges.
```FEEL
started by( (1..10], (1..5] ) = true
```
```FEEL
started by( [1..10], (1..5] ) = false
```
```FEEL
started by( (1..10], [1..5] ) = false
```
```FEEL
started by( [1..10], [1..10] ) = true
```
```FEEL
started by( [1..10], [1..10) ) = true
```
```FEEL
started by( (1..10), (1..10) ) = true
```
--------------------------------
### get entries() Function Example
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Extracts all key-value pairs from a context into a list of contexts.
```FEEL
get entries( {key1 : "value1", key2 : "value2"} ) = [ { key : "key1", value : "value1" }, {key : "key2", value : "value2"} ]
```
--------------------------------
### Before Range Function Examples
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Provides examples of the 'before' function for comparing points and ranges.
```FEEL
before( 1, 10 ) = true
before( 10, 1 ) = false
before( 1, [1..10] ) = false
before( 1, (1..10] ) = true
before( 1, [5..10] ) = true
before( [1..10], 10 ) = false
before( [1..10), 10 ) = true
before( [1..10], 15 ) = true
before( [1..10], [15..20] ) = true
before( [1..10], [10..20] ) = false
before( [1..10), [10..20] ) = true
before( [1..10], (10..20] ) = true
```
--------------------------------
### Start Kafka Instance with Docker Compose
Source: https://github.com/apache/incubator-kie-drools/blob/main/drools-quarkus-extension/drools-quarkus-examples/drools-quarkus-examples-reactive/README.md
Use this command to start a dedicated Kafka instance for testing purposes using Docker Compose.
```bash
docker-compose up -d
```
```bash
docker compose up -d
```
--------------------------------
### get value() Function Examples
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Retrieves a value from a context using a specified key. Returns null if the key does not exist.
```FEEL
get value( {key1 : "value1"}, "key1" ) = "value1"
```
```FEEL
get value( {key1 : "value1"}, "unexistent-key" ) = null
```
--------------------------------
### started by
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Checks if the first temporal interval started at or before the second temporal interval started, and if the first temporal interval ended at or after the second temporal interval ended.
```APIDOC
## started by( interval1, interval2 )
### Description
Checks if the first temporal interval started at or before the second temporal interval started, and if the first temporal interval ended at or after the second temporal interval ended.
### Parameters
#### Path Parameters
- **interval1** (temporal interval) - Required - The first temporal interval.
- **interval2** (temporal interval) - Required - The second temporal interval.
### Examples
[source,FEEL]
----
started by( (1..10], (1..5] ) = true
started by( [1..10], (1..5] ) = false
started by( (1..10], [1..5] ) = false
started by( [1..10], [1..10] ) = true
started by( [1..10], [1..10) ) = true
started by( (1..10), (1..10) ) = true
----
```
--------------------------------
### FEEL TestRig Example with Echo Command
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/README.md
Provides a complete example of using the FEELTestRig by first creating an input file with 'echo' and then executing the Java command to parse it. This illustrates a typical testing workflow.
```Shell
echo "sum(1+2)" > target/input.txt
java -cp "target/*:target/dependency/*" org.kie.dmn.feel.parser.feel11.FEELTestRig FEEL_1_1 compilation_unit -gui target/input.txt
```
--------------------------------
### starts
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Evaluates if an element A starts an element B, considering specific requirements.
```APIDOC
## starts
### Description
Returns `true` when an element `A` starts an element `B` and when the relevant requirements for evaluating to `true` are also met.
### Signatures
- `starts( point, range )`
- `starts( range1, range2 )`
### Requirements for evaluating to `true`
- `range.start = point and range.start included`
- `range1.start = range2.start and range1.start included = range2.start included and ( range1.end < range2.end or (range1.end = range2.end and (not(range1.end included) or range2.end included)) )`
### Examples
[source,FEEL]
----
starts( 1, [1..10] ) = true
starts( 1, (1..10] ) = false
starts( 2, [1..10] ) = false
starts( [1..5], [1..10] ) = true
starts( (1..5], (1..10] ) = true
starts( (1..5], [1..10] ) = false
starts( [1..5], (1..10] ) = false
starts( [1..10], [1..10] ) = true
starts( [1..10), [1..10] ) = true
starts( (1..10), (1..10) ) = true
----
```
--------------------------------
### Maven Invoker Plugin Setup Configuration
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-maven-plugin/IntegrationTests.md
Configuration within kie-maven-plugin/pom.xml to ensure setup modules are invoked before other integration tests.
```xml
maven-invoker-plugin
kie-maven-plugin-test-kjar-setup/pom.xml
*/pom.xml
```
--------------------------------
### started by
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Evaluates if an element A is started by an element B, considering specific requirements.
```APIDOC
## started by
### Description
Returns `true` when an element `A` is started by an element `B` and when the relevant requirements for evaluating to `true` are also met.
### Signatures
- `started by( range, point )`
- `started by( range1, range2 )`
### Requirements for evaluating to `true`
- `range.start = point and range.start included`
- `range1.start = range2.start and range1.start included = range2.start included and ( range2.end < range1.end or (range2.end = range1.end and (not(range2.end included) or range1.end included)) )`
### Examples
[source,FEEL]
----
started by( [1..10], 1 ) = true
started by( (1..10], 1 ) = false
started by( [1..10], 2 ) = false
started by( [1..10], [1..5] ) = true
----
```
--------------------------------
### Meets Range Function Examples
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Demonstrates the 'meets' function for checking if the end of one range meets the start of another.
```FEEL
meets( [1..5], [5..10] ) = true
meets( [1..5), [5..10] ) = false
meets( [1..5], (5..10] ) = false
meets( [1..5], [6..10] ) = false
```
--------------------------------
### starts() Function in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Use `starts()` to verify if a point matches the start of a range or if one range begins at the same point as another. For point comparisons, the point must be exactly the start of the range and included. For range comparisons, the start points must match and be included, with further checks on end points.
```FEEL
starts( 1, [1..10] ) = true
starts( 1, (1..10] ) = false
starts( 2, [1..10] ) = false
starts( [1..5], [1..10] ) = true
starts( (1..5], (1..10] ) = true
starts( (1..5], [1..10] ) = false
starts( [1..5], (1..10] ) = false
starts( [1..10], [1..10] ) = true
starts( [1..10), [1..10] ) = true
starts( (1..10), (1..10) ) = true
```
--------------------------------
### started by() Function in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Use `started by()` to check if a range is started by a specific point or if one range is started by another. The point must be the start of the range and included. For range comparisons, start points and their inclusivity must match, with additional conditions on end points.
```FEEL
started by( [1..10], 1 ) = true
started by( (1..10], 1 ) = false
started by( [1..10], 2 ) = false
started by( [1..10], [1..5] ) = true
```
--------------------------------
### Example XLS2DMN CLI Execution
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-xls2dmn-cli/README.md
Example of running the XLS2DMN CLI utility to convert an Excel file named 'Loan_approvals.xlsx' into a DMN model. The output file will be named 'Loan_approvals.xlsx.dmn'.
```bash
java -jar kie-dmn-xls2dmn-cli-7.57.0.Final.jar Loan_approvals.xlsx
```
--------------------------------
### String Conversion Examples
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Demonstrates converting different types to string representation. Null values are converted to null.
```FEEL
string( 1.1 ) = "1.1"
string( null ) = null
```
--------------------------------
### Build KieModule and Get AnalysisModel
Source: https://github.com/apache/incubator-kie-drools/blob/main/drools-impact-analysis/README.md
Set up KieFileSystem and build all assets. This process generates an ImpactAnalysisKieModule from which the AnalysisModel can be retrieved.
```java
// set up KieFileSystem
...
KieBuilder kieBuilder = KieServices.Factory.get().newKieBuilder(kfs).buildAll(ImpactAnalysisProject.class);
ImpactAnalysisKieModule analysisKieModule = (ImpactAnalysisKieModule) kieBuilder.getKieModule();
AnalysisModel analysisModel = analysisKieModule.getAnalysisModel();
```
--------------------------------
### starts with
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Returns true if the string starts with the match.
```APIDOC
## starts with( string, match )
### Description
Returns `true` if the string starts with the match.
### Parameters
#### Path Parameters
- **string** (string) - Required - The string to check.
- **match** (string) - Required - The substring to check for at the beginning.
### Request Example
```feel
starts with( "testing", "te" )
```
### Response
#### Success Response (boolean)
- `true` if the string starts with the match, `false` otherwise.
### Response Example
```feel
true
```
```
--------------------------------
### Time Addition Example
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Demonstrates adding a duration to a time value in FEEL.
```FEEL
time( "23:59:00z" ) + duration( "PT2M" ) = time( "00:01:00@Etc/UTC" )
```
--------------------------------
### After Range Function Examples
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Illustrates the 'after' function for comparing points and ranges.
```FEEL
after( 10, 5 ) = true
after( 5, 10 ) = false
after( 12, [1..10] ) = true
after( 10, [1..10) ) = true
after( 10, [1..10] ) = false
after( [11..20], 12 ) = false
after( [11..20], 10 ) = true
after( (11..20], 11 ) = true
after( [11..20], 11 ) = false
after( [11..20], [1..10] ) = true
after( [1..10], [11..20] ) = false
after( [11..20], [1..11) ) = true
after( (11..20], [1..11] ) = true
```
--------------------------------
### Create KiePMMLSimplePredicate Examples
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-pmml-trusty/kie-pmml-models/kie-pmml-models-tree/kie-pmml-models-tree-compiler/src/test/resources/KiePMMLNodeFactoryTest_01.txt
These snippets show how to build individual KiePMMLSimplePredicate instances for various comparison operators and values. They are used to define simple conditions on data fields.
```java
KiePMMLSimplePredicate predicate_0 = KiePMMLSimplePredicate
.builder("temperature", Collections.emptyList(), org.kie.pmml.api.enums.OPERATOR.GREATER_THAN)
.withValue(60.0)
.build();
```
```java
KiePMMLSimplePredicate predicate_1 = KiePMMLSimplePredicate
.builder("temperature", Collections.emptyList(), org.kie.pmml.api.enums.OPERATOR.LESS_THAN)
.withValue(100.0)
.build();
```
```java
KiePMMLSimplePredicate predicate_2 = KiePMMLSimplePredicate
.builder("outlook", Collections.emptyList(), org.kie.pmml.api.enums.OPERATOR.EQUAL)
.withValue("overcast")
.build();
```
```java
KiePMMLSimplePredicate predicate_3 = KiePMMLSimplePredicate
.builder("humidity", Collections.emptyList(), org.kie.pmml.api.enums.OPERATOR.LESS_THAN)
.withValue(70.0)
.build();
```
```java
KiePMMLSimplePredicate predicate_4 = KiePMMLSimplePredicate
.builder("windy", Collections.emptyList(), org.kie.pmml.api.enums.OPERATOR.EQUAL)
.withValue("false")
.build();
```
--------------------------------
### Exponentiation Function Example
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Shows how to use the exp function to calculate Euler's number raised to a given power.
```FEEL
decimal( exp( 5 ), 2 ) = 148.41
```
--------------------------------
### Decimal Function Example
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Demonstrates the usage of the decimal function to round a number to a specified number of decimal places.
```FEEL
decimal( log( 10 ), 2 ) = 2.30
```
--------------------------------
### sort() Function Example
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Sorts a list based on a provided precedes function.
```FEEL
sort( list: [3,1,4,5,2], precedes: function(x,y) x < y ) = [1,2,3,4,5]
```
--------------------------------
### Square Root Function Example in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Demonstrates the `sqrt` function, which returns the square root of a given number.
```FEEL
sqrt( 16 ) = 4
```
--------------------------------
### get entries
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Returns a list of key-value pairs for the specified context.
```APIDOC
## get entries( m )
### Description
Returns a list of key-value pairs for the specified context.
### Parameters
#### Path Parameters
- **m** (context) - Required - The context to retrieve entries from.
### Example
[source,FEEL]
----
get entries( {key1 : "value1", key2 : "value2"} ) = [ { key : "key1", value : "value1" }, {key : "key2", value : "value2"} ]
----
```
--------------------------------
### Round Up Function Examples in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Demonstrates the `round up` function for rounding a number up to a specified scale. If either input is null, the result is null.
```FEEL
round up( 5.5, 0 ) = 6
round up( -5.5, 0 ) = -6
round up( 1.121, 2 ) = 1.13
round up( -1.126, 2 ) = -1.13
```
--------------------------------
### coincides() Function Examples
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Illustrates the 'coincides' function for checking if two points or ranges are identical.
```FEEL
coincides( 5, 5 ) = true
```
```FEEL
coincides( 3, 4 ) = false
```
```FEEL
coincides( [1..5], [1..5] ) = true
```
```FEEL
coincides( (1..5), [1..5] ) = false
```
```FEEL
coincides( [1..5], [2..6] ) = false
```
--------------------------------
### Create KiePMMLCompoundPredicate Example
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-pmml-trusty/kie-pmml-models/kie-pmml-models-tree/kie-pmml-models-tree-compiler/src/test/resources/KiePMMLNodeFactoryTest_01.txt
This snippet demonstrates how to construct a KiePMMLCompoundPredicate by combining multiple KiePMMLSimplePredicate instances using a boolean operator. This is useful for creating complex logical conditions.
```java
KiePMMLCompoundPredicate predicate = KiePMMLCompoundPredicate
.builder(Collections.emptyList(), org.kie.pmml.api.enums.BOOLEAN_OPERATOR.AND)
.withKiePMMLPredicates(Arrays.asList(predicate_0, predicate_1, predicate_2, predicate_3, predicate_4))
.build();
```
--------------------------------
### Modulo Function Examples in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Shows the `modulo` function, which returns the remainder of a division. The sign of the result matches the sign of the divisor. Handles both integer and decimal inputs.
```FEEL
modulo( 12, 5 ) = 2
modulo( -12,5 )= 3
modulo( 12,-5 )= -3
modulo( -12,-5 )= -2
modulo( 10.1, 4.5 )= 1.1
modulo( -10.1, 4.5 )= 3.4
modulo( 10.1, -4.5 )= -3.4
modulo( -10.1, -4.5 )= -1.1
```
--------------------------------
### Floor Function Examples in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Illustrates the `floor` function, which returns the number rounded down to the nearest integer or to a specified scale. Handles null inputs by returning null.
```FEEL
floor( 1.5 ) = 1
floor( -1.56, 1 ) = -1.6
floor( -1.5 ) = -2
```
--------------------------------
### Ceiling Function Examples in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Shows the `ceiling` function, which returns the number rounded up to the nearest integer or to a specified scale. Returns null if either input is null.
```FEEL
ceiling( 1.5 ) = 2
ceiling( -1.56, 1 ) = -1.5
ceiling( -1.5 ) = -1
```
--------------------------------
### Logarithm Function Example in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Illustrates the `log` function, which returns the logarithm of a specified number. The specific base of the logarithm is not detailed in this snippet.
```FEEL
log( 100 ) = 2
```
--------------------------------
### Display Command Line Utility Help
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-ruleset2dmn-parent/README.md
Execute the JAR file with the --help option to view available command-line arguments and usage instructions.
```sh
java -jar kie-dmn-ruleset2dmn-cli-8.24.0-SNAPSHOT.jar --help
```
--------------------------------
### Round Half Up Function Examples in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Shows the `round half up` function, which rounds a number to the nearest value, with halves rounded up. Handles null inputs by returning null.
```FEEL
round half up( 5.5, 0 ) = 6
round half up( -5.5, 0 ) = -6
round half up( 1.121, 2 ) = 1.12
round half up( -1.126, 2 ) = -1.13
```
--------------------------------
### Load and Use Knowledge Resources from Classpath
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-api/src/main/javadoc/overview.html
Demonstrates loading knowledge resources like rules and processes from the classpath using KieServices and KieContainer. Ensure META-INF/kmodule.xml is present for configuration.
```java
KieServices kieServices = KieServices.Factory.get();
KieContainer kieContainer = kieServices.getKieClasspathContainer();
KieSession kieSession = kieContainer.newKieSession();
try {
kieSession.insert(new Fibonacci(10));
kieSession.fireAllRules();
} finally {
kieSession.dispose();
}
```
--------------------------------
### Context Creation and Manipulation
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Demonstrates how to create a context from a list of key-value pairs. Handles cases with duplicate keys and missing values.
```FEEL
context([{key:"a", value:1}, {key:"b", value:2}]) = {a:1, b:2}
```
```FEEL
context([{key:"a", value:1}, {key:"b", value:2, something: "else"}]) = {a:1, b:2}
```
```FEEL
context([{key:"a", value:1}, {key:"b"}]) = null
```
--------------------------------
### Substring Extraction
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Extracts a portion of a string starting from a specified position. The start position is 1-based. Negative start positions count from the end of the string.
```FEEL
substring( "testing",3 ) = "sting"
substring( "testing",3,3 ) = "sti"
substring( "testing", -2, 1 ) = "n"
substring( "\U01F40Eab", 2 ) = "ab"
```
--------------------------------
### Removed Class Example
Source: https://github.com/apache/incubator-kie-drools/blob/main/script/ci/tests/scenarios-compute-build-scopes/08-combined-mixed-changes/changed-files.txt
An example of a class that has been removed from the project. This serves as a placeholder or historical reference.
```java
package org.example;
public class RemovedClass {
// This class has been removed.
}
```
--------------------------------
### Test PMML Compiler (No Provider)
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-pmml-trusty/kie-pmml-compiler/kie-pmml-compiler-core/Readme.md
Test the PMML compiler by running its main class without any specific algorithm providers available. This is expected to result in a 'No provider found' message.
```bash
java -cp ./kie-pmml-commons/target/kie-pmml-commons-7.32.0-SNAPSHOT.jar:./kie-pmml-marshaller/target/kie-pmml-marshaller-7.32.0-SNAPSHOT.jar:./kie-pmml-compiler/target/kie-pmml-compiler-7.32.0-SNAPSHOT.jar org.kie.pmml.compiler.Main (No provider found expected)
```
--------------------------------
### sublist(list, start position, length)
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Extracts a portion of a list, starting from a specified position and with an optional length.
```APIDOC
## sublist(list, start position, length?)
### Description
Returns the sublist from the start position, limited to the length elements. The `length` parameter is optional.
### Parameters
#### Path Parameters
- **list** (list) - Required - The list from which to extract a sublist.
- **start position** (number) - Required - The starting index (1-based) of the sublist.
- **length** (number) - Optional - The number of elements to include in the sublist.
### Request Example
```feel
sublist( [4,5,6], 1, 2 )
```
### Response
#### Success Response (list)
- A new list containing the specified elements.
#### Response Example
```feel
[4,5]
```
```
--------------------------------
### overlaps after
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Checks if range1 overlaps with range2, specifically when range1 starts within or at the start of range2 and ends after or at the same point as range2.
```APIDOC
## overlaps after( range1, range2 )
### Description
Returns `true` when an element `A` overlaps after an element `B` and when the relevant requirements for evaluating to `true` are also met.
### Requirements for evaluating to `true`
- `( range2.start < range1.start or (range2.start = range1.start and range2.start included and not( range1.start included)) ) and ( range2.end > range1.start or (range2.end = range1.start and range2.end included and range1.start included) ) and ( range2.end < range1.end or (range2.end = range1.end and (not(range2.end included) or range1.end included)) )`
### Examples
```FEEL
overlaps after( [3..8], [1..5] )= true
overlaps after( [6..8], [1..5] )= false
overlaps after( [5..8], [1..5] )= true
overlaps after( (5..8], [1..5] )= false
overlaps after( [5..8], [1..5) )= false
overlaps after( (1..5], [1..5) )= true
overlaps after( (1..5], [1..5] )= true
overlaps after( [1..5], [1..5) )= false
overlaps after( [1..5], [1..5] )= false
overlaps after( (1..5), [1..5] )= false
overlaps after( (1..5], [1..6] )= false
overlaps after( (1..5], (1..5] )= false
overlaps after( (1..5], [2..5] )= false
```
```
--------------------------------
### Build KiePMMLTargetValue
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-pmml-trusty/kie-pmml-compiler/kie-pmml-compiler-commons/src/test/resources/KiePMMLTargetValueFactoryTest_01.txt
Demonstrates how to build a KiePMMLTargetValue using its builder pattern. This is useful for creating target value configurations within the Kie PMML framework.
```java
KiePMMLTargetValue.builder("%s", Collections.emptyList(), new TargetValue("%s", "%s", %s, %s))
.build()
```
--------------------------------
### substring( string, start position, length? )
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Returns the substring from the start position for the specified length. The first character is at position value `1`.
```APIDOC
## substring( string, start position, length? )
### Description
Returns the substring from the start position for the specified length. The first character is at position value `1`.
### Parameters
#### Path Parameters
- **string** (string) - Required - The string to extract a substring from.
- **start position** (number) - Required - The position of the first character to include (1-based index).
- **length** (number) - Optional - The number of characters to include in the substring.
### Request Example
```feel
substring( "testing",3 ) = "sting"
substring( "testing",3,3 ) = "sti"
substring( "testing", -2, 1 ) = "n"
substring( "\U01F40Eab", 2 ) = "ab"
```
Note: In FEEL, the string literal `"\U01F40Eab"` is the `🐎ab` string (horse symbol followed by `a` and `b`).
```
--------------------------------
### overlaps before() Function in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Use the `overlaps before` function to check if the first range overlaps with the second range, specifically when the first range starts before or at the same point as the second range and ends after the second range's start.
```FEEL
overlaps before( [1..5], [3..8] ) = true
overlaps before( [1..5], [6..8] ) = false
overlaps before( [1..5], [5..8] ) = true
overlaps before( [1..5], (5..8] ) = false
overlaps before( [1..5), [5..8] ) = false
overlaps before( [1..5), (1..5] ) = true
overlaps before( [1..5], (1..5] ) = true
overlaps before( [1..5), [1..5] ) = false
overlaps before( [1..5], [1..5] ) = false
```
--------------------------------
### met by() Function in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Use the `met by` function to check if two ranges meet each other. The start of the first range must be included, the end of the second range must be included, and the start of the first range must equal the end of the second range.
```FEEL
met by( [5..10], [1..5] ) = true
met by( [5..10], [1..5) ) = false
met by( (5..10], [1..5] ) = false
met by( [6..10], [1..5] ) = false
```
--------------------------------
### FEEL TestRig with Text File Input
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/README.md
Demonstrates launching the FEELTestRig with ANTLR's 'grun' to parse FEEL expressions from a text file. This is an alternative to standard input for testing.
```Java
java -cp "target/*:target/dependency/*" org.kie.dmn.feel.parser.feel11.FEELTestRig FEEL_1_1 compilation_unit -gui input.txt
```
--------------------------------
### get value
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Returns the value from the context for the specified entry key.
```APIDOC
## get value( m, key )
### Description
Returns the value from the context for the specified entry key.
### Parameters
#### Path Parameters
- **m** (context) - Required - The context to retrieve the value from.
- **key** (string) - Required - The key of the entry.
### Examples
[source,FEEL]
----
get value( {key1 : "value1"}, "key1" ) = "value1"
get value( {key1 : "value1"}, "unexistent-key" ) = null
----
```
--------------------------------
### Create KiePMMLCompoundPredicate
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-pmml-trusty/kie-pmml-compiler/kie-pmml-compiler-commons/src/test/resources/KiePMMLCompoundPredicateFactoryTest_01.txt
Demonstrates building a KiePMMLCompoundPredicate by combining simple predicates and a simple set predicate. Use this when you need to define compound logic for PMML models.
```java
KiePMMLSimplePredicate %1$s_0 = KiePMMLSimplePredicate.builder("PARAM_1", Collections.emptyList(), org.kie.pmml.api.enums.OPERATOR.EQUAL)
.withValue(100.0)
.build();
KiePMMLSimplePredicate %1$s_1 = KiePMMLSimplePredicate.builder("PARAM_2", Collections.emptyList(), org.kie.pmml.api.enums.OPERATOR.GREATER_THAN)
.withValue(5.0)
.build();
KiePMMLSimpleSetPredicate %1$s_2 = KiePMMLSimpleSetPredicate.builder("SIMPLESETPREDICATENAME", Collections.emptyList(),
org.kie.pmml.api.enums.ARRAY_TYPE.STRING, org.kie.pmml.api.enums.IN_NOTIN.IN)
.withValues(Arrays.asList(%2$s))
.build();
KiePMMLCompoundPredicate %1$s = KiePMMLCompoundPredicate.builder(Collections.emptyList(), %3$s)
.withKiePMMLPredicates(Arrays.asList(%1$s_0, %1$s_1, %1$s_2))
.build();
```
--------------------------------
### during() Function in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Use `during()` to check if a point falls within a range or if one range is temporally during another. The point must be between the range's start and end, respecting inclusivity. For range comparisons, the second range must be fully contained within the first, considering start and end boundaries.
```FEEL
during( 5, [1..10] ) = true
during( 12, [1..10] ) = false
during( 1, [1..10] ) = true
during( 10, [1..10] ) = true
during( 1, (1..10] ) = false
during( 10, [1..10) ) = false
during( [4..6], [1..10] ) = true
during( [1..5], [1..10] ) = true
during( (1..5], (1..10] ) = true
during( (1..10), [1..10] ) = true
during( [5..10), [1..10) ) = true
during( [1..10), [1..10] ) = true
during( (1..10], [1..10] ) = true
during( [1..10], [1..10] ) = true
```
--------------------------------
### Create KiePMMLTransformationDictionary
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-pmml-trusty/kie-pmml-compiler/kie-pmml-compiler-commons/src/test/resources/KiePMMLModelFactoryUtilsTest_01.txt
This method constructs a KiePMMLTransformationDictionary, demonstrating the initialization of various PMML transformation functions like CONSTANT, FIELDREF, APPLY, and TEXT_INDEX_NORMALIZATION.
```java
private org.kie.pmml.commons.transformations.KiePMMLTransformationDictionary createTransformationDictionary() {
KiePMMLParameterField CONSTANT_FUNCTION_0 = KiePMMLParameterField.builder("empty", Collections.emptyList()).withDataType(null).withOpType(null).withDisplayName(null).build();
KiePMMLConstant CONSTANT_FUNCTION_Expression = new KiePMMLConstant("CONSTANT_FUNCTION_Expression", Collections.emptyList(), "CONSTANT_FUNCTION_VALUE", null);
KiePMMLDefineFunction CONSTANT_FUNCTION = new KiePMMLDefineFunction("CONSTANT_FUNCTION", Collections.emptyList(), org.kie.pmml.api.enums.DATA_TYPE.STRING, org.kie.pmml.api.enums.OP_TYPE.CATEGORICAL, Arrays.asList(CONSTANT_FUNCTION_0), CONSTANT_FUNCTION_Expression);
KiePMMLParameterField FIELDREF_FUNCTION_0 = KiePMMLParameterField.builder("fieldRed", Collections.emptyList()).withDataType(null).withOpType(null).withDisplayName(null).build();
KiePMMLFieldRef FIELDREF_FUNCTION_Expression = new KiePMMLFieldRef("Petal.Length", Collections.emptyList(), null);
KiePMMLDefineFunction FIELDREF_FUNCTION = new KiePMMLDefineFunction("FIELDREF_FUNCTION", Collections.emptyList(), org.kie.pmml.api.enums.DATA_TYPE.DOUBLE, org.kie.pmml.api.enums.OP_TYPE.CONTINUOUS, Arrays.asList(FIELDREF_FUNCTION_0), FIELDREF_FUNCTION_Expression);
KiePMMLParameterField APPLY_FUNCTION_0 = KiePMMLParameterField.builder("fieldRed", Collections.emptyList()).withDataType(null).withOpType(null).withDisplayName(null).build();
KiePMMLFieldRef APPLY_FUNCTION_Expression_0 = new KiePMMLFieldRef("Petal.Length", Collections.emptyList(), null);
KiePMMLApply APPLY_FUNCTION_Expression = KiePMMLApply.builder("APPLY_FUNCTION_Expression", Collections.emptyList(), "FIELDREF_FUNCTION").withDefaultValue(null).withMapMissingTo(null).withInvalidValueTreatmentMethod("returnInvalid").withKiePMMLExpressions(Arrays.asList(APPLY_FUNCTION_Expression_0)).build();
KiePMMLDefineFunction APPLY_FUNCTION = new KiePMMLDefineFunction("APPLY_FUNCTION", Collections.emptyList(), org.kie.pmml.api.enums.DATA_TYPE.DOUBLE, org.kie.pmml.api.enums.OP_TYPE.CONTINUOUS, Arrays.asList(APPLY_FUNCTION_0), APPLY_FUNCTION_Expression);
KiePMMLParameterField TEXT_INDEX_NORMALIZATION_FUNCTION_0 = KiePMMLParameterField.builder("reviewText", Collections.emptyList()).withDataType(null).withOpType(null).withDisplayName(null).build();
KiePMMLParameterField TEXT_INDEX_NORMALIZATION_FUNCTION_1 = KiePMMLParameterField.builder("term", Collections.emptyList()).withDataType(null).withOpType(null).withDisplayName(null).build();
KiePMMLFieldRef TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_Expression = new KiePMMLFieldRef("term", Collections.emptyList(), null);
Map TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_0_columnValues = Stream.of(new Object[][] { { "regex", "true" }, { "string", "interfaces?" }, { "stem", "interface" } }).collect(Collectors.toMap(data -> (String) data[0], data -> data[1]));
KiePMMLRow TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_0 = new KiePMMLRow(TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_0_columnValues);
Map TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_1_columnValues = Stream.of(new Object[][] { { "regex", "true" }, { "string", "is|are|seem(ed|s?)|were" }, { "stem", "be" } }).collect(Collectors.toMap(data -> (String) data[0], data -> data[1]));
KiePMMLRow TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_1 = new KiePMMLRow(TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_1_columnValues);
Map TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_2_columnValues = Stream.of(new Object[][] { { "regex", "true" }, { "string", "user friendl(y|iness)" }, { "stem", "user_friendly" } }).collect(Collectors.toMap(data -> (String) data[0], data -> data[1]));
KiePMMLRow TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_2 = new KiePMMLRow(TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_2_columnValues);
KiePMMLInlineTable TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable = new KiePMMLInlineTable("TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable", Collections.emptyList(), Arrays.asList(TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_0, TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_1, TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable_2));
KiePMMLTextIndexNormalization TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0 = KiePMMLTextIndexNormalization.builder("TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0", Collections.emptyList()).withInField("string").withOutField("stem").withKiePMMLInlineTable(TEXT_INDEX_NORMALIZATION_FUNCTION_Expression_0_InlineTable).withRegexField("regex").withRecursive(false).withIsCaseSensitive(false).withMaxLevenshteinDistance(null).withWordSeparatorCharacterRE(null).withTokenize(false).build();
return null;
}
```
--------------------------------
### Build KiePMMLMiningField with Target Field Usage
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-pmml-trusty/kie-pmml-compiler/kie-pmml-compiler-commons/src/test/resources/KiePMMLMiningFieldFactoryTest_01.txt
Demonstrates building a KiePMMLMiningField with specific configurations including TARGET field usage type and a data type. Use this to define a target field in a PMML model.
```java
KiePMMLMiningField %s = KiePMMLMiningField.builder("%s", Collections.emptyList())
.withFieldUsageType(org.kie.pmml.api.enums.FIELD_USAGE_TYPE.TARGET)
.withOpType(null)
.withDataType(%s)
.withMissingValueTreatmentMethod(null)
.withInvalidValueTreatmentMethod(org.kie.pmml.api.enums.INVALID_VALUE_TREATMENT_METHOD.RETURN_INVALID)
.withMissingValueReplacement(null)
.withInvalidValueReplacement(null)
.withAllowedValues(Arrays.asList())
.withIntervals(Arrays.asList())
.build();
```
--------------------------------
### month of year() Function Example
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Retrieves the month of the year for a given date.
```FEEL
month of year( date(2019, 9, 17) ) = "September"
```
--------------------------------
### Create KiePMMLTargets for Testing
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-pmml-trusty/kie-pmml-compiler/kie-pmml-compiler-commons/src/test/resources/KiePMMLModelFactoryUtilsTest_10.txt
This Java method generates a list of `KiePMMLTarget` objects. It's used in test scenarios to provide sample target configurations for PMML models. The method initializes `TargetField` objects with various parameters, including field names, types, and other attributes.
```java
private static List getCreatedKiePMMLTargets() {
List toReturn = new ArrayList();
toReturn.add(KiePMMLTarget.builder("%s", Collections.emptyList(), new TargetField(Arrays.asList(), %s, "Target-0", %s, %s, %s, %s, %s)).build());
toReturn.add(KiePMMLTarget.builder("%s", Collections.emptyList(), new TargetField(Arrays.asList(), %s, "Target-1", %s, %s, %s, %s, %s)).build());
toReturn.add(KiePMMLTarget.builder("%s", Collections.emptyList(), new TargetField(Arrays.asList(), %s, "Target-2", %s, %s, %s, %s, %s)).build());
return toReturn;
}
```
--------------------------------
### day of week() Function Example
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Determines the day of the week for a given date.
```FEEL
day of week( date(2019, 9, 17) ) = "Tuesday"
```
--------------------------------
### day of year() Function Example
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Calculates the day of the year for a given date.
```FEEL
day of year( date(2019, 9, 17) ) = 260
```
--------------------------------
### Java - Create KiePMMLCharacteristic Factory Method
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-pmml-trusty/kie-pmml-models/kie-pmml-models-scorecard/kie-pmml-models-scorecard-compiler/src/test/resources/KiePMMLCharacteristicsFactoryTest_01.txt
This Java method demonstrates how to build a KiePMMLCharacteristic object. It includes creating nested predicates, apply expressions, and attributes, showcasing the construction of a characteristic with a baseline score and reason code.
```java
private static KiePMMLCharacteristic get%1$s() {
KiePMMLSimplePredicate %1$s_0_Predicate = KiePMMLSimplePredicate.builder("input1", Collections.emptyList(), org.kie.pmml.api.enums.OPERATOR.GREATER_THAN).withValue(-1000.0).build();
KiePMMLFieldRef %1$s_0_ComplexPartialScore_0_0 = new KiePMMLFieldRef("input1", Collections.emptyList(), null);
KiePMMLFieldRef %1$s_0_ComplexPartialScore_0_1 = new KiePMMLFieldRef("input2", Collections.emptyList(), null);
KiePMMLApply %1$s_0_ComplexPartialScore_0 = KiePMMLApply.builder("%1$s_0_ComplexPartialScore_0", Collections.emptyList(), "+").withDefaultValue(null).withMapMissingTo(null).withInvalidValueTreatmentMethod("returnInvalid").withKiePMMLExpressions(Arrays.asList(%1$s_0_ComplexPartialScore_0_0, %1$s_0_ComplexPartialScore_0_1)).build();
KiePMMLComplexPartialScore %1$s_0_ComplexPartialScore = new KiePMMLComplexPartialScore("%1$s_0_ComplexPartialScore", Collections.emptyList(), %1$s_0_ComplexPartialScore_0);
KiePMMLAttribute %1$s_0 = KiePMMLAttribute.builder("%1$s_0", Collections.emptyList(), %1$s_0_Predicate).withPartialScore(null).withComplexPartialScore(%1$s_0_ComplexPartialScore).build();
KiePMMLTruePredicate %1$s_1_Predicate = new KiePMMLTruePredicate("%1$s_1_Predicate", Collections.emptyList());
KiePMMLAttribute %1$s_1 = KiePMMLAttribute.builder("%1$s_1", Collections.emptyList(), %1$s_1_Predicate).withPartialScore(25).withComplexPartialScore(null).build();
KiePMMLCharacteristic %1$s = KiePMMLCharacteristic.builder("%1$s", Collections.emptyList(), Arrays.asList(%1$s_0, %1$s_1)).withBaselineScore(20).withReasonCode("characteristic1ReasonCode").build();
return %1$s;
}
```
--------------------------------
### met by
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Checks if one range is met by another, considering start and end inclusion.
```APIDOC
## met by( range1, range2 )
### Description
Returns `true` when an element `A` is met by an element `B` and when the relevant requirements for evaluating to `true` are also met.
### Requirements for evaluating to `true`
- `range1.start included and range2.end included and range1.start = range2.end`
### Examples
```FEEL
met by( [5..10], [1..5] ) = true
met by( [5..10], [1..5) ) = false
met by( (5..10], [1..5] ) = false
met by( [6..10], [1..5] ) = false
```
```
--------------------------------
### includes() Function in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Use `includes()` to determine if a range contains a specific point or if one range is contained within another. For point inclusion, check if the point falls within the range's start and end, considering inclusivity. For range inclusion, both start and end points must be within the bounds of the containing range.
```FEEL
includes( [1..10], 5 ) = true
includes( [1..10], 12 ) = false
includes( [1..10], 1 ) = true
includes( [1..10], 10 ) = true
includes( (1..10], 1 ) = false
includes( [1..10), 10 ) = false
includes( [1..10], [4..6] ) = true
includes( [1..10], [1..5] ) = true
includes( (1..10], (1..5] ) = true
includes( [1..10], (1..10) ) = true
includes( [1..10), [5..10) ) = true
includes( [1..10], [1..10) ) = true
includes( [1..10], (1..10] ) = true
includes( [1..10], [1..10] ) = true
```
--------------------------------
### Full Maven Build Command
Source: https://github.com/apache/incubator-kie-drools/blob/main/script/ci/tests/scenarios-summary/01-no-tests-no-scope/expected-summary.md
Use this command to perform a full Maven build. It ensures batch mode, no transfer progress, fails at the end, and redirects test output to files.
```bash
mvn --batch-mode --no-transfer-progress -fae -Dsurefire.redirectTestOutputToFile=true install
```
--------------------------------
### Decimal Rounding Examples in FEEL
Source: https://github.com/apache/incubator-kie-drools/blob/main/kie-dmn/kie-dmn-feel/ref-dmn-feel-builtin-functions.adoc
Demonstrates the `decimal` function for rounding numbers to a specified scale, consistent with FEEL's definition of rounding to the nearest even decimal number.
```FEEL
decimal( 1/3, 2 ) = .33
decimal( 1.5, 0 ) = 2
decimal( 2.5, 0 ) = 2
decimal( 1.035, 2 ) = 1.04
decimal( 1.045, 2 ) = 1.04
decimal( 1.055, 2 ) = 1.06
decimal( 1.065, 2 ) = 1.06
```