SlideShare une entreprise Scribd logo
1  sur  17
Télécharger pour lire hors ligne
 
                               
Drools5 Community Training
Hands On Playing with Rules
      Sponsored by Plugtree
Hands On 1: Drools Expert
   Playing with Rules
   Drools5 Community Training
      version: 1.0-SNAPSHOT
     Release Date: 09/05/2011
Under The Creative Common License
Hands On 1: Drools Expert
   Playing with Rules
 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/.
Overview

● Drools Expert Examples
   ○ Introduction examples
   ○ Conditional elements examples
   ○ Rules Attributes examples
Introduction Examples

● Project: drools5/01-DroolsExpert-Introduction
● Test: SimpleRulesExampleTest.java
● Rules: src/main/resources/rules/rules.drl
● Kbuilder, Kbase and Ksession (createKSession() method)
   ○ Take a look at the addEventListener() method
● DRL syntax in the rule file:
   ○ Take a look at the LHS
   ○ Take a look at the RHS
● Rules activation and execution (you can activate the logger)
Introduction Examples

● Exercise
   ○ Find a way to get "Warn when we have a POP songs and
     Playlist" Rule activated but not fired.
   ○ Find a way to get "Warn when we have a POP songs and
     Playlist" Rule activated and fired.
Conditional Elements examples
● Project: drools5/02-DroolsExpert-ConditionalElements
● Simple Rules Example:
   ○ Test Class: SimpleRulesExampleTest.java
   ○ Rules: SimpleRules.drl
   ○ Conditional Elements on LHS
   ○ from Conditional Element
● Advanced from Examples:
   ○ Test Class: AdvancedFromRulesExampleTest.java
   ○ Rules: AdvancedFromRules.drl
   ○ collect, accumulate, accumulate custom function, Using
     Hibernate session in from CE
Conditional Elements Examples

● Exercise 1
   ○ Replace "Add Playlists that contains songs with letter 'a'
     in their titles to the list using the accumulate conditional
     elements defining init, action, reverse and result functions.
     i.e:
             from accumulate(
     $s: Song() from $songs,
     init(),
     action(),
     reverse(),
     result()
 )
Conditional Elements examples

Solution:
rule "Playlists that contains songs with letter 'a' in their titles."
when
        $playlist: Playlist($songs: songs)
        $match: java.util.List(empty == false) from accumulate(
           $s: Song() from $songs,
           init( java.util.List result = new java.util.ArrayList();),
           action( if ($s.getTitle().contains("a")) result.add($s); ),
           result( result )
        )
then
        System.out.println("Playlist found: "+$playlist);
        for (int i=0; i<$match.size(); i++){
           System.out.println("t--"+$match.get(i));
        }
end
Conditional Elements examples

● Exercise 2
   ○ Create a custom accumulate function to collect random
     songs from a playlist.
   ○ Copy the SongsWithALetterOnTheirTitlesFunction.java implementation
Conditional Elements Examples

● eval Example:
    ○ Test Class: EvalRulesExampleTest.java
    ○ Rules: /rules/EvalRules.drl
    ○ use of eval in LHS

● exists Example:
    ○ Test Class: ExistsRulesExampleTest.java
    ○ Rules: ExistsRules.drl
    ○ use of exists and not in the LHS
Conditional Elements Examples

● Exercise
   ○ Replace "Warn when we have a Playlist longer than 9000
     seconds" with an equivalent Rule without using eval
Conditional Elements Examples

Solution
rule "Playlist longer than 9000 seconds without eval"
when
$playlist: Playlist($songs: songs) AND
       $n : Number(intValue > 9000) from accumulate(
             $s : Song() from $songs,
             sum($s.getDuration()))
then
System.out.println("We have found a Playlist
                     longer than 9000 seconds");
end
Rule Attributes examples

● Project: drools/03-DroolsExpert-RulesAttributes
● Test Class: RuleAttributesExampleTest.java
● Attributes:
   ○ salience
   ○ no-loop:
       ■ Test: noLoop() Rules: /rules/NoLoopRules.drl
   ○ lock-on-active:
       ■ Test: lockOnActive() Rules: /rules/LockOnActiveRules.drl
   ○ agenda-group:
       ■ Test: agendaGroup() Rules: /rules/AgendaGroupRules.drl
 
              
Questions?
Enjoy! Questions and Feedback are
always appreciated!
 
                     
    Contact us at
www.plugtree.com

Contenu connexe

Tendances

Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP GeneratorsMark Baker
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsMark Baker
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHPTaras Kalapun
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersIan Barber
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionIan Barber
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodJeremy Kendall
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 
Clojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVMClojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVMsunng87
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 
PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)brian d foy
 
