From 311b8c892129771ff2f22fd11f70d493c83d3a41 Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 02:49:02 -0400
Subject: [PATCH 01/16] Typos and tweaks
Capitalization, punctuation, spelling for readability. Added a link as it wasn't clear to me which one went to the right place.
---
README.md | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index a38da68..c03c8a9 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,23 @@
# Intended audience
-This book as its title suggest is for newcomers to drools. As explained in the drools tutorial, when using drools you will change the classical development paradigm you are using going from procedurale to declarative programming. The shift is not complex to accomplish but there is a need for a onboarding set of tutorials that will help you to jump into implementing algorith/business rules wiht drools with no difficulty.
-As a regular trainer of drools, I can only encourage you to do the exercices completely by yourself and try not to go the solutions directly.
+This book, as its title suggests, is for newcomers to drools. As explained in the drools tutorial, when using drools you will change the classical development paradigm you are using, going from procedural to declarative programming. The shift is not complex to accomplish, but there is a need for an onboarding set of tutorials that will help you to jump into implementing algorithm/business rules with drools with no difficulty.
+As a regular trainer of drools, I can only encourage you to do the exercises completely by yourself and try not to go the solutions directly.
By doing so, the learning curve will be a little longer but so much easier at the end. By going directly to the solution, you will miss 50% of the training content.
# drools On Boarding
-You can find here all the materials that goes with this book.
+You can find here all the materials that go with this book.
The book is also on github [ here ](https://github.com/nheron/droolsonboarding).
-Here is the [content](SUMMARY.md) of the book
+Here is the [content](SUMMARY.md) of the book.
## How to edit the docs
-* go to [Drools Onboarding book](https://www.gitbook.com/book/nheron/droolsonboarding/details)
-* There you can clone and edit the document
-* You can do it from github also
+* Go to [Drools Onboarding book](https://www.gitbook.com/book/nheron/droolsonboarding/details).
+* There you can clone and edit the document.
+* You can do it from [github](https://github.com/nheron/droolsonboarding) also.
## How to run the tutorial and examples
-* the source code for the tutorials and examples can be found on [github](https://github.com/nheron/droolscourse)
-* there is a virtual box appliance available with all included that you can find here \(TODO\)
+* The source code for the tutorials and examples can be found on [github](https://github.com/nheron/droolscourse).
+* There is a virtual box appliance available with all included that you can find here. \(TODO\)
From 40b96738768d5639d272b511272779a15c401608 Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 02:55:02 -0400
Subject: [PATCH 02/16] Typos and tweaks
---
overview/overview.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/overview/overview.md b/overview/overview.md
index c1f483c..bb7d49c 100644
--- a/overview/overview.md
+++ b/overview/overview.md
@@ -3,13 +3,13 @@
-Software programmers are used to a procedural approach when it comes to implement Business requirements. The consequence is that the business rule implementation solely depends on the competence and understanding the software developer has of the Business Rules he has to implement.
-This limitation was already seen and identified by researches. Object oriented programming may be seen as "the solution" to business implementation and agility and many developers rely on this paradigm. At the end, Object oriented approach ends up with the classical ["Spaghetti code"](https://en.wikipedia.org/wiki/Spaghetti_code).
+Software programmers are used to a procedural approach when it comes to implementing Business requirements. The consequence is that the business rule implementation solely depends on the competence and understanding the software developer has of the Business Rules he has to implement.
+This limitation was already seen and identified by researchers. Object oriented programming may be seen as "the solution" to business implementation and agility and many developers rely on this paradigm. At the end, the Object oriented approach ends up with the classic ["Spaghetti code"](https://en.wikipedia.org/wiki/Spaghetti_code).
To avoid this ending, a new approach was taken called "[declarative programming](https://en.wikipedia.org/wiki/Declarative_programming)".
This is a big shift and we shall try to focus on that before learning the tooling around drools.
-- the first set of tutorials called "drools tutorials" start from the base concepts (there are few and is concentrated on the the core engine) up to more language concepts
-- the second set of tutorials called "BRMS tutorial" will introduce the the management tooling (called workbench) around the lifecycle of the rule artifact. but the workbench also introduces more artifacts type like decision table, rule templates, etc.. that will help when modeling business requirements.
-- the third set of tutorials called "BRMS runtime tutorials" start to introduce possible software architectures in a real project. In the examples parts, we will use ideas that we describe in that part.
+- The first set of tutorials, called "drools tutorials", start from the base concepts (there are few and is concentrated on the the core engine) up to more language concepts
+- The second set of tutorials, called "BRMS tutorials", will introduce the the management tooling (called workbench) around the lifecycle of the rule artifact. But the workbench also introduces more artifact types like decision table, rule templates, etc.. That will help when modeling business requirements.
+- The third set of tutorials, called "BRMS runtime tutorials", start to introduce possible software architectures in a real project. In the examples parts, we will use ideas that we describe in that part.
From 34e4633f17817c9b6361ea3430ca7bdbb68f593e Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 02:57:45 -0400
Subject: [PATCH 03/16] Missing period
---
overview/overview.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/overview/overview.md b/overview/overview.md
index bb7d49c..35ca7ca 100644
--- a/overview/overview.md
+++ b/overview/overview.md
@@ -7,7 +7,7 @@ Software programmers are used to a procedural approach when it comes to implemen
This limitation was already seen and identified by researchers. Object oriented programming may be seen as "the solution" to business implementation and agility and many developers rely on this paradigm. At the end, the Object oriented approach ends up with the classic ["Spaghetti code"](https://en.wikipedia.org/wiki/Spaghetti_code).
To avoid this ending, a new approach was taken called "[declarative programming](https://en.wikipedia.org/wiki/Declarative_programming)".
This is a big shift and we shall try to focus on that before learning the tooling around drools.
-- The first set of tutorials, called "drools tutorials", start from the base concepts (there are few and is concentrated on the the core engine) up to more language concepts
+- The first set of tutorials, called "drools tutorials", start from the base concepts (there are few and is concentrated on the the core engine) up to more language concepts.
- The second set of tutorials, called "BRMS tutorials", will introduce the the management tooling (called workbench) around the lifecycle of the rule artifact. But the workbench also introduces more artifact types like decision table, rule templates, etc.. That will help when modeling business requirements.
- The third set of tutorials, called "BRMS runtime tutorials", start to introduce possible software architectures in a real project. In the examples parts, we will use ideas that we describe in that part.
From 93d959029be9a8bce469e65dde89ad2cc9b2a14c Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 03:01:15 -0400
Subject: [PATCH 04/16] Typos and tweaks
---
gettingStarted/drools.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gettingStarted/drools.md b/gettingStarted/drools.md
index 50d03ce..ed270d2 100644
--- a/gettingStarted/drools.md
+++ b/gettingStarted/drools.md
@@ -1,12 +1,12 @@
When working with drools, there are things you have to define :
-1\) The data model on which the rules applies. As we are working in the java language, a data model is a set of java classes.
+1\) The data model on which the rules apply. As we are working in the Java language, a data model is a set of Java classes.
-2\) Rules which are going on one side \(called left side or LHS\) express constraints on the data model, which here class name and their attributes and on the other side \(called right side or RHS\) which will act on the facts which are in the working memory.
+2\) Rules which are going on one side \(called left side or LHS\) express constraints on the data model, which are class name and their attributes and on the other side \(called right side or RHS\) which will act on the facts which are in the working memory.
-When you want to apply some rules on some data, you will instantiate a java class and give it to the rule engine. This instance is called a Fact object.
+When you want to apply some rules on some data, you will instantiate a Java class and give it to the rule engine. This instance is called a Fact object.
-To work with the rule engine, we have to instantiate a KieContainer. We will see later how to program it. This kieContainer contains a set of rules. The KieContainer allows also to contain other types of artifacts are is common to other components like jbpm and optoplanner.
+To work with the rule engine, we have to instantiate a KieContainer. We will see later how to program it. This KieContainer contains a set of rules. The KieContainer allows also to contain other types of artifacts that are common to other components like jbpm and optoplanner.
When you want to work with drools, you have to get a KieSession from the KieContainer. This KieSession will allow you to give facts to the rule engine and to ask to fire rules.
From 751b0c97fa95d6dde719c05cdbdc92c9ba2e0531 Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 03:12:32 -0400
Subject: [PATCH 05/16] Capitalization and tweaks
---
gettingStarted/installing_drools_tooling.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gettingStarted/installing_drools_tooling.md b/gettingStarted/installing_drools_tooling.md
index f26bc92..b7e18e0 100644
--- a/gettingStarted/installing_drools_tooling.md
+++ b/gettingStarted/installing_drools_tooling.md
@@ -7,11 +7,11 @@ To be able to work with drools, we need :
## Install Java Virtual Machine
-Drools is working with either Oracle Java machine or OpenJDK. With the drools version we have, we can have java version 7 or 8.
+Drools works with either Oracle Java machine or OpenJDK. With the drools version we have, we can have Java version 7 or 8.
## Install Eclipse IDE
-After installing java, we can install [eclipse](http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/mars2).
+After installing Java, we can install [eclipse](http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/mars2).
## Download drools tooling
@@ -23,15 +23,15 @@ You have to unzip the file. In the directory droolsjbpm-tools-distribution-6.5.0
Go to File/New/Other

-then push on next
+then push on next.

-Select the middle button and push next
+Select the middle button and push next.

-Enter "FirstProject" as a project name and keep only the "Add a sample Helloworld rule file to this project". the generated project should look like that:
+Enter "FirstProject" as a project name and keep only the "Add a sample Helloworld rule file to this project". The generated project should look like this:

-If you do with the right mouse on DroolsTest class and run as "java Program", the following should be displayed on the console view
+If you click with the right mouse button on DroolsTest class and run as "Java Program", the following should be displayed on the console view

All is well installed.
From 6fc7567edf27356eea2ffbfb1768ba0f5c51c04c Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 03:15:20 -0400
Subject: [PATCH 06/16] Typo
---
gettingStarted/installing_drools_tooling.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gettingStarted/installing_drools_tooling.md b/gettingStarted/installing_drools_tooling.md
index b7e18e0..079edfa 100644
--- a/gettingStarted/installing_drools_tooling.md
+++ b/gettingStarted/installing_drools_tooling.md
@@ -19,7 +19,7 @@ To be able to use drools in eclipse, we need to download the [Drools and jbpm To
You have to unzip the file. In the directory droolsjbpm-tools-distribution-6.5.0.Final/binaries/org.drools.updatesite/ is the update site from where you have to install new Software.
-## Create you first project
+## Create your first project
Go to File/New/Other

From ae75e422dcf80e8ae4205fc91763b452252b5bcc Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 06:08:08 -0400
Subject: [PATCH 07/16] Typos and tweaks
---
.../data_model_used_in_the_tutorial.md | 58 +++++++++----------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/gettingStarted/data_model_used_in_the_tutorial.md b/gettingStarted/data_model_used_in_the_tutorial.md
index 19d92a6..7957a9f 100644
--- a/gettingStarted/data_model_used_in_the_tutorial.md
+++ b/gettingStarted/data_model_used_in_the_tutorial.md
@@ -1,7 +1,7 @@
# Data Model used in the tutorial
-We are first going to write java code that we are going to use through all the drooks tutorial.
-Here is the model we are going to use \(taken from presentation done during conferences by drools members\)
+We are first going to write Java code that we are going to use through all the drools tutorial.
+Here is the model we are going to use \(taken from presentations done during conferences by drools members\).
We are in a bank that handles accounts \(2\) and on each account there can be movements \(1\). The purpose is to calculate the account balance between an accounting period \(3\) of all accounts given the movements it has.
We will run all examples in junit Tests.
This data model is the same as you can find in the reference model in the drools documentation.
@@ -9,12 +9,12 @@ This data model is the same as you can find in the reference model in the drools
## Implement the pojo model
-We have to create an AccountProject of type drools as previously describes.
-Then we shall create a java package that we can name droolscours package in src/main/java \(to respect maven definition\) by doing on src/main/java right click and new Package, gibe him a name and push the finish button.
+We have to create an AccountProject of type drools as previously described.
+Then we shall create a java package that we can name droolscourse package in src/main/java \(to respect maven definition\) by doing on src/main/java a right click and New Package, give it a name and push the Finish button.

-and we are going to create 3 java classes : Account, AccountingPeriod and CashFlow by right-clicking on the new package just created and new Class
+And we are going to create 3 java classes: Account, AccountingPeriod and CashFlow by right-clicking on the new package just created and New Class.

@@ -31,7 +31,7 @@ and for CashFlow

-# Add JUnit library
+## Add JUnit library
To be able to use junit, we have to add the junit library.
Select the project, right click and select BuildPath/Configure BuildPath
@@ -40,71 +40,71 @@ Select the project, right click and select BuildPath/Configure BuildPath
Click on the Libraries tab and select the "Add library" button.

-Select the Junit library and push the next button
+Select the Junit library and push the Next button.

-On the next screen, push the Finish Button
+On the next screen, push the Finish button

-and the the Ok button
+and the the Ok button.

-The Junit libray is now part of the project
+The Junit libray is now part of the project.

-We now have to create some directory.
-Select the src directory and right click button new Directory.
+We now have to create a directory.
+Right click on the src directory and click New Directory.

-Enter test/java in the folder name and press finish.
-Do the same but test/rules.
-The folder part should look like that :
+Enter test/java in the folder name and press Finish.
+Do the same with test/rules.
+The folder part should look like this:

-now Select src/test/java and right click buildpath/use as source folder
+Now right click src/test/java and click Buildpath/Use as source folder.

-Do the same with src/test/rules
-now the project should look like this :
+Do the same with src/test/rules and
+now the project should look like this:

-# Create a Helper Class
+## Create a Helper Class
To simplify the writing of tests, we shall write a helper class.
-To do, we first create a package called util and in there create a class that we shall all KnowledgeSessionHelper
+To do this, we first create a package called util and in there create a class that we shall call KnowledgeSessionHelper .


-Then create a new class called KnowledgeSessionHelper
+Then create a new class called KnowledgeSessionHelper .


-In the Class, the content should look like here
+In the class, the content should look like here

-# Create the first test case
+## Create the first test case
-Select the src/test/java package and Right click Other and type junit. Select Junit Test case
+Right click the src/test/java package, click Other and type junit. Select JUnit Test Case.

Push the next Button.
-In the next screen, enter droolscours as package name and FirstTry as Name
+In the next screen, enter droolscourse as the package name and FirstTry as the Name.

-And push the Finish Button
+And push the Finish Button.
-the code should be entered like this :
+The code should be entered like this :

-Select the open class, Right click and run as JUnit Test :
+Select the open class, right click and run as JUnit Test :

-And the Junit Window should appear as above. \(of course no rules were fired\).
+And the JUnit window should appear as above. \(of course no rules were fired\).
We are now ready to start the lessons.
From 6b8d99541ac4049bd3b3df4f2788e931717ec3de Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 07:28:04 -0400
Subject: [PATCH 08/16] Typos and tweaks
---
gettingStarted/first_rule_language_element.md | 85 ++++++++++---------
1 file changed, 43 insertions(+), 42 deletions(-)
diff --git a/gettingStarted/first_rule_language_element.md b/gettingStarted/first_rule_language_element.md
index b11c901..9435095 100644
--- a/gettingStarted/first_rule_language_element.md
+++ b/gettingStarted/first_rule_language_element.md
@@ -2,20 +2,20 @@
## What is a rule ?
-In the previously created project, we are going to add a new drl file \(drl = drools rule language\)
-to do so, select src/test/rules and first create a package called lesson1 and the a rule file called "lesson1".
+In the previously created project, we are going to add a new drl file \(drl = drools rule language\).
+To do so, select src/test/rules and first create a package called lesson1 and then a rule file called "lesson1".


-and the select rule Drools/Rule Resource
+And select Drools/Rule Resource.

Enter a rule name and package and press the Finish Button.

-the following element is then displayed : lesson1.drl
+The following element is then displayed : lesson1.drl

@@ -32,11 +32,11 @@ Let's analyse the rule elements:
As any plugin in eclipse, the drools plugin allows auto completion \(ctrl+space\)

-We create a rule the has a condition just a fact of type Account. If the rule is fired, then we shall show the message "The account exists" in the console. Notice that the then part is just pure java.
+We create a rule the has a condition just a fact of type Account. If the rule is fired, then we shall show the message "The account exists" in the console. Notice that the then part is just pure Java.

-Create a junit test called "testLesson1"
+Create a JUnit test called "testLesson1".

@@ -52,9 +52,9 @@ Here we defined a session called "ksession-rules" \(that we use in the test to i
Now you can run the test in TestLesson1 and you should see this:

-It is the message that we have put in the rule "Your first rule"
+It is the message that we have put in the rule "Your first rule".
-Let us add some logging to facilate the output
+Let us add some logging to facilitate the output.
## Using a Global variable to log informations
@@ -70,41 +70,42 @@ To initialize the global variable, we shall use the method setGlobal on the sess

-When running the junit test, the console should look like this :
+When running the JUnit test, the console should look like this:

-## Using callback to log activity in drools runtime
+## Using callbacks to log activity in drools runtime
-Up to known, we only defined one rule. It runs or not and if yes we added a method that shows us something to see if the rule was executed.
-In bigger project, adding logging code to each rule is not a good practice and will complexify the writing of rules and furthermore we are pushing drools to be a business tool for business analyst and they have to write technical code.
-Drools offers a pattern to implement that functionnality that is called session callbacks.
+Up to now, we have only defined one rule. It runs or not and if yes we added a method that shows us something to see if the rule was executed.
+In a bigger project, adding logging code to each rule is not a good practice and will complexify the writing of rules.
+Furthermore we are pushing drools to be a business tool for business analysts and they have to write technical code.
+Drools offers a pattern to implement that functionality that is called session callbacks.
-Drools can be viewed in a synthetic picture like this :
+Drools can be viewed in a synthetic picture like this:

-The production memory contains all the rule definition \(in our case the drl for the moment\).
-The working memory which created with the session and we can add facts to it with the method insert.
+The production memory contains all the rule definitions \(in our case the drl for the moment\).
+The working memory which we created with the session and we can add facts to it with the method insert.
The agenda which contains all the rules that can be fired.
-The pattern Matcher which is the algorithm that is used to match the rules on the facts given. In drools latest version, there are many different algorithm that are used \(The main one is the rete algorithm\).
+The Pattern Matcher which is the algorithm that is used to match the rules on the facts given. In drools latest version, there are many different algorithm that are used \(The main one is the rete algorithm\).
On each of those parts, it is possible to add a callback when we create a Session.

-Each time a fact is inserted,updated or retracted we shall log the event and show it on the console. Here we are using the toString method of the java instance given \(event.getObject\(\).toString\(\)\).
+Each time a fact is inserted, updated or retracted we shall log the event and show it on the console. Here we are using the toString method of the Java instance given \(event.getObject\(\).toString\(\)\).
-We shall add a toString method to all our pojo classes Account, AccountingPeriod and CashFlow. To do so we shall let eclipse generate it for us by right clicking in the source code
+We shall add a toString method to all our POJO classes Account, AccountingPeriod and CashFlow. To do so we shall let eclipse generate it for us by right clicking in the source code.



-Then you should add the following unit test to the TestLesson1 java class
+Then you should add the following unit test to the TestLesson1 Java class.

-And in the console you should see this :
+And in the console you should see this:

-The first line is generated by the first test. To be able to see the difference when a new test is started, we can add the following code to our JUnit test case :
+The first line is generated by the first test. To be able to see the difference when a new test is started, we can add the following code to our JUnit test case:

@@ -113,13 +114,13 @@ and now the console should look like this :;
```
-and then you have to use that facthandle to tell drools the object was updated :
+and then you have to use that facthandle to tell drools the object was updated:
```
a.setBalance(12.0);
@@ -139,13 +140,13 @@ as we call fireAllRules\(\) after we retract the only fact that was in the worki
Let us take an example :

We insert an Account, call FireAllRules and then call a second time fireAllRules on the same session.
-What shall happen ? How many times the rule "Your First Rule revisited" shall be fired ?
+What shall happen? How many times the rule "Your First Rule revisited" shall be fired?
-Here is the result :
+Here is the result:

The rule is fired only once.
-May be it is because we did not modify the Account object ?
+Maybe it is because we did not modify the Account object?
Let us do another example that modifies the account object we pass to the the session.

@@ -155,7 +156,7 @@ Here is the result :
The rule is still not fired a second time. Just modifying the object does not do the job.
-Let us modify the example like this by telling the rule engine we modified the fact :
+Let us modify the example like this by telling the rule engine we modified the fact:

Before calling the second fireAllRules, we tell drools that the fact we inserted before was updated. In our case, we did not modify its data.
@@ -166,19 +167,19 @@ The rule was executed a second time.
Here is what is happening when the FireAllRules method is called on a statefull session :
* drools will look at all rules that can apply and put it in its agenda.
-* drools will execute the rule that is on top of its agenda
-* Once fired, the rule will be deactivated
-* We have to tell drools of a state change in one of facts in the when part \(lhs\) to make him reconsidering the rule.
+* drools will execute the rule that is on top of its agenda.
+* Once fired, the rule will be deactivated.
+* We have to tell drools of a state change in one of the facts in the when part \(lhs\) to make it reconsider the rule.
* A state change can be an insert, update or delete \(retract\).
-In the last example, we tell drools that a fact has been updated
+In the last example, we tell drools that a fact has been updated.
```
sessionStatefull.update(handle, a);
```
So therefore, considering the previously inserted fact has been updated, drools reconsiders the rule.
-As in the rule "Your First Rule revisited" there are no condition on the attributes, the rule is then fired.
+As in the rule "Your First Rule revisited" there are no conditions on the attributes, the rule is then fired.
But we can also do that in the then \(RHS\) part of a rule : insert, update, retract.
@@ -188,30 +189,30 @@ Here is the test case :
Here are the concerned rules.

in the first rule, in the then part we create a new instance of time AccountingPeriod and we use the keyword insert to tell drools to create a new fact.
-As a concequence, the second rule will be executed as the only condition is there is an AccountingPeriod in the working memory.
+As a consequence, the second rule will be executed as the only condition is there is an AccountingPeriod in the working memory.

We see in the logs
-* two first line : an object of type CashFlow was inserted. We did that from the Junit test with the code
+* The first two lines: an object of type CashFlow was inserted. We did that from the Junit test with the code
`FactHandle handlea = sessionStatefull.insert(a);`
-* the third line is generated in the then part of the rule "Your First Rule revisited AccountingPeriod".
+* The third line is generated in the then part of the rule "Your First Rule revisited AccountingPeriod".
-* The fourth and fifth line : an object of type AccountingPeriod was inserted. This was done in the then part of the rule "Your First Rule revisited AccountingPeriod"
+* The fourth and fifth lines: an object of type AccountingPeriod was inserted. This was done in the then part of the rule "Your First Rule revisited AccountingPeriod".
```
AccountingPeriod newPeriod = new AccountingPeriod();
insert (newPeriod);
```
-* the last line is coming from the then part of the rule "Rule on AccountingPeriod that are inserting". Meaning the insered object AccountingPeriod we inserted in the previous rule triggered the second rule.
+* The last line is coming from the then part of the rule "Rule on AccountingPeriod that are inserting". Meaning the AccountingPeriod object we inserted in the previous rule triggered the second rule.
## Summary
-This ends the first lesson where we learned the core concepts needed when working with drools :
-1. What is a rule
-2. A rule with a simple condition
-3. How to log what is happening in the rule engine
+This ends the first lesson, where we learned the core concepts needed when working with drools:
+1. What is a rule?
+2. A rule with a simple condition.
+3. How to log what is happening in the rule engine.
4. What triggers a rule execution and how to interact with the rule engine for fact handling.
From 9362eb931063f59def05712ad81915681e7cccc6 Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 15:01:04 -0400
Subject: [PATCH 09/16] Typos and tweaks
---
gettingStarted/lesson_2__binding.md | 106 ++++++++++++++--------------
1 file changed, 52 insertions(+), 54 deletions(-)
diff --git a/gettingStarted/lesson_2__binding.md b/gettingStarted/lesson_2__binding.md
index 25c91d5..8f3b7b9 100644
--- a/gettingStarted/lesson_2__binding.md
+++ b/gettingStarted/lesson_2__binding.md
@@ -4,7 +4,7 @@
To be able to see what is happening in the rule engine, we shall add to the KnowledgeSessionHelper this method
```
- public static KieSession getStatefulKnowledgeSessionWithCallback(
+ public static KieSession getStatefulKnowledgeSessionWithCallback(
KieContainer kieContainer, String sessionName) {
KieSession session = getStatefulKnowledgeSession(kieContainer, sessionName);
session.addEventListener(new RuleRuntimeEventListener() {
@@ -40,7 +40,7 @@ To be able to see what is happening in the rule engine, we shall add to the Know
public void afterMatchFired(AfterMatchFiredEvent event) {
System.out.println("The rule "
+ event.getMatch().getRule().getName()
- + " has be fired");
+ + " has been fired");
}
public void agendaGroupPopped(AgendaGroupPoppedEvent event) {
}
@@ -55,6 +55,8 @@ To be able to see what is happening in the rule engine, we shall add to the Know
public void afterRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event) {
}
});
+ return session;
+ }
```
In the CashFlow class, we should add the following toString method
```
@@ -62,30 +64,30 @@ In the CashFlow class, we should add the following toString method
import java.text.DateFormat;
public class CashFlow {
- public static int CREDIT = 1;
- public static int DEBIT = 2;
- @Override
+ public static final int CREDIT = 1;
+ public static final int DEBIT = 2;
+
+ @Override
public String toString() {
- // TODO Auto-generated method stub
StringBuffer buff = new StringBuffer();
buff.append("-----CashFlow-----)\n");
buff.append("Account no=" + this.accountNo + "\n");
if (this.mvtDate != null) {
- buff.append("Mouvement Date= "
+ buff.append("Movement Date= "
+ DateFormat.getDateInstance().format(this.mvtDate)
+ "\n");
} else {
- buff.append("No Mouvement date was set\n");
+ buff.append("No Movement date was set\n");
}
- buff.append("Mouvement Amount=" + this.amount + "\n");
+ buff.append("Movement Amount=" + this.amount + "\n");
buff.append("-----CashFlow end--)");
return buff.toString();
}
```
-in the util package, we shall create a DateHelper class that will look like this :
+in the util package, we shall create a DateHelper class that will look like this:
```
@@ -111,7 +113,7 @@ public class DateHelper {
```
-In the kmodule.xml, make it look like that
+In the kmodule.xml, make it look like this
```
@@ -124,15 +126,15 @@ In the kmodule.xml, make it look like that
```
-in the src/test/rules, create a package lesson2 and a rule resource named lesson2.drl and should look like this :
+in the src/test/rules, create a package lesson2 and a rule resource named lesson2.drl and should look like this:
```
-package droolscours
+package droolscourse
//list any import classes here.
-import droolscours.AccountingPeriod;
-import droolscours.CashFlow;
-import droolscours.Account;
+import droolscourse.AccountingPeriod;
+import droolscourse.CashFlow;
+import droolscourse.Account;
import util.OutputDisplay;
global OutputDisplay showResults;
@@ -146,9 +148,9 @@ end
```
-
+In src/tests/java droolscourse create JUnit Test Case TestLesson2, which should look like
```
-package droolscours;
+package droolscourse;
import org.junit.After;
import org.junit.Before;
@@ -211,26 +213,26 @@ So now we know all is working we can continue our lesson.
## Test Case
We are going to implement a test case with the following data :
1) Account with accountno=1
-2) an Accounting period going from January first 2016 to march 31th 2016
-3) 3 Cash Flow movements, credit 1000$ January 15th 2016, debit 500$ February 15th 2016 and a credit movement April 15th 2016 of 1000$.
+2) An Accounting period going from January 1st 2016 to March 31st 2016
+3) 3 Cash Flow movements, credit $1000 January 15th 2016, debit $500 February 15th 2016 and a credit movement April 15th 2016 of $1000.
-The result should be a balance of 500$ for the accounting period.
+The result should be a balance of $500 for the accounting period.
## Fact binding
We want to update the account balance for each CashFlow.
We first put the CashFlow and select all CashFlow of type CREDIT.
-To do so, we add a constraint on the type attribute of java class CashFlow.
+To do so, we add a constraint on the type attribute of Java class CashFlow.

Then we add a second constraint of type Account.
The question is now how in the then part do the balance update.
-It is where the fact binding comes in :
+This is where the fact binding comes in:
```
-package droolscours
+package droolscourse
//list any import classes here.
-import droolscours.AccountingPeriod;
-import droolscours.CashFlow;
-import droolscours.Account;
+import droolscourse.AccountingPeriod;
+import droolscourse.CashFlow;
+import droolscourse.Account;
import util.OutputDisplay;
global OutputDisplay showResults;
@@ -248,11 +250,11 @@ end
```
-In front of the fact, we declare variables $cash and $acc like shown above and then those variables can be used in the then part as normal java variables.
+In front of the fact, we declare variables $cash and $acc like shown above and then those variables can be used in the then part as normal Java variables.
As shown above we can then update the balance.
```
-package droolscours;
+package droolscourse;
import util.OutputDisplay;
@@ -296,20 +298,20 @@ public class TestLesson2 {
sessionStatefull.setGlobal("showResults", display);
Account a = new Account();
a.setAccountNo(1);
- a.setBalance(0);
+ a.setBalance(0.0);
sessionStatefull.insert(a);
CashFlow cash1 = new CashFlow();
cash1.setAccountNo(1);
- cash1.setAmount(1000);
+ cash1.setAmount(1000.0);
cash1.setType(CashFlow.CREDIT);
sessionStatefull.insert(cash1);
sessionStatefull.fireAllRules();
- Assert.assertEquals(a.getBalance(), 1000,0);
+ Assert.assertEquals(1000.0, a.getBalance());
}
}
```
-In the TestTwoFacts test we insert an object of type Account and CashFlow mouvement of type credit. At the end, the balance should be 1000$.
+In the TestTwoFacts test we insert an object of type Account and CashFlow movement of type credit. At the end, the balance should be $1000.
the console should look like this when running the test :

@@ -329,22 +331,22 @@ Let us make now an example with a second CashFlow movement. Here is the test cas
sessionStatefull.setGlobal("showResults", display);
Account a = new Account();
a.setAccountNo(1);
- a.setBalance(0);
+ a.setBalance(0.0);
sessionStatefull.insert(a);
CashFlow cash1 = new CashFlow();
cash1.setAccountNo(1);
- cash1.setAmount(1000);
+ cash1.setAmount(1000.0);
cash1.setMvtDate(DateHelper.getDate("2010-01-15"));
cash1.setType(CashFlow.CREDIT);
sessionStatefull.insert(cash1);
CashFlow cash2 = new CashFlow();
cash2.setAccountNo(2);
- cash2.setAmount(1000);
+ cash2.setAmount(1000.0);
cash2.setMvtDate(DateHelper.getDate("2010-01-15"));
cash2.setType(CashFlow.CREDIT);
sessionStatefull.insert(cash2);
sessionStatefull.fireAllRules();
- Assert.assertEquals(a.getBalance(), 1000,0);
+ Assert.assertEquals(1000.0, a.getBalance());
}
```
@@ -353,8 +355,8 @@ When we run the test case, the test fails :
and in the console, we see that the rule "Credit rule" is running twice :

-The rule was fired twice because there are 2 (CashFlow,Account) couples. The first CashFlow mouvement concerns account number 1 and the seconde account number 2. We need to find a way to link the two facts.
-We shall modify the rule like this :
+The rule was fired twice because there are 2 (CashFlow,Account) couples. The first CashFlow movement concerns account number 1 and the second account number 2. We need to find a way to link the two facts.
+We shall modify the rule like this:
```
package droolscours
@@ -381,33 +383,33 @@ The rule above uses a binding variable. We create an attribute variable called $


-Now the rule "Credit Rule" is only fired once and the balance is corret.
+Now the rule "Credit Rule" is only fired once and the balance is correct.
## Calculating balance
Now we know how to link facts and use attribute variable via binding attributes to use them as constraint, we shall modify the credit rule and create a debit rule :
```
-package cours
+package droolscourse
-import droolscours.Account;
-import droolscours.AccountingPeriod;
-import droolscours.CashFlow;
-import droolscours.util.OutputDisplay;
+import droolscourse.Account;
+import droolscourse.AccountingPeriod;
+import droolscourse.CashFlow;
+import droolscourse.util.OutputDisplay;
global OutputDisplay showResult;
rule "Credit rule"
when
- $cash :CashFlow( $aDate : mvtDate, $no : accountNo ,type == CashFlow.CREDIT )
- $acc : Account(accountNo ==$no )
- $period : AccountingPeriod( startDate <= $aDate && endDate >= $aDate)
+ $cash :CashFlow( $aDate : mvtDate, $no : accountNo, type == CashFlow.CREDIT )
+ $acc : Account(accountNo == $no )
+ $period : AccountingPeriod( startDate <= $aDate && endDate >= $aDate )
then
$acc.setBalance($acc.getBalance()+$cash.getAmount());
showResults.showText("Account no "+$acc.getAccountNo()+ " has now a balance of "+$acc.getBalance());
- end
+end
rule "Debit rule"
when
@@ -420,7 +422,7 @@ rule "Debit rule"
+ " has now a balance of "+$acc.getBalance());
end
```
-In the rule above, we add a constraint so that the mvtDate of the CashFlow is between the startDate and endDate of the AccountinPeriod.
+In the rule above, we add a constraint so that the mvtDate of the CashFlow is between the startDate and endDate of the AccountingPeriod.
and the test case
@@ -472,7 +474,3 @@ As expected, the "Credit Rule" is fired once and the "Debit Rule" is fired once
In lesson 1, we learned the dynamic of the rule engine : how and when are the rules fired.
In the current lesson, we started to link together conditions between facts and how to interact with the facts in the rule execution.
In the next lesson, we will see how to express more complex constraints.
-
-
-
-
From fb8d05f0895e0af5b22f594ca35acb5c4ac3137e Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 16:07:51 -0400
Subject: [PATCH 10/16] Typos and tweaks
---
gettingStarted/lesson_3.md | 50 +++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/gettingStarted/lesson_3.md b/gettingStarted/lesson_3.md
index fe754fa..6ddb739 100644
--- a/gettingStarted/lesson_3.md
+++ b/gettingStarted/lesson_3.md
@@ -2,7 +2,7 @@
We concentrate on how the rule engine works in the first lesson. In the second lesson, we introduced how to express constraint between facts.
In this lesson, we will concentrate on all the drools language possibilities to write constraints on facts for more complex cases.
-The reader has to create a test classes called TestLesson3 like for lesson2, a new package lesson3 in the src/test/rules and add in the kmodule.xml a new session declaration
+The reader has to create a test class called TestLesson3 like for lesson2, a new package lesson3 in the src/test/rules and add in the kmodule.xml a new session declaration
```
@@ -14,10 +14,10 @@ While building the examples, you will see more rules fired than the shown exampl
## Some more classes
-To be able to see some more advanced features, we are going to add 2 new classes in src/main/java droolscours package.
+To be able to see some more advanced features, we are going to add 2 new classes in src/main/java droolscourse package.
```
-package droolscours;
+package droolscourse;
public class Customer {
private String name;
@@ -75,7 +75,7 @@ public class Customer {
```
```
-package droolscours;
+package droolscourse;
public class PrivateAccount extends Account {
private Customer owner;
@@ -107,13 +107,13 @@ public class PrivateAccount extends Account {
This allows to validate an attribute is a list of values
```
-package cours
+package lesson3
//#list any import classes here.
-import droolscours.CashFlow;
+import droolscourse.CashFlow;
import util.OutputDisplay;
//#declare any global variables here
-global OutputDisplay showResult;
+global OutputDisplay showResults;
rule "The cashFlow can be a credit or a debit"
@@ -136,7 +136,7 @@ end
cashFlow.setType(CashFlow.CREDIT);
sessionStatefull.insert(cashFlow);
sessionStatefull.fireAllRules();
- } }
+ }
```
And the console should look as follows :
@@ -145,7 +145,7 @@ And the console should look as follows :
## Nested Accessor
-This allows to add a constraint to a attribute class without the need to add the linked object to the session.
+This allows us to add a constraint to a attribute class without the need to add the linked object to the session.
```
rule "Accessor"
@@ -180,7 +180,7 @@ The rule has been fired.
## And/or
-It is possible to do constraints on attribute like in java.
+It is possible to do constraints on attributes like in Java.
```
rule "infixAnd"
@@ -241,7 +241,7 @@ end
## exist
-On the contrary of previous syntax, this allows to test if there at least one fact type is in the session.
+The inverse of the previous syntax, this allows to test if there is at least one fact type in the session.
```
rule "Exists"
@@ -271,7 +271,7 @@ end
## ForAll
-We would like to verify that every cashflow instance is linked to an Account instance.
+We would like to verify that every CashFlow instance is linked to an Account instance.
```
rule "ForAll"
@@ -284,8 +284,8 @@ rule "ForAll"
end
```
-In this rule, in the forall condition, we link the CashFLow instance to the Account instance.
-We are going to do a test case where all objects are related
+In this rule, in the forall condition, we link the CashFlow instance to the Account instance.
+We are going to do a test case where all objects are related.
```
@Test
@@ -325,7 +325,7 @@ When running the test, you should see the following logging.
Just modify the test case by updating the test case :
```
-sessionStatefull.insert(cash2);
+ sessionStatefull.insert(cash2);
Account a2 = new Account();
a2.setAccountNo(2);
a2.setBalance(0);
@@ -343,7 +343,7 @@ When you run the test case, the rule ForAll will not be fired.
It is sometimes needed to access data from outside the drools session.
As it is not possible to insert all objects in the session, we can use the from instruction in the when part.
-First let us create a CustomerService class in package Droolscours.sercice
+First let us create a CustomerService class in package droolscourse.service
```
package droolscours.service;
@@ -355,7 +355,7 @@ import java.util.List;
public class CustomerService {
- public List getListCustomer() {
+ public List getCustomerList() {
List result = new ArrayList();
result.add(new Customer("Héron", "Nicolas", "Fr"));
result.add(new Customer("Héron", "James", "GB"));
@@ -377,7 +377,7 @@ global CustomerService serviceCustomer;
rule "FromCondition"
when
$c : Customer()
- $cc : Customer(name ==$c.name,surname==$c.surname,country !=$c.country) from serviceCustomer.getListCustomer();
+ $cc : Customer(name ==$c.name,surname==$c.surname,country !=$c.country) from serviceCustomer.getCustomerList();
then
showResult.showText("Found same customer in 2 countries");
end
@@ -405,12 +405,12 @@ The rule is fired twice as in the service there are two customers with the same
## Collecting
-The purpose is to collect a set of fact and constraint if the constraints are true. Let us see the following example int the rule "More then 2 CashFlow Line". in this rule, we want to collect all CashFlow that are in the correct time period and the good account number. The "from collect" syntax returns an arrayList. It is possible to add a condition as in the first rule where we add a constraint that we expect at least 2 items. In the second rule, we do not add this constraint.
+The purpose is to collect a set of facts and constraints if the constraints are true. Let us see the following example in the rule "More then 2 CashFlow Line". In this rule, we want to collect all CashFlow that are in the correct time period and with the correct account number. The "from collect" syntax returns an ArrayList. It is possible to add a condition as in the first rule where we add a constraint that we expect at least 2 items. In the second rule, we do not add this constraint.
```
rule "More then 2 CashFlow Line"
when
- $c : Account( $acc : accountno )
+ $c : Account( $acc : accountNo )
$p : AccountingPeriod ($sDate : startDate ,$eDate : endDate )
$number : ArrayList(size >= 2 )
from collect( CashFlow( mvtDate >= $sDate && mvtDate <= $eDate,accountNo == $acc ) )
@@ -426,7 +426,7 @@ end
rule "Numbers of CashFlow Line"
when
- $c : Account( $acc : accountno )
+ $c : Account( $acc : accountNo )
$p : AccountingPeriod ($sDate : startDate ,$eDate : endDate )
$number : ArrayList( )
from collect( CashFlow( mvtDate >= $sDate && mvtDate <= $eDate,accountNo == $acc ) )
@@ -488,7 +488,7 @@ Here is our test case :
## Accumulating
-In the previous section, we collect data. There is an "from accumulate" that allows us to sum data in one command.
+In the previous section, we collect data. There is a "from accumulate" that allows us to sum data in one command.
the "from collect" instruction takes 5 parameters :
1\) a fact constraint expression
2\) an init condition
@@ -496,7 +496,7 @@ the "from collect" instruction takes 5 parameters :
4\) the reverse action when the fact constraint expression is not true anymore
5\) The result of the accumulate
-Here is our example :
+Here is our example:
```
rule "Credit and Debit Rule"
@@ -504,13 +504,13 @@ rule "Credit and Debit Rule"
$c : Account( $acc : accountno )
$p : AccountingPeriod ($sDate : startDate ,$eDate : endDate )
$totalCredit : Number( doubleValue > 100 )
- from accumulate( CashFlow( type ==CashFlow.CREDIT,$value : amount, mvtDate >= $sDate && mvtDate <= $eDate,accountNo == $acc ),
+ from accumulate( CashFlow( type == CashFlow.CREDIT, $value : amount, mvtDate >= $sDate && mvtDate <= $eDate, accountNo == $acc ),
init( double total = 0; ),
action( total += $value; ),
reverse( total -= $value; ),
result( total ) )
$totalDebit : Number( doubleValue > 100 )
- from accumulate( CashFlow( type ==CashFlow.DEBIT,$value : amount, mvtDate >= $sDate && mvtDate <= $eDate,accountNo == $acc ),
+ from accumulate( CashFlow( type == CashFlow.DEBIT, $value : amount, mvtDate >= $sDate && mvtDate <= $eDate, accountNo == $acc ),
init( double total = 0; ),
action( total += $value; ),
reverse( total -= $value; ),
From d2531660f5017da0a54f8cb3a98edc3a1620d519 Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 18:37:47 -0400
Subject: [PATCH 11/16] Typos and tweaks
---
gettingStarted/lesson_4__ruleflow.md | 57 ++++++++++++++--------------
1 file changed, 29 insertions(+), 28 deletions(-)
diff --git a/gettingStarted/lesson_4__ruleflow.md b/gettingStarted/lesson_4__ruleflow.md
index ee8d01e..b4fd7c1 100644
--- a/gettingStarted/lesson_4__ruleflow.md
+++ b/gettingStarted/lesson_4__ruleflow.md
@@ -7,44 +7,46 @@ In the drools/jbpm technology, we are going to use a jbpm process by using rule
## Configure project to become a jbpm project
-select the project, right click with the mouse configure/convert to jbpm project
+Select the project, right click with the mouse configure/convert to jbpm project

## Create your first rule flow
-in the src/test/rules create a package lesson4. Right click and create new File and call it ruleflow1.bpmn2 and click the OK button. An error messages appear to say the file is empty but the plugin will create a start event.
+In the src/test/rules create a package lesson4. Right click and create new File and call it ruleflow1.bpmn2 and click the OK button. An error messages appear to say the file is empty but the plugin will create a start event.

-put two Rule tasks and one End Event.
+Put two Rule tasks and one End Event.

-Then select each of the Rule set and set the properties as follows :
+Then select each of the Rule set and set the properties as follows:

-
-The workflow should look like that :
+
+
+The workflow should look like this:
+

-Select the workflow in the rear, and in the properties file, change as follows :
+Select the workflow in the rear, and in the properties file, change as follows:

Create a new rule file called demo-ruleflow1.drl
```
-package cours
+package lesson4
-import droolscours.Account;
-import droolscours.AccountingPeriod;
-import droolscours.CashFlow;
+import droolscourse.Account;
+import droolscourse.AccountingPeriod;
+import droolscourse.CashFlow;
import util.OutputDisplay;
global OutputDisplay showResult;
@@ -75,7 +77,7 @@ Do not forget to add a new entry in the kmodule.xml
```
-Look at the keyword "ruleflow-group". Here the first rule we give it the name "Group1" and the second "Group2". they have the same name as the Rule-flow items we defined in the process definition above. Therefor, the first rule can only be fired when the rule-flow group "Group1" is activated and the same for the second rule and rule-flow group "Group2".
+Look at the keyword "ruleflow-group". Here the first rule we give the name "Group1" and the second "Group2". They have the same name as the Rule-flow items we defined in the process definition above. Therefore, the first rule can only be fired when the rule-flow group "Group1" is activated and the same for the second rule and rule-flow group "Group2".
Before running a test case, we will add a new callback to know the activities around the jbpm process.
```
@@ -151,11 +153,11 @@ Before running a test case, we will add a new callback to know the activities ar
```
-Note that we are only looking for Node of type Rule Step called RuleSetNodeInstance.
-And the test case looks like this :
+Note that we are only looking for a Node of type Rule Step called RuleSetNodeInstance.
+And the test case looks like this:
```
-package droolscours;
+package droolscourse;
import util.OutputDisplay;
import org.junit.After;
import org.junit.Before;
@@ -200,17 +202,18 @@ Before calling the fireAllRules method, we call a startProcess method with the "
-And the console display should be like this :
+And the console display should be like this:

