SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
 
                               
Drools5 Community Training
      Sponsored by Plugtree
Module 1.5: Drools Expert 
     First Example
   Drools5 Community Training
      version: 1.0-SNAPSHOT
     Release Date: 03/16/2011
Under The Creative Common License
Module 1.5: Drools Expert First
          Example
   Drools5 Community Training Course
    by Mauricio "Salaboy" Salatino and
    Esteban Aliverti is licensed under a
    Creative Commons Attribution 3.0
              Unported License.
  Based on a work at salaboy.wordpress.
                    com.
   Permissions beyond the scope of this
     license may be available at http:
         //salaboy.wordpress.com/.
Agenda

Introduction
Business Rule Structure
Drools Expert Example Scenario
Hands on lab
Drools Expert in 2 slides

The core of Drools
Lets us express our Knowledge -> Business Rules
Lets us create Sessions -> Our World
It will be in charge of making inferences between them and
firing the correspondent actions.
Let's see how it works!
Drools Expert in 2 slides
Business Rule Structure

rule "My Rule"

      when <LHS>
        Person(name == "John") <CEs>
      then <RHS>
        System.out.println("Hi John!"); <Actions>
end
Example Scenario
Example Model

We can define that a Pet will have a name, type and a position.

For this example a Person will have a Pet which he/she can call. And
this Person can also call the fire department.

The Firefighter will know how to retrieve a Cat from a Tree.
Example Rules

   Rule "Call Cat when it is in a tree"
    When my Cat is on a limb in a tree
    Then I will call my Cat

   Rule "Call the fire department"
    When my Cat is on a limb and
                   it doesn't come down when I call
    Then call the Fire Department

   Rule "Firefighter gets the cat down"
    When the Firefighter can reach the Cat
    Then the Firefighter retrieves the Cat
Technical View of  the Model
Technical View of  the Rules

rule "Call Cat when it is in a tree"
  when
    $p: Person($pet: pet, petCallCount == 0)
    $cat: Pet(this == $pet,
              position == "on a limb",
              type == PetType.CAT)
    then
       //$cat.getName() + " come down!"
       $p.setPetCallCount($p.getPetCallCount()+1);
       update($p);
end
                   Rule "Call Cat when it is in a tree"
                    When my Cat is on a limb in a tree
                    Then I will call my Cat
Technical View of  the Rules

rule "Call the fire department"
  when
    $p: Person($pet: pet, petCallCount > 0)
    $cat: Pet(this == $pet,
              position == "on a limb",
              type == PetType.CAT)
  then
    Firefighter firefighter
                   = new Firefighter("Fred");
    insert(firefighter);
end

                 Rule "Call the fire department"
                  When my Cat is on a limb and
                         it doesn't come down when I call
                  Then call the Fire Department
Technical View of  the Rules

rule "Firefighter gets the cat down"
  when
    $f: Firefighter()
    $p: Person($pet: pet, petCallCount > 0)
    $cat: Pet(this == $pet,
              position == "on a limb",
              type == PetType.CAT)
  then
    $cat.setPosition("on the street");
    retract($f);
    update($cat);
end
                  Rule "Firefighter gets the cat down"
                   When the Firefighter can reach the Cat
                   Then the Firefighter retrieves the Cat
Active Scenario in Java

For the previous rules to fire in our Java world we need to have:
   An instance of a Person that contains a relation to its Pet
   An instance of a Pet that is on a limb

  Person person = new Person("Salaboy!");
  Pet pet = new Pet("mittens", "on a limb",
                        Pet.PetType.CAT);
  person.setPet(pet);
API's Sneak Preview
Hands On

Project Name: drools5/00-Drools5-FirstExample
Sources: https://github.com/Salaboy/Drools_jBPM5-Training-
Examples
Characteristics:
   Java Project (jar)
   Uses Maven (pom.xml)
   Drools Dependencies (core, api, compiler)
   DRL File (src/test/resources/rules.drl)
To do:
   Run the test (src/test/java/org/plugtree/example/FirstExampleTest.java)
   Get familiar with the output
Hands On