Things I Believe Now That I'm Old
Things I Believe Now That I'm OldThings I Believe Now That I'm Old
Things I Believe Now That I'm OldRoss Tuck
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserHoward Lewis Ship
 
Event Sourcing and Functional Programming
Event Sourcing and Functional ProgrammingEvent Sourcing and Functional Programming
Event Sourcing and Functional ProgrammingGlobalLogic Ukraine
 
JavaScript Classes and Inheritance
JavaScript Classes and InheritanceJavaScript Classes and Inheritance
JavaScript Classes and Inheritancemarcheiligers
 
Intro to Advanced JavaScript
Intro to Advanced JavaScriptIntro to Advanced JavaScript
Intro to Advanced JavaScriptryanstout
 

Tendances (20)

Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP Generators
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Presentatie - Introductie in Groovy
Presentatie - Introductie in GroovyPresentatie - Introductie in Groovy
Presentatie - Introductie in Groovy
 
はじめてのGroovy
はじめてのGroovyはじめてのGroovy
はじめてのGroovy
 
Miracle of std lib
Miracle of std libMiracle of std lib
Miracle of std lib
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHP
 
JS OO and Closures
JS OO and ClosuresJS OO and Closures
JS OO and Closures
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find Fraudsters
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Clojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVMClojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVM
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)
 
Things I Believe Now That I'm Old
Things I Believe Now That I'm OldThings I Believe Now That I'm Old
Things I Believe Now That I'm Old
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The Browser
 
Event Sourcing and Functional Programming
Event Sourcing and Functional ProgrammingEvent Sourcing and Functional Programming
Event Sourcing and Functional Programming
 
JavaScript Classes and Inheritance
JavaScript Classes and InheritanceJavaScript Classes and Inheritance
JavaScript Classes and Inheritance
 
Nantes Jug - Java 7
Nantes Jug - Java 7Nantes Jug - Java 7
Nantes Jug - Java 7
 
Intro to Advanced JavaScript
Intro to Advanced JavaScriptIntro to Advanced JavaScript
Intro to Advanced JavaScript
 

Similaire à Drools5 Community Training HandsOn 1 Drools DRL Syntax

The Ring programming language version 1.5.4 book - Part 78 of 185
The Ring programming language version 1.5.4 book - Part 78 of 185The Ring programming language version 1.5.4 book - Part 78 of 185
The Ring programming language version 1.5.4 book - Part 78 of 185Mahmoud Samir Fayed
 
Performance Tuning and Optimization
Performance Tuning and OptimizationPerformance Tuning and Optimization
Performance Tuning and OptimizationMongoDB
 
The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212Mahmoud Samir Fayed
 
Lecture 4 - Object Interaction and Collections
Lecture 4 - Object Interaction and CollectionsLecture 4 - Object Interaction and Collections
Lecture 4 - Object Interaction and CollectionsSyed Afaq Shah MACS CP
 
The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185Mahmoud Samir Fayed
 
Searching for AI - Leveraging Solr for classic Artificial Intelligence tasks
Searching for AI - Leveraging Solr for classic Artificial Intelligence tasksSearching for AI - Leveraging Solr for classic Artificial Intelligence tasks
Searching for AI - Leveraging Solr for classic Artificial Intelligence tasksAlexandre Rafalovitch
 
The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185Mahmoud Samir Fayed
 
Java 2 chapter 10 - basic oop in java
Java 2   chapter 10 - basic oop in javaJava 2   chapter 10 - basic oop in java
Java 2 chapter 10 - basic oop in javalet's go to study
 
The Ring programming language version 1.6 book - Part 42 of 189
The Ring programming language version 1.6 book - Part 42 of 189The Ring programming language version 1.6 book - Part 42 of 189
The Ring programming language version 1.6 book - Part 42 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 76 of 189
The Ring programming language version 1.6 book - Part 76 of 189The Ring programming language version 1.6 book - Part 76 of 189
The Ring programming language version 1.6 book - Part 76 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 93 of 212
The Ring programming language version 1.10 book - Part 93 of 212The Ring programming language version 1.10 book - Part 93 of 212
The Ring programming language version 1.10 book - Part 93 of 212Mahmoud Samir Fayed
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 itiAhmed mar3y
 
Introducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyIntroducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyNikhil Mungel
 
2nd Proj. Update: Integrating SWI-Prolog for Semantic Reasoning in Bioclipse
2nd Proj. Update: Integrating SWI-Prolog for Semantic Reasoning in Bioclipse2nd Proj. Update: Integrating SWI-Prolog for Semantic Reasoning in Bioclipse
2nd Proj. Update: Integrating SWI-Prolog for Semantic Reasoning in BioclipseSamuel Lampa
 
Rails 3 generators
Rails 3 generatorsRails 3 generators
Rails 3 generatorsjoshsmoore
 
Mario Fusco - Lazy Java - Codemotion Milan 2018
Mario Fusco - Lazy Java - Codemotion Milan 2018Mario Fusco - Lazy Java - Codemotion Milan 2018
Mario Fusco - Lazy Java - Codemotion Milan 2018Codemotion
 

Similaire à Drools5 Community Training HandsOn 1 Drools DRL Syntax (20)

The Ring programming language version 1.5.4 book - Part 78 of 185
The Ring programming language version 1.5.4 book - Part 78 of 185The Ring programming language version 1.5.4 book - Part 78 of 185
The Ring programming language version 1.5.4 book - Part 78 of 185
 
Performance Tuning and Optimization
Performance Tuning and OptimizationPerformance Tuning and Optimization
Performance Tuning and Optimization
 
The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212The Ring programming language version 1.10 book - Part 17 of 212
The Ring programming language version 1.10 book - Part 17 of 212
 
Lecture 4 - Object Interaction and Collections
Lecture 4 - Object Interaction and CollectionsLecture 4 - Object Interaction and Collections
Lecture 4 - Object Interaction and Collections
 
The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185
 
Searching for AI - Leveraging Solr for classic Artificial Intelligence tasks
Searching for AI - Leveraging Solr for classic Artificial Intelligence tasksSearching for AI - Leveraging Solr for classic Artificial Intelligence tasks
Searching for AI - Leveraging Solr for classic Artificial Intelligence tasks
 
The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185The Ring programming language version 1.5.4 book - Part 79 of 185
The Ring programming language version 1.5.4 book - Part 79 of 185
 
Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examples
 
Testing Spring Applications
Testing Spring ApplicationsTesting Spring Applications
Testing Spring Applications
 
Java 2 chapter 10 - basic oop in java
Java 2   chapter 10 - basic oop in javaJava 2   chapter 10 - basic oop in java
Java 2 chapter 10 - basic oop in java
 
The Ring programming language version 1.6 book - Part 42 of 189
The Ring programming language version 1.6 book - Part 42 of 189The Ring programming language version 1.6 book - Part 42 of 189
The Ring programming language version 1.6 book - Part 42 of 189
 
The Ring programming language version 1.6 book - Part 76 of 189
The Ring programming language version 1.6 book - Part 76 of 189The Ring programming language version 1.6 book - Part 76 of 189
The Ring programming language version 1.6 book - Part 76 of 189
 
The Ring programming language version 1.10 book - Part 93 of 212
The Ring programming language version 1.10 book - Part 93 of 212The Ring programming language version 1.10 book - Part 93 of 212
The Ring programming language version 1.10 book - Part 93 of 212
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
 
Introducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyIntroducing Command Line Applications with Ruby
Introducing Command Line Applications with Ruby
 
2nd Proj. Update: Integrating SWI-Prolog for Semantic Reasoning in Bioclipse
2nd Proj. Update: Integrating SWI-Prolog for Semantic Reasoning in Bioclipse2nd Proj. Update: Integrating SWI-Prolog for Semantic Reasoning in Bioclipse
2nd Proj. Update: Integrating SWI-Prolog for Semantic Reasoning in Bioclipse
 
Rails 3 generators
Rails 3 generatorsRails 3 generators
Rails 3 generators
 
Mario Fusco - Lazy Java - Codemotion Milan 2018
Mario Fusco - Lazy Java - Codemotion Milan 2018Mario Fusco - Lazy Java - Codemotion Milan 2018
Mario Fusco - Lazy Java - Codemotion Milan 2018
 
