-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdrools.adoc.po
288 lines (220 loc) · 12.5 KB
/
drools.adoc.po
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
msgid ""
msgstr ""
"Language: es_ES\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: jekyll-l10n\n"
#: _guides/drools.adoc
msgid "Defining and executing business rules with Drools"
msgstr ""
#: _guides/drools.adoc
msgid ""
"This guide demonstrates how your Quarkus application can use https://www.drools.org[Drools] to add intelligent automation\n"
"and power it up with the Drools rule engine."
msgstr ""
#: _guides/drools.adoc
msgid "Prerequisites"
msgstr "Requisitos previos"
#: _guides/drools.adoc
msgid "Introduction"
msgstr "Introducción"
#: _guides/drools.adoc
msgid "https://www.drools.org[Drools] is a set of projects focusing on intelligent automation and decision management, most notably providing a forward-chaining and backward-chaining inference-based rule engine, DMN decisions engine and other projects. A rule engine is a fundamental building block to create an expert system which, in artificial intelligence, is a computer system that emulates the decision-making ability of a human expert. You can read more information on the https://www.drools.org[Drools website]."
msgstr ""
#: _guides/drools.adoc
msgid "Drools allows defining rules with 2 different programming styles: one more traditional based on the concepts of a KieBase acting as a repository of business rules and a KieSession storing and evaluating the runtime data against them, and the other using a Rule Unit as a single abstraction that encapsulates the definitions of both a set of rules and the facts against which those rules will be matched."
msgstr ""
#: _guides/drools.adoc
msgid "Both these styles are fully supported in the Drools Quarkus extension and this document explains how to use both, outlining the pros and cons of each one."
msgstr ""
#: _guides/drools.adoc
msgid "Integrating the traditional Drools programming model with Quarkus"
msgstr ""
#: _guides/drools.adoc
msgid "This first example demonstrates how to define a set of rules using the traditional Drools style and how to expose their evaluation inside a REST endpoint through Quarkus."
msgstr ""
#: _guides/drools.adoc
msgid "The domain model of this sample project is made only by two classes, a loan application"
msgstr ""
#: _guides/drools.adoc
msgid "and the applicant who requested it"
msgstr ""
#: _guides/drools.adoc
msgid "The rules set is made of business decisions to approve or reject an application plus one last rule collecting all the approved applications into a list."
msgstr ""
#: _guides/drools.adoc
msgid "The goal that we want to achieve is putting the evaluation of these rules in a microservice, exposing them in a REST endpoint developed with Quarkus. To do so it is enough to add the Drools Quarkus extension among the dependencies of your project."
msgstr ""
#: _guides/drools.adoc
msgid "and at this point it is possible to obtain a reference to the KieSession evaluating the formerly defined rules and use it in a REST endpoint as it follows:"
msgstr ""
#: _guides/drools.adoc
msgid "where an implementation of the `KieRuntimeBuilder` interface is automatically generated and made injectable for you by the Drools extension and allows to obtain with a single statement an instance of any KieBases and KieSessions defined in your Drools project."
msgstr ""
#: _guides/drools.adoc
msgid "Here the `LoanAppDto` is a simple POJO used to submit multiple loan application to the same KieSession"
msgstr ""
#: _guides/drools.adoc
msgid "thus trying for example to invoke that endpoint with a set of loan applications"
msgstr ""
#: _guides/drools.adoc
msgid "the rule engine will evaluate them against the business rules we have configured before, returning the only one that in this case can be approved according to them"
msgstr ""
#: _guides/drools.adoc
msgid "Moving to the rule unit programming model"
msgstr ""
#: _guides/drools.adoc
msgid "A rule unit is a new concept introduced in Drools encapsulating both a set of rules and the facts against which those rules will be matched. It comes with a second abstraction called data source, defining the sources through which the facts are inserted, acting in practice as typed entry-points. There are two types of data sources:"
msgstr ""
#: _guides/drools.adoc
msgid "DataStream: an append-only data source"
msgstr ""
#: _guides/drools.adoc
msgid "subscribers only receive new (and possibly past) messages"
msgstr ""
#: _guides/drools.adoc
msgid "cannot update/remove"
msgstr ""
#: _guides/drools.adoc
msgid "stream may also be hot/cold in “reactive streams” terminology"
msgstr ""
#: _guides/drools.adoc
msgid "DataStore: data source for modifiable data"
msgstr ""
#: _guides/drools.adoc
msgid "subscribers may act upon the data store, by acting upon the fact handle"
msgstr ""
#: _guides/drools.adoc
msgid "In order to use rule units in our quarkus application it is necessary to add a second dependency."
msgstr ""
#: _guides/drools.adoc
msgid "In essence a rule unit is made of 2 strictly related parts: the definition of the fact to be evaluated and the set of rules evaluating them. The first part is implemented with a POJO, that for the loan example could be something like the following:"
msgstr ""
#: _guides/drools.adoc
msgid "Here instead of using the `LoanAppDto` that we introduced to marshall/unmarshall the JSON requests we are binding directly the class representing the rule unit. The two relevant differences are that it implements the `RuleUnitData` interface and uses a `DataStore` instead of a plain `List` containing the loan applications to be approved. The first is just a marker interface to notify the engine that this class is part of a rule unit definition. The use of a `DataStore` is necessary to let the rule engine to react accordingly to the changes by firing new rules and triggering other rules. In the example, the consequences of the rules modify the approved property of the loan applications. Conversely, the `maxAmount` value can be considered a configuration parameter of the rule unit and left as it is: it will automatically be processed during the rules evaluation with the same semantic of a global, and automatically set from the value passed by the JSON request as in the first example, so you will still be allowed to use it in your rules."
msgstr ""
#: _guides/drools.adoc
msgid "The second part of the rule unit is the drl file containing the rules belonging to this unit."
msgstr ""
#: _guides/drools.adoc
msgid "This rules file must declare the same package and a unit with the same name of the Java class implementing the `RuleUnitData` interface in order to state that they belong to the same rule unit."
msgstr ""
#: _guides/drools.adoc
msgid "This file has also been rewritten using the new OOPath notation: as anticipated, here the data source acts as a typed entry-point and the oopath expression has its name as root while the constraints are in square brackets, like in the following example."
msgstr ""
#: _guides/drools.adoc
msgid "Alternatively you can still use the old DRL syntax, specifying the name of the data source as an entry-point, with the drawback that in this case you need to specify again the type of the matched object, even if the engine can infer it from the type of the datasource, as it follows."
msgstr ""
#: _guides/drools.adoc
msgid "Finally note that the last rule collecting all the approved loan applications into a global `List` has been replaced by a query simply retrieving them. One of the advantages in using a rule unit is that it clearly defines the context of computation, in other terms the facts to be passed in input to the rule evaluation. Similarly, the query defines what is the output expected by this evaluation."
msgstr ""
#: _guides/drools.adoc
msgid "This clear definition of the computation boundaries allows Drools to also automatically generate a class executing the query and returning its results, together with a REST endpoint taking the rule unit as input, passing it to the former query executor and returning its as output."
msgstr ""
#: _guides/drools.adoc
msgid "You can have as many query as you want and for each of them it will be generated a different REST endpoint with the same name of the query transformed from camel case (like `FindApproved`) to dash separated (like `find-approved`)."
msgstr ""
#: _guides/drools.adoc
msgid "A more comprehensive example"
msgstr ""
#: _guides/drools.adoc
msgid "In this more comprehensive and complete example, we will augment a basic Quarkus application with a few simple rules to infer potential issues with the status of a home automation setup."
msgstr ""
#: _guides/drools.adoc
msgid "We will define a Drools Rule Unit and the rules in the DRL format."
msgstr ""
#: _guides/drools.adoc
msgid "We will wire the Rule Unit into a standard Quarkus CDI bean, for use in the Quarkus application (for instance, wiring MQTT messages from Kafka, etc.)."
msgstr ""
#: _guides/drools.adoc
#, fuzzy
msgid "To complete this guide, you need:"
msgstr "Para completar esta guía, necesitas:"
#: _guides/drools.adoc
msgid "less than 15 minutes"
msgstr ""
#: _guides/drools.adoc
#, fuzzy
msgid "an IDE"
msgstr "un IDE"
#: _guides/drools.adoc
#, fuzzy
msgid "JDK 17+ installed with `JAVA_HOME` configured appropriately"
msgstr "JDK 17+ instalado con `JAVA_HOME` configurado adecuadamente"
#: _guides/drools.adoc
msgid "Apache Maven 3.9.3+"
msgstr ""
#: _guides/drools.adoc
msgid "Docker"
msgstr "Docker"
#: _guides/drools.adoc
msgid "link:{https://quarkus.io/guides/building-native-image}[GraalVM installed] if you want to run in native mode"
msgstr ""
#: _guides/drools.adoc
msgid "Creating the Maven Project"
msgstr "Creación del proyecto Maven"
#: _guides/drools.adoc
msgid ""
"First, we need a new Quarkus project.\n"
"To create a new Quarkus project, you can reference the link:{https://quarkus.io/guides/maven-tooling}[Quarkus and Maven Guide]"
msgstr ""
#: _guides/drools.adoc
msgid "When you have your Quarkus project configured, you can add the Drools Quarkus extensions to your project by adding the following dependencies to your `pom.xml`:"
msgstr ""
#: _guides/drools.adoc
#, fuzzy
msgid "Writing the application"
msgstr "Escribir la aplicación"
#: _guides/drools.adoc
msgid "Let's start from the application domain model."
msgstr ""
#: _guides/drools.adoc
msgid "This application goal is to infer potential issues with the status of a home automation setup, so we create the necessary domain models to represent status of sensors, devices and other things inside the house."
msgstr ""
#: _guides/drools.adoc
msgid "Light device domain model:"
msgstr ""
#: _guides/drools.adoc
msgid "CCTV security camera domain model:"
msgstr ""
#: _guides/drools.adoc
msgid "Smartphone detected in WiFi domain model:"
msgstr ""
#: _guides/drools.adoc
msgid "Alert class to hold information of the potential detected problems:"
msgstr ""
#: _guides/drools.adoc
msgid "Next, we create a rule file `rules.drl` inside the `src/main/resources/org/drools/quarkus/quickstart/test` folder of the Quarkus project."
msgstr ""
#: _guides/drools.adoc
msgid "In this file there are some example rules to decide whether the overall status of the house is deemed inappropriate, triggering the necessary `Alert` (s)."
msgstr ""
#: _guides/drools.adoc
msgid "Rule Unit a central paradigm introduced in Drools 8 that helps users to encapsulate the set of rules and the facts against which those rules will be matched; you can read more information in the https://www.drools.org/learn/documentation.html[Drools documentation]."
msgstr ""
#: _guides/drools.adoc
msgid "The facts will be inserted into a `DataStore`, a type-safe entry point. To make everything work, we need to define both the RuleUnit and the DataStore."
msgstr ""
#: _guides/drools.adoc
#, fuzzy
msgid "Testing the Application"
msgstr "Probar la aplicación"
#: _guides/drools.adoc
msgid "We can create a standard Quarkus and JUnit test to check the behaviour of the Rule Unit and the defined rules, accordingly to a certain set of scenarios."
msgstr ""
#: _guides/drools.adoc
msgid "Wiring the Rule Unit with Quarkus CDI beans"
msgstr ""
#: _guides/drools.adoc
msgid "We can now wire the Rule Unit into a standard Quarkus CDI bean, for general use in the Quarkus application."
msgstr ""
#: _guides/drools.adoc
msgid "For example, this might later be helpful to wire device status reporting through MQTT via Kafka, using the appropriate Quarkus extensions."
msgstr ""
#: _guides/drools.adoc
msgid "We create a simple CDI bean to abstract away the Rule Unit API usage with:"
msgstr ""
#: _guides/drools.adoc
msgid "The same test scenarios can be refactored using this CDI bean accordingly."
msgstr ""