Exercise 1:
   Create a new rule that inserts a Dog (on the street) when
   there is Cat on the street too.
   Create a new rule for the situation when a Cat and a Dog are
   on the street, the Dog should chase it up to the tree and then
   the Cat should climb the limb.
Hands On - Solution
rule "Cat on the street"
    when
         Pet(position == "on the street", type == PetType.CAT)
    then
         Pet dog = new Pet("doggy", "on the street" , PetType.DOG);
         insert (dog);
end


rule "Cat on the street and a dog is around"
    when
         $cat: Pet(position == "on the street", type == PetType.CAT)
         $dog: Pet(position == "on the street", type == PetType.DOG)
    then
              modify($cat){
                 setPosition("on the limb");
              }
              modify($dog){
                 setPosition("under the tree");
              }
end
Hands On - What Happen?

Exercise 1:
   What happens with the execution? Why?
   Try to find a solution
Briefing Up

Covered Topics:
   Quick review about Drools Expert
   Project Dependencies
   A simple example that shows the key things that we need
   to have to use Drools
 
              
Questions?
Enjoy! 
Questions and Feedback are always
appreciated!
Stay Tuned!
 
                     
    Contact us at
www.plugtree.com

Contenu connexe

Tendances

Introduction to Drools
Introduction to DroolsIntroduction to Drools
Introduction to Droolsgiurca
 
Rule Engine: Drools .Net
Rule Engine: Drools .NetRule Engine: Drools .Net
Rule Engine: Drools .NetGuo Albert
 
Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)martincabrera
 
JavaScript
JavaScriptJavaScript
JavaScriptSunil OS
 
Hibernate
Hibernate Hibernate
Hibernate Sunil OS
 
Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2José Paumard
 
Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Roman Elizarov
 
Drools and jBPM 6 Overview
Drools and jBPM 6 OverviewDrools and jBPM 6 Overview
Drools and jBPM 6 OverviewMark Proctor
 
Java Basics V3
Java Basics V3Java Basics V3
Java Basics V3Sunil OS
 
Presentation Spring, Spring MVC
Presentation Spring, Spring MVCPresentation Spring, Spring MVC
Presentation Spring, Spring MVCNathaniel Richand
 
Drools 6 deep dive
Drools 6 deep diveDrools 6 deep dive
Drools 6 deep diveMario Fusco
 
Rules Programming tutorial
Rules Programming tutorialRules Programming tutorial
Rules Programming tutorialSrinath Perera
 
Mastering RecyclerView Layouts
Mastering RecyclerView LayoutsMastering RecyclerView Layouts
Mastering RecyclerView LayoutsDave Smith
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Michel Schudel
 
Lambda and Stream Master class - part 1
Lambda and Stream Master class - part 1Lambda and Stream Master class - part 1
Lambda and Stream Master class - part 1José Paumard
 

Tendances (20)

Drools
DroolsDrools
Drools
 
Introduction to Drools
Introduction to DroolsIntroduction to Drools
Introduction to Drools
 
Rule Engine: Drools .Net
Rule Engine: Drools .NetRule Engine: Drools .Net
Rule Engine: Drools .Net
 
Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Hibernate
Hibernate Hibernate
Hibernate
 
Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2
 
Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Drools and jBPM 6 Overview
Drools and jBPM 6 OverviewDrools and jBPM 6 Overview
Drools and jBPM 6 Overview
 
Java Basics V3
Java Basics V3Java Basics V3
Java Basics V3
 
Presentation Spring, Spring MVC
Presentation Spring, Spring MVCPresentation Spring, Spring MVC
Presentation Spring, Spring MVC
 
OOP V3.1
OOP V3.1OOP V3.1
OOP V3.1
 
Drools 6 deep dive
Drools 6 deep diveDrools 6 deep dive
Drools 6 deep dive
 
Rules Programming tutorial
Rules Programming tutorialRules Programming tutorial
Rules Programming tutorial
 
Mastering RecyclerView Layouts
Mastering RecyclerView LayoutsMastering RecyclerView Layouts
Mastering RecyclerView Layouts
 
Introducing Kogito
Introducing KogitoIntroducing Kogito
Introducing Kogito
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
 
