Your SlideShare is downloading. ×
0
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Drools5 Community Training: Module 1.5 - Drools Expert First Example
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Drools5 Community Training: Module 1.5 - Drools Expert First Example

7,460

Published on

for more information visit: http://salaboy.wordpress.com

for more information visit: http://salaboy.wordpress.com

Published in: Technology
2 Comments
4 Likes
Statistics
Notes
  • Hi Eng,
    Sorry for the late reply. All Clips, Jess and Drools are Rule Engines, Clips is written in C, Jess is a Port to Java and Drools is also Java. The main advantage of drools is a really active developer community and the integration with other tools such as a Process Engine and Complex Event Processing.
    You can analyse data with Drools, writing rules based on your information, but it really depends on what your goals are.
    Hope this helps
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • I am beginner at text mining field , i want to extract information from textual data , can i do that by using Drools or no , and can you help me to know different between Clips,Jess,Drools and what is the best
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
7,460
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
317
Comments
2
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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/2011Under 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. AgendaIntroductionBusiness Rule StructureDrools Expert Example ScenarioHands on lab
  • 5. Drools Expert in 2 slidesThe core of DroolsLets us express our Knowledge -> Business RulesLets us create Sessions -> Our WorldIt will be in charge of making inferences between them andfiring the correspondent actions.Lets see how it works!
  • 6. Drools Expert in 2 slides
  • 7. Business Rule Structurerule "My Rule" when <LHS> Person(name == "John") <CEs> then <RHS> System.out.println("Hi John!"); <Actions>end
  • 8. Example Scenario
  • 9. Example ModelWe 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. Andthis 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 doesnt 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 Rulesrule "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 Rulesrule "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 doesnt come down when I call Then call the Fire Department
  • 14. Technical View of  the Rulesrule "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 JavaFor 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);
  • 16. APIs Sneak Preview
  • 17. Hands OnProject Name: drools5/00-Drools5-FirstExampleSources: https://github.com/Salaboy/Drools_jBPM5-Training-ExamplesCharacteristics: 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 OnExercise 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 - Solutionrule "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);endrule "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 UpCovered 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 alwaysappreciated!Stay Tuned!
  • 24.     Contact us atwww.plugtree.com

×