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:
felipeazv 2017-11-09 12:04:37 +01:00 committed by adamd1985
parent 8df4293b68
commit f96548363e
4 changed files with 31 additions and 7 deletions

View File

@ -1,7 +1,6 @@
<?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"
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>
<artifactId>drools-backward-chaining</artifactId>
@ -17,7 +16,6 @@
<properties>
<runtime.version>6.4.0.Final</runtime.version>
</properties>
<dependencies>
<dependency>
<groupId>org.kie</groupId>
@ -26,7 +24,6 @@
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${runtime.version}</version>
</dependency>
<dependency>
@ -35,4 +32,4 @@
<version>${runtime.version}</version>
</dependency>
</dependencies>
</project>
</project>

View File

@ -21,13 +21,11 @@ public class BackwardChaining {
KieSession ksession = kContainer.newKieSession("ksession-backward-chaining");
ksession.setGlobal("result", result);
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.fireAllRules();
return result;
}
}

View File

@ -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

View File

@ -7,6 +7,8 @@
<groupId>com.baeldung</groupId>
<artifactId>drools</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>com.baeldung</groupId>