Lazy java
Lazy javaLazy java
Lazy java
 
Lazy Java
Lazy JavaLazy Java
Lazy Java
 

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

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Dernier (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Drools5 Community Training HandsOn 1 Drools DRL Syntax

  • 1.     Drools5 Community Training Hands On Playing with Rules Sponsored by Plugtree
  • 2. Hands On 1: Drools Expert Playing with Rules Drools5 Community Training version: 1.0-SNAPSHOT Release Date: 09/05/2011 Under The Creative Common License
  • 3. Hands On 1: Drools Expert Playing with Rules 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. Overview ● Drools Expert Examples ○ Introduction examples ○ Conditional elements examples ○ Rules Attributes examples
  • 5. Introduction Examples ● Project: drools5/01-DroolsExpert-Introduction ● Test: SimpleRulesExampleTest.java ● Rules: src/main/resources/rules/rules.drl ● Kbuilder, Kbase and Ksession (createKSession() method) ○ Take a look at the addEventListener() method ● DRL syntax in the rule file: ○ Take a look at the LHS ○ Take a look at the RHS ● Rules activation and execution (you can activate the logger)
  • 6. Introduction Examples ● Exercise ○ Find a way to get "Warn when we have a POP songs and Playlist" Rule activated but not fired. ○ Find a way to get "Warn when we have a POP songs and Playlist" Rule activated and fired.
  • 7. Conditional Elements examples ● Project: drools5/02-DroolsExpert-ConditionalElements ● Simple Rules Example: ○ Test Class: SimpleRulesExampleTest.java ○ Rules: SimpleRules.drl ○ Conditional Elements on LHS ○ from Conditional Element ● Advanced from Examples: ○ Test Class: AdvancedFromRulesExampleTest.java ○ Rules: AdvancedFromRules.drl ○ collect, accumulate, accumulate custom function, Using Hibernate session in from CE
  • 8. Conditional Elements Examples ● Exercise 1 ○ Replace "Add Playlists that contains songs with letter 'a' in their titles to the list using the accumulate conditional elements defining init, action, reverse and result functions. i.e: from accumulate( $s: Song() from $songs, init(), action(), reverse(), result() )
  • 9. Conditional Elements examples Solution: rule "Playlists that contains songs with letter 'a' in their titles." when $playlist: Playlist($songs: songs) $match: java.util.List(empty == false) from accumulate( $s: Song() from $songs, init( java.util.List result = new java.util.ArrayList();), action( if ($s.getTitle().contains("a")) result.add($s); ), result( result ) ) then System.out.println("Playlist found: "+$playlist); for (int i=0; i<$match.size(); i++){ System.out.println("t--"+$match.get(i)); } end
  • 10. Conditional Elements examples ● Exercise 2 ○ Create a custom accumulate function to collect random songs from a playlist. ○ Copy the SongsWithALetterOnTheirTitlesFunction.java implementation
  • 11. Conditional Elements Examples ● eval Example: ○ Test Class: EvalRulesExampleTest.java ○ Rules: /rules/EvalRules.drl ○ use of eval in LHS ● exists Example: ○ Test Class: ExistsRulesExampleTest.java ○ Rules: ExistsRules.drl ○ use of exists and not in the LHS
  • 12. Conditional Elements Examples ● Exercise ○ Replace "Warn when we have a Playlist longer than 9000 seconds" with an equivalent Rule without using eval
  • 13. Conditional Elements Examples Solution rule "Playlist longer than 9000 seconds without eval" when $playlist: Playlist($songs: songs) AND $n : Number(intValue > 9000) from accumulate( $s : Song() from $songs, sum($s.getDuration())) then System.out.println("We have found a Playlist longer than 9000 seconds"); end
  • 14. Rule Attributes examples ● Project: drools/03-DroolsExpert-RulesAttributes ● Test Class: RuleAttributesExampleTest.java ● Attributes: ○ salience ○ no-loop: ■ Test: noLoop() Rules: /rules/NoLoopRules.drl ○ lock-on-active: ■ Test: lockOnActive() Rules: /rules/LockOnActiveRules.drl ○ agenda-group: ■ Test: agendaGroup() Rules: /rules/AgendaGroupRules.drl
  • 15.     Questions?
  • 16. Enjoy! Questions and Feedback are always appreciated!
  • 17.     Contact us at www.plugtree.com