BAEL-803: Backward Chaining with Drools - parent module (#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
This commit is contained in:
parent
8df4293b68
commit
f96548363e
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>drools-backward-chaining</artifactId>
|
<artifactId>drools-backward-chaining</artifactId>
|
||||||
|
@ -17,7 +16,6 @@
|
||||||
<properties>
|
<properties>
|
||||||
<runtime.version>6.4.0.Final</runtime.version>
|
<runtime.version>6.4.0.Final</runtime.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.kie</groupId>
|
<groupId>org.kie</groupId>
|
||||||
|
@ -26,7 +24,6 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.drools</groupId>
|
<groupId>org.drools</groupId>
|
||||||
<artifactId>drools-core</artifactId>
|
|
||||||
<version>${runtime.version}</version>
|
<version>${runtime.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -35,4 +32,4 @@
|
||||||
<version>${runtime.version}</version>
|
<version>${runtime.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -21,13 +21,11 @@ public class BackwardChaining {
|
||||||
KieSession ksession = kContainer.newKieSession("ksession-backward-chaining");
|
KieSession ksession = kContainer.newKieSession("ksession-backward-chaining");
|
||||||
ksession.setGlobal("result", result);
|
ksession.setGlobal("result", result);
|
||||||
ksession.insert(new Fact("Asia", "Planet Earth"));
|
ksession.insert(new Fact("Asia", "Planet Earth"));
|
||||||
// ksession.insert(new Fact("China", "Asia"));
|
// ksession.insert(new Fact("China", "Asia"));
|
||||||
ksession.insert(new Fact("Great Wall of China", "China"));
|
ksession.insert(new Fact("Great Wall of China", "China"));
|
||||||
|
|
||||||
ksession.fireAllRules();
|
ksession.fireAllRules();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.baeldung
|
||||||
|
|
||||||
|
import com.baeldung.drools.model.Fact;
|
||||||
|
|
||||||
|
global com.baeldung.drools.model.Result result;
|
||||||
|
|
||||||
|
dialect "mvel"
|
||||||
|
|
||||||
|
query belongsTo(String x, String y)
|
||||||
|
Fact(x, y;)
|
||||||
|
or
|
||||||
|
(Fact(z, y;) and belongsTo(x, z;))
|
||||||
|
end
|
||||||
|
|
||||||
|
rule "Great Wall of China BELONGS TO Planet Earth"
|
||||||
|
when
|
||||||
|
belongsTo("Great Wall of China", "Planet Earth";)
|
||||||
|
then
|
||||||
|
result.setValue("Decision one taken: Great Wall of China BELONGS TO Planet Earth");
|
||||||
|
end
|
||||||
|
|
||||||
|
rule "print all facts"
|
||||||
|
when
|
||||||
|
belongsTo(element, place;)
|
||||||
|
then
|
||||||
|
result.addFact(element + " IS ELEMENT OF " + place);
|
||||||
|
end
|
|
@ -7,6 +7,8 @@
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>drools</artifactId>
|
<artifactId>drools</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
|
|
Loading…
Reference in New Issue