Lambda and Stream Master class - part 1
Lambda and Stream Master class - part 1Lambda and Stream Master class - part 1
Lambda and Stream Master class - part 1
 
Java 8 Lambda and Streams
Java 8 Lambda and StreamsJava 8 Lambda and Streams
Java 8 Lambda and Streams
 

En vedette

Open shift
Open shiftOpen shift
Open shiftmarcolof
 
JUDCon India 2012 Drools Expert
JUDCon  India 2012 Drools ExpertJUDCon  India 2012 Drools Expert
JUDCon India 2012 Drools ExpertMark Proctor
 
2012 02-04 fosdem 2012 - guvnor and j bpm designer
2012 02-04 fosdem 2012 - guvnor and j bpm designer 2012 02-04 fosdem 2012 - guvnor and j bpm designer
2012 02-04 fosdem 2012 - guvnor and j bpm designer marcolof
 
BRM 2012 (Decision Tables)
BRM 2012 (Decision Tables)BRM 2012 (Decision Tables)
BRM 2012 (Decision Tables)Michael Anstis
 
2012 02-04 fosdem 2012 - drools planner
2012 02-04 fosdem 2012 - drools planner2012 02-04 fosdem 2012 - drools planner
2012 02-04 fosdem 2012 - drools plannerGeoffrey De Smet
 
JUDCon India 2012 Drools Fusion
JUDCon  India 2012 Drools FusionJUDCon  India 2012 Drools Fusion
JUDCon India 2012 Drools FusionMark Proctor
 

En vedette (6)

Open shift
Open shiftOpen shift
Open shift
 
JUDCon India 2012 Drools Expert
JUDCon  India 2012 Drools ExpertJUDCon  India 2012 Drools Expert
JUDCon India 2012 Drools Expert
 
2012 02-04 fosdem 2012 - guvnor and j bpm designer
2012 02-04 fosdem 2012 - guvnor and j bpm designer 2012 02-04 fosdem 2012 - guvnor and j bpm designer
2012 02-04 fosdem 2012 - guvnor and j bpm designer
 
BRM 2012 (Decision Tables)
BRM 2012 (Decision Tables)BRM 2012 (Decision Tables)
BRM 2012 (Decision Tables)
 
2012 02-04 fosdem 2012 - drools planner
2012 02-04 fosdem 2012 - drools planner2012 02-04 fosdem 2012 - drools planner
2012 02-04 fosdem 2012 - drools planner
 
JUDCon India 2012 Drools Fusion
JUDCon  India 2012 Drools FusionJUDCon  India 2012 Drools Fusion
JUDCon India 2012 Drools Fusion
 

Similaire à Drools5 Community Training: Module 1.5 - Drools Expert First Example

Class and Objects in PHP
Class and Objects in PHPClass and Objects in PHP
Class and Objects in PHPRamasubbu .P
 
Drools Introduction
Drools IntroductionDrools Introduction
Drools IntroductionJBug Italy
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oopLearningTech
 
Architecture logicielle #3 : object oriented design
Architecture logicielle #3 : object oriented designArchitecture logicielle #3 : object oriented design
Architecture logicielle #3 : object oriented designJean Michel
 
Objects, Testing, and Responsibility
Objects, Testing, and ResponsibilityObjects, Testing, and Responsibility
Objects, Testing, and Responsibilitymachuga
 
Oops implemetation material
Oops implemetation materialOops implemetation material
Oops implemetation materialDeepak Solanki
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaKonrad Malawski
 
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguajeKotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguajeVíctor Leonel Orozco López
 
Module 10-Introduction to OOP.pptx
Module 10-Introduction to OOP.pptxModule 10-Introduction to OOP.pptx
Module 10-Introduction to OOP.pptxssuserec53e73
 
Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insAndrew Dupont
 
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good PracticesEffective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good PracticesNaresha K
 
14 Defining classes
14 Defining classes14 Defining classes
14 Defining classesmaznabili
 
Android & Kotlin - The code awakens #03
Android & Kotlin - The code awakens #03Android & Kotlin - The code awakens #03
Android & Kotlin - The code awakens #03Omar Miatello
 
