-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.lein-repl-history
154 lines (149 loc) · 5 KB
/
.lein-repl-history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
(use 'drools.rules.RuleRunner)
(-main)
(def knowledge-session (build-knowledge-session))
;; Create a Temperature fact
(def shouldBeTooHot
(drools.model.Temperature. 100))
;; Create another Temperature fact
(def shouldBeTooCold
(drools.model.Temperature. 20))
;; Insert the facts & fire all rules
(doto knowledge-session
(.insert shouldBeTooHot)
(.insert shouldBeTooCold)
(.fireAllRules))
(def m (-main)
)
(println m)
(print m)
shouldBeTooCold
(.getValue shouldBeTooCold)
(def knowledge-builder
(org.drools.builder.KnowledgeBuilderFactory/newKnowledgeBuilder))
;; Adding the Weather Rules definition
;; to the KnowledgeBuilder
(.add knowledge-builder
(org.drools.io.ResourceFactory/newClassPathResource
"WeatherRules.drl")
org.drools.builder.ResourceType/DRL)
knowledge-builder
(quit)
(-main)
(quit)
(def ks (org.kie.api.KieServices$Factory/get))
(def container ^org.kie.api.runtime.KieContainer (.getKieClasspathContainer ks))
container
(.getKieBase container)
(quit)
(def ks (org.kie.api.KieServices$Factory/get))
(def container (.. ks getKieClasspathContainer))
(def ksesson (.. container newKieSession))
(def shouldBeTooHot
(drools.model.Temperature. 100))
;; Create another Temperature fact
(def shouldBeTooCold
(drools.model.Temperature. 20))
(.insert ksesson shouldBeTooCold)
(.insert ksesson shouldBeTooHot)
(.fireAllRules ksesson)
shouldBeTooHot
ksesson
(def ksesson (.. container newKieSession))
ksesson
(def shouldBeTooHot
(drools.model.Temperature. 100))
(.insert ksesson shouldBeTooHot)
(.fireAllRules ksesson)
container
(.verify container)
intln( temp.value.toString() + \" F is too hot.\" + \" Declare HEAT WARNING!\");:\n[Error: unable to resolve method using strict-mode: double.toString()]\n[Near : {... ( temp.value.toString() + \" F is too hot.\" ....}]\n ^\n[Line: 5, Column: 0]]\nMessage [id=2, kieBase=defaultKieBase, level=ERROR, path=WeatherRules.drl, line=15, column=0\n text=Unable
(def ksesson (.. container newKieSession))
ksesson
(def ks (org.
))
(def ks (org.kie.api.KieServices$Factory/get))
(def container (.. ks getKieClasspathContainer))
(def ksesson (.. container newKieSession))
(def shouldBeTooHot
(drools.model.Temperature. 100))
;; Create another Temperature fact
(def shouldBeTooCold
(drools.model.Temperature. 20))
(quit)
(def ks (org.kie.api.KieServices$Factory/get))
(def container (.. ks getKieClasspathContainer))
(def ksesson (.. container newKieSession))
quit
(def ks (org.kie.api.KieServices$Factory/get))
(def container (.. ks getKieClasspathContainer))
(def ksesson (.. container newKieSession))
(quit)
(def ks (org.kie.api.KieServices$Factory/get))
(def container (.. ks getKieClasspathContainer))
(def ksesson (.. container newKieSession))
(def shouldBeTooHot
(drools.model.Temperature. 100))
;; Create another Temperature fact
(def shouldBeTooCold
(drools.model.Temperature. 20))
(.insert ksesson shouldBeTooCold)
(.insert ksesson shouldBeTooHot)
(.fireAllRules ksesson)
(use 'drools.rules.Main)
(def status (atom {}))
(defn init []
"init"
(let [kieservice (org.kie.api.KieServices$Factory/get)
kiecontainer (.. kieservice getKieClasspathContainer)
ksesson (.. kiecontainer newKieSession)]
(swap! status assoc :kieservice kieservice)
(swap! status assoc :kiecontainer kiecontainer)
(swap! status assoc :ksesson ksesson)))
(init)
(def status (atom {}))
(defn init []
"init"
(let [kieservice (org.kie.api.KieServices$Factory/get)
kiecontainer (.. kieservice getKieClasspathContainer)
ksesson (.. kiecontainer newKieSession)]
(swap! status assoc :kieservice kieservice)
(swap! status assoc :kiecontainer kiecontainer)
(swap! status assoc :ksesson ksesson)))
(init)
(defn testFireRule []
"Test Fire Rules"
(let [shouldBeTooHot (drools.model.Temperature. 100)
shouldBeTooCold (drools.model.Temperature. 20)]
(.insert (:ksesson @status) shouldBeTooCold)
(.insert (:ksesson @status) shouldBeTooHot)
(.fireAllRules (:ksesson ksesson))))
(defn testFireRule []
"Test Fire Rules"
(let [shouldBeTooHot (drools.model.Temperature. 100)
shouldBeTooCold (drools.model.Temperature. 20)]
(.insert (:ksesson @status) shouldBeTooCold)
(.insert (:ksesson @status) shouldBeTooHot)
(.fireAllRules (:ksesson @status))))
(testFireRule)
@status
(init)
(testFireRule)
(defn testFireRule1 []
"Test Fire Rules"
(let [shouldBeTooHot (drools.model.Temperature. 100)
shouldBeTooCold (drools.model.Temperature. 199)]
(.insert (:ksesson @status) shouldBeTooCold)
(.insert (:ksesson @status) shouldBeTooHot)
(.fireAllRules (:ksesson @status))))
(testFireRule2)
(testFireRule1)
(testFireRule)
status
(defn testFireRule2 []
"Test Fire Rules"
(let [shouldBeTooHot (drools.model.Temperature. 1)
shouldBeTooCold (drools.model.Temperature. 2)]
(.insert (:ksesson @status) shouldBeTooCold)
(.insert (:ksesson @status) shouldBeTooHot)
(.fireAllRules (:ksesson @status))))
(testFireRule2)