Skip to content

Commit f965483

Browse files
felipeazvadamd1985
authored andcommitted
BAEL-803: Backward Chaining with Drools - parent module (eugenp#2986)
* spring beans DI examples * fix-1: shortening examples * List of Rules Engines in Java * BAEL-812: Openl-Tablets example added * BAEL-812: artifacts names changed * BAEL-812: moving rule-engines examples to rule-engines folder * BAEL-812: removing evaluation article files * BAEL-812: folder renamed * BAEL-812: folder renamed * BAEL-812: pom.xml - parent added * BAEL-1027: Introduction to GraphQL - initial commit * BAEL-781: Explore the new Spring Cloud Gateway * BAEL-781: Fix UserService.java * BAEL-781: Fix user-service pom.xml * BAEL-781: remove eureka-server from the example * BAEL-781: modifying example * BAEL-803: Backward Chaining wih Drools * BAEL-803: pom.xml * BAEL-803: Backward Chaining with Drools - new example * BAEL-803: Backward Chaining with Drools - parent module * BAEL-803: Backward Chaining with Drools - parent module * BAEL-803: Backward Chaining with Drools - meta-inf/maven-fix * BAEL-803: Backward Chaining with Drools - drools parent module
1 parent 8df4293 commit f965483

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

‎drools/backward-chaining/pom.xml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4-
54
<modelVersion>4.0.0</modelVersion>
65

76
<artifactId>drools-backward-chaining</artifactId>
@@ -17,7 +16,6 @@
1716
<properties>
1817
<runtime.version>6.4.0.Final</runtime.version>
1918
</properties>
20-
2119
<dependencies>
2220
<dependency>
2321
<groupId>org.kie</groupId>
@@ -26,7 +24,6 @@
2624
</dependency>
2725
<dependency>
2826
<groupId>org.drools</groupId>
29-
<artifactId>drools-core</artifactId>
3027
<version>${runtime.version}</version>
3128
</dependency>
3229
<dependency>
@@ -35,4 +32,4 @@
3532
<version>${runtime.version}</version>
3633
</dependency>
3734
</dependencies>
38-
</project>
35+
</project>

‎drools/backward-chaining/src/main/java/com/baeldung/drools/BackwardChaining.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ public Result backwardChaining() {
2121
KieSession ksession = kContainer.newKieSession("ksession-backward-chaining");
2222
ksession.setGlobal("result", result);
2323
ksession.insert(new Fact("Asia", "Planet Earth"));
24-
// ksession.insert(new Fact("China", "Asia"));
24+
// ksession.insert(new Fact("China", "Asia"));
2525
ksession.insert(new Fact("Great Wall of China", "China"));
2626

2727
ksession.fireAllRules();
2828

2929
return result;
30-
3130
}
32-
3331
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.baeldung
2+
3+
import com.baeldung.drools.model.Fact;
4+
5+
global com.baeldung.drools.model.Result result;
6+
7+
dialect "mvel"
8+
9+
query belongsTo(String x, String y)
10+
Fact(x, y;)
11+
or
12+
(Fact(z, y;) and belongsTo(x, z;))
13+
end
14+
15+
rule "Great Wall of China BELONGS TO Planet Earth"
16+
when
17+
belongsTo("Great Wall of China", "Planet Earth";)
18+
then
19+
result.setValue("Decision one taken: Great Wall of China BELONGS TO Planet Earth");
20+
end
21+
22+
rule "print all facts"
23+
when
24+
belongsTo(element, place;)
25+
then
26+
result.addFact(element + " IS ELEMENT OF " + place);
27+
end

‎drools/pom.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<groupId>com.baeldung</groupId>
88
<artifactId>drools</artifactId>
99
<version>1.0.0-SNAPSHOT</version>
10+
11+
<packaging>pom</packaging>
1012

1113
<parent>
1214
<groupId>com.baeldung</groupId>

0 commit comments

Comments
 (0)