Drools5 Community Training Module 3 Drools Expert DRL Syntax
Drools5 Community Training Module 3 Drools Expert DRL SyntaxDrools5 Community Training Module 3 Drools Expert DRL Syntax
Drools5 Community Training Module 3 Drools Expert DRL SyntaxMauricio (Salaboy) Salatino
 
What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?Christophe Porteneuve
 

Similaire à Drools5 Community Training: Module 1.5 - Drools Expert First Example (20)

Dog Ont In Dog
Dog Ont In DogDog Ont In Dog
Dog Ont In Dog
 
PHP Classes and OOPS Concept
PHP Classes and OOPS ConceptPHP Classes and OOPS Concept
PHP Classes and OOPS Concept
 
Class and Objects in PHP
Class and Objects in PHPClass and Objects in PHP
Class and Objects in PHP
 
10 classes
10 classes10 classes
10 classes
 
Drools Introduction
Drools IntroductionDrools Introduction
Drools Introduction
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
 
Architecture logicielle #3 : object oriented design
Architecture logicielle #3 : object oriented designArchitecture logicielle #3 : object oriented design
Architecture logicielle #3 : object oriented design
 
Objects, Testing, and Responsibility
Objects, Testing, and ResponsibilityObjects, Testing, and Responsibility
Objects, Testing, and Responsibility
 
Oops implemetation material
Oops implemetation materialOops implemetation material
Oops implemetation material
 
The things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and Akka
 
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguajeKotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
Kotlin+MicroProfile: Enseñando trucos de 20 años a un nuevo lenguaje
 
Module 10-Introduction to OOP.pptx
Module 10-Introduction to OOP.pptxModule 10-Introduction to OOP.pptx
Module 10-Introduction to OOP.pptx
 
Everything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-insEverything is Permitted: Extending Built-ins
Everything is Permitted: Extending Built-ins
 
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good PracticesEffective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good Practices
 
14 Defining classes
14 Defining classes14 Defining classes
14 Defining classes
 
Backbone intro
Backbone introBackbone intro
Backbone intro
 
Android & Kotlin - The code awakens #03
Android & Kotlin - The code awakens #03Android & Kotlin - The code awakens #03
Android & Kotlin - The code awakens #03
 
Drools5 Community Training Module 3 Drools Expert DRL Syntax
Drools5 Community Training Module 3 Drools Expert DRL SyntaxDrools5 Community Training Module 3 Drools Expert DRL Syntax
Drools5 Community Training Module 3 Drools Expert DRL Syntax
 
What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?
 

Plus de Mauricio (Salaboy) Salatino

Lessons Learnt from creating platforms on Kubernetes @ Rejekts
Lessons Learnt from creating platforms on Kubernetes @ RejektsLessons Learnt from creating platforms on Kubernetes @ Rejekts
Lessons Learnt from creating platforms on Kubernetes @ RejektsMauricio (Salaboy) Salatino
 
Building Developer Experiences for the Cloud .pdf
Building Developer Experiences for the Cloud .pdfBuilding Developer Experiences for the Cloud .pdf
Building Developer Experiences for the Cloud .pdfMauricio (Salaboy) Salatino
 
KUBEDAY - JAPAN 2022 - Building FaaS Platforms.pdf
KUBEDAY - JAPAN  2022 - Building FaaS Platforms.pdfKUBEDAY - JAPAN  2022 - Building FaaS Platforms.pdf
KUBEDAY - JAPAN 2022 - Building FaaS Platforms.pdfMauricio (Salaboy) Salatino
 
The Challenges of building Cloud Native Platforms
The Challenges of building Cloud Native PlatformsThe Challenges of building Cloud Native Platforms
The Challenges of building Cloud Native PlatformsMauricio (Salaboy) Salatino
 
Functions Working Group Update - August 2022.pdf
Functions Working Group Update - August 2022.pdfFunctions Working Group Update - August 2022.pdf
Functions Working Group Update - August 2022.pdfMauricio (Salaboy) Salatino
 