-How a rule-group works ?
+
+### How a rule-group works ?
A rule flow group works like a separate group of rules. Those who are setting the focus when the rule step is called with the same node id as the ruleflow-group.
When no more rules can be fired, the process can continue to the next node.
-We can go further
+We can go further.
-## starting a ruleflow from a rule
+## Starting a ruleflow from a rule
Let us write the following rule :
@@ -268,15 +271,15 @@ Here is for "to Node Calculate1". Do not forget to click the "Imports" button t

-here is the rule file :
+Here is the rule file :
```
-package cours
+package lesson4a
//#list any import classes here.
-import droolscours.Account;
-import droolscours.AccountingPeriod;
-import droolscours.CashFlow;
+import droolscourse.Account;
+import droolscourse.AccountingPeriod;
+import droolscourse.CashFlow;
import util.OutputDisplay;
global OutputDisplay showResult;
@@ -326,9 +329,7 @@ and the test case

-if you change the balance to 500, the console should be :
+If you change the balance to 500, the console should be:

-It is more efficient to have two groups of rules like this instead adding for all rules of 'Group1' the constraint on balance > 1000 and balance <= 1000 for "Group2". Indeed, if the level 1000$ changes you have to modify all rules. And furthermore, if the end user gives your the rule : "first case is when balance is less than 1000$", then the good practice is to implement business rules as they are given. And implementing with a ruleflow will help end users to divide their way of expressing more complex rules. We will see int the exercise how it helps.
-
-
+It is more efficient to have two groups of rules like this instead adding for all rules of 'Group1' the constraint on balance > 1000 and balance <= 1000 for "Group2". Indeed, if the level $1000 changes you have to modify all rules. And furthermore, if the end user gives your the rule : "first case is when balance is less than $1000", then the best practice is to implement business rules as they are given. And implementing with a ruleflow will help end users to divide their way of expressing more complex rules. We will see in the exercise how it helps.
From 39deca66d71f233c094a08a53bd1b865b897250b Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 18:42:53 -0400
Subject: [PATCH 12/16] Typos and tweaks
---
gettingStarted/lesson_4__execercice.md | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/gettingStarted/lesson_4__execercice.md b/gettingStarted/lesson_4__execercice.md
index 4b9ee08..126a978 100644
--- a/gettingStarted/lesson_4__execercice.md
+++ b/gettingStarted/lesson_4__execercice.md
@@ -1,8 +1,9 @@
# Cost transport calculator
-The purpose of the exercise is to go through all steps of a real project when using a rule engine like drools. The use case is simple enough to be realize withing one or two working days.
-We first expose the business requirements like they may be expressed by users. Then we are going to design the implementation we shall use. Feel free to modify the implementation if you think it is not how you would have done. The only point of view you should keep is to use declarative programming versus procedural code.
-It is very common for new comers to write a few rules and implement huge then part of rules. It works. But you should remember that the implemented algorithms that are behind drools will work best if you express a lot a pattern expressions (constraints) on java facts and if you insert new fact that are the result of a rule.
-For example, in a loyalty system in retail industry, if a customer is comming more than twice per month on the web site or in the shop, than he is a gold customer. this is a fact that can be used in other rules as input.
-This is how the rule engine was thought to be used and when you see business requirements it is how it is expressed naturally.
\ No newline at end of file
+The purpose of the exercise is to go through all steps of a real project when using a rule engine like drools. The use case is simple enough to be realized within one or two working days. We first expose the business requirements like they may be expressed by users. Then we are going to design the implementation we shall use. Feel free to modify the implementation if you think it is not how you would have done it. The only point of view you should keep is to use declarative programming versus procedural code.
+
+It is very common for newcomers to write a few rules with huge then parts. It works. But you should remember that the implemented algorithms that are behind drools will work best if you express a lot of pattern expressions (constraints) on java facts and if you insert new facts that are the result of a rule.
+For example, in a loyalty system in a retail industry, if a customer is coming more than twice per month on the web site or in the shop, then he is a gold customer. This is a fact that can be used in other rules as input.
+
+This is how the rules engine was designed to be used, and when you see business requirements it is how they are expressed naturally.
From 66c44018ca7f1bb30615bfa41011a51718bd831a Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Sun, 7 Oct 2018 18:51:07 -0400
Subject: [PATCH 13/16] Typos and tweaks
---
gettingStarted/requirements.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gettingStarted/requirements.md b/gettingStarted/requirements.md
index a1fa7be..919b9f2 100644
--- a/gettingStarted/requirements.md
+++ b/gettingStarted/requirements.md
@@ -1,7 +1,7 @@
# Requirements
-We are working for a retail company that buys its products from different places in Asian mostly. each shop can go to the buying web site and say what he wants and put an order.
-Up to now, the transport cost was a estimated but not calculated on the content of the order.
+We are working for a retail company that buys its products from different places in Asia mostly. Each shop can go to the buying web site and say what he wants and put an order. Up to now, the transport cost was estimated but not calculated on the content of the order.
+
The purpose is to implement such a calculator.
## Data model
@@ -16,9 +16,9 @@ A product has
* transport type : if the product can be put with other products in a pallet, individual\(alone\) or bulk \(like sand for example\)
* a weight
-A product can be put on a pallet. a pallet 120 cm width and and 80 cm depth. It can be maximum 2 meters height and the weight should not exceed 1400 kg. We should use a simple algorithm to fill each pallet. It will be not optimized but we should used that as a margin of the costs. a product that is bigger than 60 cm in width or depth or higher than 1m should be put alone in a pallet.
+A product can be put on a pallet. A pallet is 120 cm width and and 80 cm depth. It can be a maximum of 2 meters in height and the weight should not exceed 1400 kg. We should use a simple algorithm to fill each pallet. It will not be optimized, but we should used that as a margin of the costs. A product that is bigger than 60 cm in width or depth or higher than 1m should be put alone on a pallet.
-All products start from the same city and go to the same city in an order. A trip is composed f steps. Each step can be done by train, boat or truck.
+All products start from the same city and go to the same city in an order. A trip is composed of steps. Each step can be done by train, boat or truck.
Here is the list of products in our test order.
@@ -40,7 +40,7 @@ And the trip is a follows :
There are 3 types of costs :
-* transport costs per Pallet
+* Transport costs per Pallet
| Transport | Cost |
| :--- | :--- |
@@ -57,7 +57,7 @@ There are 3 types of costs :
| Tournai | 2€ per handling person |
| Lille | 30€ per handling person |
-* handling
+* Handling
| City | Cost |
| :--- | :--- |
From 8170165da079d6aadd2ffbe060c0aecd044607d4 Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Mon, 8 Oct 2018 04:24:55 -0400
Subject: [PATCH 14/16] Update requirements.md
---
gettingStarted/requirements.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gettingStarted/requirements.md b/gettingStarted/requirements.md
index 919b9f2..8e7aeee 100644
--- a/gettingStarted/requirements.md
+++ b/gettingStarted/requirements.md
@@ -22,7 +22,7 @@ All products start from the same city and go to the same city in an order. A tri
Here is the list of products in our test order.
-| Product | Transport type | Number | Height | Weight | Depth | Weight |
+| Product | Transport type | Number | Height | Width | Depth | Weight |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| Drill | pallet | 1000 | 20cm | 40cm | 30cm | 2 kg |
| Screwdriver | pallet | 30000 | 3cm | 2cm | 20cm | 0,2 kg |
@@ -30,7 +30,7 @@ Here is the list of products in our test order.
| Gravel | bulk | | | | | 14 Tons |
| Furniture | individual | 23 | | | | 500 kg |
-And the trip is a follows :
+And the trip is as follows:
| \# | start city | arrival city | distance \(km\) | travel mode |
| :--- | :--- | :--- | :--- | :--- |
@@ -38,7 +38,7 @@ And the trip is a follows :
| 2 | Rotterdam | Tournai | 300 | Train |
| 3 | Tournai | Lille | 20 | Truck |
-There are 3 types of costs :
+There are 3 types of costs:
* Transport costs per Pallet
From 7f908424a8cbc6e2921fc22f3f1b7dde554e9e3a Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Mon, 8 Oct 2018 04:26:51 -0400
Subject: [PATCH 15/16] Update requirements.md
---
gettingStarted/requirements.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gettingStarted/requirements.md b/gettingStarted/requirements.md
index 8e7aeee..f5172c0 100644
--- a/gettingStarted/requirements.md
+++ b/gettingStarted/requirements.md
@@ -13,10 +13,10 @@ A product has
* a height,
* a width,
* a depth,
-* transport type : if the product can be put with other products in a pallet, individual\(alone\) or bulk \(like sand for example\)
+* transport type : if the product can be put with other products in a pallet, individual \(alone\) or bulk \(like sand for example\)
* a weight
-A product can be put on a pallet. A pallet is 120 cm width and and 80 cm depth. It can be a maximum of 2 meters in height and the weight should not exceed 1400 kg. We should use a simple algorithm to fill each pallet. It will not be optimized, but we should used that as a margin of the costs. A product that is bigger than 60 cm in width or depth or higher than 1m should be put alone on a pallet.
+A product can be put on a pallet. A pallet is 120 cm width and and 80 cm depth. It can be a maximum of 2 meters in height and the weight should not exceed 1400 kg. We should use a simple algorithm to fill each pallet. It will not be optimized, but we should use that as an upper limit for the costs. A product that is bigger than 60 cm in width or depth or higher than 1m should be put alone on a pallet.
All products start from the same city and go to the same city in an order. A trip is composed of steps. Each step can be done by train, boat or truck.
From 96770d2b4fc6a2818c70d4d8f1a8b52988c9179c Mon Sep 17 00:00:00 2001
From: mdfst13 <43025590+mdfst13@users.noreply.github.com>
Date: Fri, 12 Oct 2018 02:04:34 -0400
Subject: [PATCH 16/16] Update lesson_2__binding.md
---
gettingStarted/lesson_2__binding.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gettingStarted/lesson_2__binding.md b/gettingStarted/lesson_2__binding.md
index 8f3b7b9..7fffe0e 100644
--- a/gettingStarted/lesson_2__binding.md
+++ b/gettingStarted/lesson_2__binding.md
@@ -359,11 +359,11 @@ The rule was fired twice because there are 2 (CashFlow,Account) couples. The fir
We shall modify the rule like this:
```
-package droolscours
+package droolscourse
//list any import classes here.
-import droolscours.AccountingPeriod;
-import droolscours.CashFlow;
-import droolscours.Account;
+import droolscourse.AccountingPeriod;
+import droolscourse.CashFlow;
+import droolscourse.Account;
import util.OutputDisplay;
global OutputDisplay showResults;