读书人

Drools4:对Ticket示范的分析

发布时间: 2012-11-16 14:12:14 作者: rapoo

Drools4:对Ticket示例的分析

    ?
      1. #?显示增加的门票情况 ??
      2. rule?"New?Ticket"??
      3. ????salience?10??
      4. ????when ??
      5. ????????customer?:?CustomerEx(?)???? ??
      6. ????????ticket?:?Ticket(?customer?==?customer,?status?==?"New"?)???? ??
      7. ????then ??
      8. ????????System.out.println(?"New?:?"?+?ticket?);???????? ??
      9. end ??
      10. ??
      11. #?找到银卡会员,设置电影票状态 ??
      12. rule?"Silver?Priority"??
      13. ????duration?3000??
      14. ????when ??
      15. ????????customer?:?CustomerEx(?subscription?==?"Silver"?)??? ??
      16. ????????ticket?:?Ticket(?customer?==?customer,?status?==?"New"?)???? ??
      17. ????then ??
      18. ????????ticket.setStatus(?"Escalate"?); ??
      19. ????????update(?ticket?);??????? ??
      20. end ??
      21. ??
      22. #?找到白金卡会员,设置电影票状态 ??
      23. rule?"Platinum?Priority"??
      24. ????when ??
      25. ????????customer?:?CustomerEx(?subscription?==?"Platinum"?)? ??
      26. ????????ticket?:?Ticket(?customer?==?customer,?status?==?"New"?)???? ??
      27. ????then; ??
      28. ????????ticket.setStatus(?"Escalate"?); ??
      29. ????????update(?ticket?); ??
      30. end ??
      31. ??
      32. #?找到金卡会员,设置电影票状态 ??
      33. rule?"Gold?Priority"??
      34. ????duration?1000??
      35. ????when ??
      36. ????????customer?:?CustomerEx(?subscription?==?"Gold"?)? ??
      37. ????????ticket?:?Ticket(?customer?==?customer,?status?==?"New"?)???? ??
      38. ????then ??
      39. ????????ticket.setStatus(?"Escalate"?);? ??
      40. ????????update(?ticket?);??? ??
      41. end ??
      42. ??
      43. #?对于被设置状态为Escalate的电影票发送邮件 ??
      44. rule?"Escalate"??
      45. ????when ??
      46. ????????customer?:?CustomerEx(?)???? ??
      47. ????????ticket?:?Ticket(?customer?==?customer,?status?==?"Escalate"?)??? ??
      48. ????then ??
      49. ????????sendEscalationEmail(?customer,?ticket?); ??
      50. end ??
      51. ??
      52. #?显示状态设置为Done的电影票情况 ??
      53. rule?"Done"??
      54. ????when ??
      55. ????????customer?:?CustomerEx(?)???? ??
      56. ????????ticket?:?Ticket(?customer?==?customer,?status?==?"Done"?)??? ??
      57. ????then ??
      58. ????????System.out.println(?"Done?:?"?+?ticket?);??????? ??
      59. end ??
      60. ??
      61. #?模拟发送邮件的函数 ??
      62. function?void?sendEscalationEmail(?CustomerEx?customer,?Ticket?ticket?)?{ ??
      63. ????System.out.println(?"Email?:?"?+?ticket?); ??
      64. }??
      1 楼 江南白衣 2007-08-06 给分,兄弟为drools4推广出力良多。 2 楼 chinapr 2007-08-25 辛苦

读书人网 >软件架构设计

热点推荐