Expanding Interoperability in the CD ecosystem - CDCon - Austin, TX - 2022
Expanding Interoperability in the CD ecosystem - CDCon - Austin, TX -  2022 Expanding Interoperability in the CD ecosystem - CDCon - Austin, TX -  2022
Expanding Interoperability in the CD ecosystem - CDCon - Austin, TX - 2022 Mauricio (Salaboy) Salatino
 
Spring I/O 2022: Knative and Spring - Bringing back the `func`
Spring I/O 2022: Knative and Spring - Bringing back the `func`Spring I/O 2022: Knative and Spring - Bringing back the `func`
Spring I/O 2022: Knative and Spring - Bringing back the `func`Mauricio (Salaboy) Salatino
 
Knative Maintainers KubeConEU 22 Knative Overview and Update
Knative Maintainers KubeConEU 22 Knative Overview and UpdateKnative Maintainers KubeConEU 22 Knative Overview and Update
Knative Maintainers KubeConEU 22 Knative Overview and UpdateMauricio (Salaboy) Salatino
 
CDEventsCon Expanding Interoperability in the CD ecosystem
CDEventsCon Expanding Interoperability in the CD ecosystemCDEventsCon Expanding Interoperability in the CD ecosystem
CDEventsCon Expanding Interoperability in the CD ecosystemMauricio (Salaboy) Salatino
 
A Polyglot Developer Experience on Kubernetes - KubeCon EU Valencia
A Polyglot Developer Experience on Kubernetes - KubeCon EU ValenciaA Polyglot Developer Experience on Kubernetes - KubeCon EU Valencia
A Polyglot Developer Experience on Kubernetes - KubeCon EU ValenciaMauricio (Salaboy) Salatino
 
KCD Guatemala - Abstracciones sobre Abstracciones
KCD Guatemala - Abstracciones sobre AbstraccionesKCD Guatemala - Abstracciones sobre Abstracciones
KCD Guatemala - Abstracciones sobre AbstraccionesMauricio (Salaboy) Salatino
 
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS Offering
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS OfferingKubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS Offering
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS OfferingMauricio (Salaboy) Salatino
 
Cloud Native Islamabad - Getting Closer to Continuous Delivery with Knative
Cloud Native Islamabad - Getting Closer to Continuous Delivery with KnativeCloud Native Islamabad - Getting Closer to Continuous Delivery with Knative
Cloud Native Islamabad - Getting Closer to Continuous Delivery with KnativeMauricio (Salaboy) Salatino
 

Plus de Mauricio (Salaboy) Salatino (20)

Devoxx UK - Platforms on top of K8s
Devoxx UK - Platforms on top of K8sDevoxx UK - Platforms on top of K8s
Devoxx UK - Platforms on top of K8s
 
WTF_is_SRE_DeveloperEnabledPlatforms.pdf
WTF_is_SRE_DeveloperEnabledPlatforms.pdfWTF_is_SRE_DeveloperEnabledPlatforms.pdf
WTF_is_SRE_DeveloperEnabledPlatforms.pdf
 
Lessons Learnt from creating platforms on Kubernetes @ Rejekts
Lessons Learnt from creating platforms on Kubernetes @ RejektsLessons Learnt from creating platforms on Kubernetes @ Rejekts
Lessons Learnt from creating platforms on Kubernetes @ Rejekts
 
Building Developer Experiences for the Cloud .pdf
Building Developer Experiences for the Cloud .pdfBuilding Developer Experiences for the Cloud .pdf
Building Developer Experiences for the Cloud .pdf
 
KUBEDAY - JAPAN 2022 - Building FaaS Platforms.pdf
KUBEDAY - JAPAN  2022 - Building FaaS Platforms.pdfKUBEDAY - JAPAN  2022 - Building FaaS Platforms.pdf
KUBEDAY - JAPAN 2022 - Building FaaS Platforms.pdf
 
The Challenges of building Cloud Native Platforms
The Challenges of building Cloud Native PlatformsThe Challenges of building Cloud Native Platforms
The Challenges of building Cloud Native Platforms
 
Functions Working Group Update - August 2022.pdf
Functions Working Group Update - August 2022.pdfFunctions Working Group Update - August 2022.pdf
Functions Working Group Update - August 2022.pdf
 
