Phil 4.3.12

8:00 – 1:30, 3:30 -6:00  CSIP

  • Ok ,now that we have working(?) code, I have something to walk through while reading the book.
  • The Drools team suggests that you use the joda DateTime library. It looks pretty nice, too – http://joda-time.sourceforge.net/. They also have a bunch of other interesting libraries at http://joda.sourceforge.net/
  • Setting a global value in a rule
    • Java
      // Import the class
      import droolsbook.bank.service.BankingInquiryService;
      
      // create the session
      static StatelessKnowledgeSession session;
      
      // create rule engine
      KnowledgeBaseConfiguration configuration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
      KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(configuration);
      
      // declare our global
      BankingInquiryService inquiryService = new BankingInquiryServiceImpl();
      
      // make a session
      session = knowledgeBase.newStatelessKnowledgeSession();
      
      // add the global to the session
      session.setGlobal("inquiryService", inquiryService);
    • Drools rule (.drl file)
      // import
      import droolsbook.bank.service.*;
      
      // declare
      global BankingInquiryService inquiryService;
      
      // use the global in a rule (note the surrounding eval(), which can evaluate any code that returns a TRUE or FALSE).
      rule "accountNumberUnique"
          when
              $account : Account(eval(!inquiryService.isAccountNumberUnique($account)))
          then
              error(kcontext, $account);
      end
  • Chapter 4
  • Nice data visualization using webGL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s