JBCNConf 2022: Go vs Java (Kubernetes)
JBCNConf 2022: Go vs Java (Kubernetes)JBCNConf 2022: Go vs Java (Kubernetes)
JBCNConf 2022: Go vs Java (Kubernetes)
 
Expanding Interoperability in the CD ecosystem - CDCon - Austin, TX - 2022
Expanding Interoperability in the CD ecosystem - CDCon - Austin, TX -  2022 Expanding Interoperability in the CD ecosystem - CDCon - Austin, TX -  2022
Expanding Interoperability in the CD ecosystem - CDCon - Austin, TX - 2022
 
Spring I/O 2022: Knative and Spring - Bringing back the `func`
Spring I/O 2022: Knative and Spring - Bringing back the `func`Spring I/O 2022: Knative and Spring - Bringing back the `func`
Spring I/O 2022: Knative and Spring - Bringing back the `func`
 
KnativeCon 2022 - Knative Functions
KnativeCon 2022 - Knative FunctionsKnativeCon 2022 - Knative Functions
KnativeCon 2022 - Knative Functions
 
Knative Maintainers KubeConEU 22 Knative Overview and Update
Knative Maintainers KubeConEU 22 Knative Overview and UpdateKnative Maintainers KubeConEU 22 Knative Overview and Update
Knative Maintainers KubeConEU 22 Knative Overview and Update
 
CDEventsCon Expanding Interoperability in the CD ecosystem
CDEventsCon Expanding Interoperability in the CD ecosystemCDEventsCon Expanding Interoperability in the CD ecosystem
CDEventsCon Expanding Interoperability in the CD ecosystem
 
A Polyglot Developer Experience on Kubernetes - KubeCon EU Valencia
A Polyglot Developer Experience on Kubernetes - KubeCon EU ValenciaA Polyglot Developer Experience on Kubernetes - KubeCon EU Valencia
A Polyglot Developer Experience on Kubernetes - KubeCon EU Valencia
 
Pave the Golden Path On Your Internal Platform
Pave the Golden Path On Your Internal PlatformPave the Golden Path On Your Internal Platform
Pave the Golden Path On Your Internal Platform
 
Knative and Spring - Bringing back the func.pdf
Knative and Spring - Bringing back the func.pdfKnative and Spring - Bringing back the func.pdf
Knative and Spring - Bringing back the func.pdf
 
KCD Guatemala - Abstracciones sobre Abstracciones
KCD Guatemala - Abstracciones sobre AbstraccionesKCD Guatemala - Abstracciones sobre Abstracciones
KCD Guatemala - Abstracciones sobre Abstracciones
 
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS Offering
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS OfferingKubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS Offering
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS Offering
 
Cloud Native Islamabad - Getting Closer to Continuous Delivery with Knative
Cloud Native Islamabad - Getting Closer to Continuous Delivery with KnativeCloud Native Islamabad - Getting Closer to Continuous Delivery with Knative
Cloud Native Islamabad - Getting Closer to Continuous Delivery with Knative
 
Intro to the Cloud with Knative (Spanish)
Intro to the Cloud with Knative (Spanish) Intro to the Cloud with Knative (Spanish)
Intro to the Cloud with Knative (Spanish)
 

Dernier

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

Drools5 Community Training: Module 1.5 - Drools Expert First Example

  • 1.     Drools5 Community Training Sponsored by Plugtree
  • 2. Module 1.5: Drools Expert  First Example Drools5 Community Training version: 1.0-SNAPSHOT Release Date: 03/16/2011 Under The Creative Common License
  • 3. Module 1.5: Drools Expert First Example Drools5 Community Training Course by Mauricio "Salaboy" Salatino and Esteban Aliverti is licensed under a Creative Commons Attribution 3.0 Unported License. Based on a work at salaboy.wordpress. com. Permissions beyond the scope of this license may be available at http: //salaboy.wordpress.com/.
  • 4. Agenda Introduction Business Rule Structure Drools Expert Example Scenario Hands on lab
  • 5. Drools Expert in 2 slides The core of Drools Lets us express our Knowledge -> Business Rules Lets us create Sessions -> Our World It will be in charge of making inferences between them and firing the correspondent actions. Let's see how it works!
  • 6. Drools Expert in 2 slides
  • 7. Business Rule Structure rule "My Rule" when <LHS> Person(name == "John") <CEs> then <RHS> System.out.println("Hi John!"); <Actions> end
  • 9. Example Model We can define that a Pet will have a name, type and a position. For this example a Person will have a Pet which he/she can call. And this Person can also call the fire department. The Firefighter will know how to retrieve a Cat from a Tree.
  • 10. Example Rules Rule "Call Cat when it is in a tree" When my Cat is on a limb in a tree Then I will call my Cat Rule "Call the fire department" When my Cat is on a limb and it doesn't come down when I call Then call the Fire Department Rule "Firefighter gets the cat down" When the Firefighter can reach the Cat Then the Firefighter retrieves the Cat
  • 11. Technical View of  the Model
  • 12. Technical View of  the Rules rule "Call Cat when it is in a tree" when $p: Person($pet: pet, petCallCount == 0) $cat: Pet(this == $pet, position == "on a limb", type == PetType.CAT) then //$cat.getName() + " come down!" $p.setPetCallCount($p.getPetCallCount()+1); update($p); end Rule "Call Cat when it is in a tree" When my Cat is on a limb in a tree Then I will call my Cat
  • 13. Technical View of  the Rules rule "Call the fire department" when $p: Person($pet: pet, petCallCount > 0) $cat: Pet(this == $pet, position == "on a limb", type == PetType.CAT) then Firefighter firefighter = new Firefighter("Fred"); insert(firefighter); end Rule "Call the fire department" When my Cat is on a limb and it doesn't come down when I call Then call the Fire Department
  • 14. Technical View of  the Rules rule "Firefighter gets the cat down" when $f: Firefighter() $p: Person($pet: pet, petCallCount > 0) $cat: Pet(this == $pet, position == "on a limb", type == PetType.CAT) then $cat.setPosition("on the street"); retract($f); update($cat); end Rule "Firefighter gets the cat down" When the Firefighter can reach the Cat Then the Firefighter retrieves the Cat
  • 15. Active Scenario in Java For the previous rules to fire in our Java world we need to have: An instance of a Person that contains a relation to its Pet An instance of a Pet that is on a limb Person person = new Person("Salaboy!"); Pet pet = new Pet("mittens", "on a limb", Pet.PetType.CAT); person.setPet(pet);
  • 17. Hands On Project Name: drools5/00-Drools5-FirstExample Sources: https://github.com/Salaboy/Drools_jBPM5-Training- Examples Characteristics: Java Project (jar) Uses Maven (pom.xml) Drools Dependencies (core, api, compiler) DRL File (src/test/resources/rules.drl) To do: Run the test (src/test/java/org/plugtree/example/FirstExampleTest.java) Get familiar with the output
  • 18. Hands On Exercise 1: Create a new rule that inserts a Dog (on the street) when there is Cat on the street too. Create a new rule for the situation when a Cat and a Dog are on the street, the Dog should chase it up to the tree and then the Cat should climb the limb.
  • 19. Hands On - Solution rule "Cat on the street" when Pet(position == "on the street", type == PetType.CAT) then Pet dog = new Pet("doggy", "on the street" , PetType.DOG); insert (dog); end rule "Cat on the street and a dog is around" when $cat: Pet(position == "on the street", type == PetType.CAT) $dog: Pet(position == "on the street", type == PetType.DOG) then modify($cat){ setPosition("on the limb"); } modify($dog){ setPosition("under the tree"); } end
  • 20. Hands On - What Happen? Exercise 1: What happens with the execution? Why? Try to find a solution
  • 21. Briefing Up Covered Topics: Quick review about Drools Expert Project Dependencies A simple example that shows the key things that we need to have to use Drools
  • 22.     Questions?
  • 23. Enjoy!  Questions and Feedback are always appreciated! Stay Tuned!
  • 24.     Contact us at www.plugtree.com