=Paper=
{{Paper
|id=Vol-428/paper-5
|storemode=property
|title=Can URML Model Successfully Drools Rules?
|pdfUrl=https://ceur-ws.org/Vol-428/paper5.pdf
|volume=Vol-428
|dblpUrl=https://dblp.org/rec/conf/ecai/PascalauG08
}}
==Can URML Model Successfully Drools Rules?==
Can URML model successfully Drools rules?
Emilian Pascalau and Adrian Giurca 1
Abstract. The use of rules in business modeling is becoming more a lot of functionality but does not provide a visual modeling environ-
and more important, in applications requiring dynamic change of be- ment for rules.
havior. A number of rule languages and tools have been proposed It is well known that visual modeling is easier to be understood
to the software engineering community. However, there are not too and to be remembered, therefore we claim that a visual language for
many visual languages for rule modeling. The goal of this paper is to rule modeling is necessary.
investigate the modeling capabilities of UML-based Rule Modeling The authors of [17] argued, that rule modeling language should
Language (URML) with respect of Drools rules. We choose Drools provide ways for representing rule expressions, in a manner easy to
because is the most important and well known open source rule plat- be understood by domain experts or by software engineers, who are
form. It is friendly to both developers and business users, offers a lot usually used with UML modeling. URML extends UML meta-model
of functionality but does not provide a visual modeling environment with the concept of rule.
for rules. The Single Item English Electronic Auction Use Case is
used to illustrate the modeling capabilities. The paper concludes that
URML rules can model the large part of Drools rules but improve- 2 UML-based rule modeling language - URML
ments of the modeling language are necessary. URML is developed by the REWERSE Working Group I1. Its main
goal is to provide visual constructs for modeling rules and business
1 Introduction processes. URML is close related to R2ML [16], [17] - a rule lan-
guage for rule interchange.
Nowadays global information networks like Internet are the envi- URML is wanted to be a general approach for modeling rules
ronment were business processes take place in automated way. A in comparison with work introduced in [4]. According to [18],
large part of e-commerce activities is devoted to B2B relationships. URML supports derivation rules, production rules and reaction
The natural way to describe behavior of such businesses is through rules. URML uses concepts such as rule condition, rule conclusion,
business rules. However, actually there is no standard way for busi- filters, actions and events.
ness rule definitions. Yet there are several rule platforms and rule A rule condition is either a ClassificationCondition, a RoleCondi-
languages: Drools [13] (also known as JBossRules), F-Logic, Jess, tion or AssociationCondition. The rule condition may contain a filter
SWRL. The most important initiative in the process of developing a expression. For example the condition depicted in Figure 1 models
standard for rule interchange is Rule Interchange Format (RIF) [1]. the following logical conjunction:
Their main goal is to define a set of requirements and standards to P roposal($bP roposal) ∧ P roposal($sP roposal)∧
be followed by any translator performing rule interchange between ∧product($bP roposal) = product($sP roposal)∧
existing rules platforms. ∧price($bP roposal) > 0
A use case very well suited for such an environment and also very
well suited to have his behavior modeled with business rules is auto- $sProposal, $bProposal
$bProposal.product=$sProposal.product
mated negotiation. This is a general problem that comprises auctions and $bProposal.price>0
also. In our paper we take as use case the Single Item English Elec- Proposal
tronic Auction [3], [9], [10]. We model its behavior using URML, price : Integer
dateTime : Date
UML-based rule modeling language (URML) [17, 18], a rule mod- type : ProposalType
VR
isValid : Boolean
eling extension of UML([12]).
Opposed to the approach taken by the authors in [15], where the
vocabulary is presented as an ER model, we express the vocabulary Figure 1. A rule condition
as an UML model. In [5], [8] was argued that UML is a de facto
standard for modeling vocabularies. Moreover, in the software engi- A filter is either an OCLFilter or an OpaqueFilter. Classification-
neering community UML class diagrams are widely used to express Condition refers to a UML Class, which is a condition classifier, and
vocabularies. URML, as an extension of UML, it is well suited to consists of an ObjectVariable, which is an instance of the Class; For
capture rules on top of UML vocabularies. example the expression
The goal of the paper is to research the capabilities of URML to
model rules that can be serialized to Drools. $bProposal.product == $sProposal.product
Drools it is the most important and well known open source rule and $bProposal.price > 0
platform. It is friendly to both developers and business users, offers
from Figure 1 is an OCL filter.
1 Brandenburg University of Technology, Germany email: {pascalau, A rule conclusion is either a RoleConclusion, ClassificationCon-
giurca}@tu-cottbus.de clusion, or AttributionConclusion, or AssociationConclusion or an
Action. A more detailed description of these concepts is not possible are written on top of Java Beans, visual modeling with URML is
because of the lack of space. The Figure 2 depicts an action corre- appropriate. The actual Drools IDE functionality and configuration
sponding to the following state change expression is targeted mainly to developers and very technical users as authors
argue in [13](Chapter 5 - The (Eclipse based) Rule IDE). The new
isV alid($bP roposal) feature will overcome this inconvenient and will allow software ar-
chitects and engineers to easily describe the business rules in a visual
i.e. the object property isValid is set to true. way.
Rules are expressed in Drools Rule Language (DRL). It contains
Proposal
price : Integer $bProposal.isValid=true package declaration, imports, globals, functions and rules. Package
dateTime : Date VR declaration and usage are similar to those from Java. A DRL pack-
type : ProposalType U
isValid : Boolean age defines a collection of rules and other related constructs. It rep-
resents a namespace, for the contained rules. Opposed to Java, the
Figure 2. A rule action DRL package name is not related to files or folders in any way. DRL
import statements work and have the same meaning as in Java. Glob-
Actions are used in production rules and in reaction rules. URML als as the name specifies are global variables used mainly to make
supports the following actions: AssertAction, RetractAction, Update- application objects available to rules, for services or to provide data.
Action and InvokeAction. They correspond to the OMG Production According with [13], DRL functions provides a way to put semantic
Rule Representation (PRR) [11]. code in rule source file and are some how equivalent to helper classes
The main advantage of URML is that it extends UML with only from Java. A DRL query is simply a way to query the working mem-
a few visual elements (see Table 1): circles for rules, conditions ar- ory for facts that match the conditions stated.
rows, conclusion arrows, action arrows. Since Drools deals only with Drools manual [13] provides the following example:
production rules, only production rules visual elements of URML are
depicted in Table 1. A condition arrow can be negated and is repre- rule "Approve if not rejected"
sented as a crossed arrow at origin. Conclusion arrows refer to a class salience -100
or an association. Action arrows are double-headed arrows referring agenda-group "approval"
either to a class (in the case of create, delete, assign or invoke ac- when
tion) or to an activity. Rule action arrow is annotated with an action not Rejection()
type (A for Assert Action, R for Retract Action, U for Update Ac- p : Policy(approved == false,
tion, and I for Invoke Action). Variables are denoted in bold (such as policyState:status)
$bProposal). exists Driver(age > 25)
Process(status == policyState)
then
Table 1. URML Production Rule visual elements
log("APPROVED: due to no objections.");
p.setApproved(true);
Rule end
A
Rule condition arrow The above rule has an unique name
("Approve if not rejected"), optional attributes (such
A
as salience -100), conditions identified by when (such as
Negated rule condition arrow
attr = 10
exists Driver(age > 25)) and actions introduced with then
A
U attr (such as p.setApproved(true); ). The conditional part of a
Rule action arrow rule corresponds to a logical formula comprising zero or more Con-
ditional Elements. The concept of Pattern is the main conditional
element. eval is a Boolean expression evaluator. The action part
3 Drools basics contains a list of actions that are to be executed. Drools provides
predefined logical actions such as: insert, update, insertLogical,
Drools is an object oriented business rule management system retract but any valid Java code is also allowed.
(BRMS) and also a Rule Engine based on Charles Forgy’s Rete al-
gorithm [13].
4 Modeling Rules with URML
The Drools architecture is based on three main components: pro-
duction memory that stores the rules, working memory that stores the Automated negotiations e.g. electronic auctions are well suited to be
facts and the inference engine. modeled with rules. The past research was focused on defining and
Drools development platform comes in two flavors: as an Eclipse development of protocols and strategies to be used in multi agent sys-
plug-in Drools IDE and as web application Drools BRMS. The tems that are to perform negotiations [10, 9, 3]. Auctions, a form of
Drools IDE provides developers with an environment to edit and test negotiation mechanism for electronic commerce, are also discussed
rules in various formats, and integrate it deeply with their applica- in a number of papers such as [19, 20, 14].
tions from within Eclipse. The IDE has a textual/graphical rule edi- English Auction is an important type of auction discussed in a wide
tor, a RuleFlow graphical editor, a domain specific language editor. range of papers such as [6, 7, 2], and we consider that the subject is
Our claim is that a visual rule editor is necessary and will enrich far from being finished. The principles of Single Item English Auc-
the Drools IDE with an important and more easy to use ”feature”. tion are: (1) only one item is sold at a time; (2) bidding is open; (3)
In opposition with the already built in rule text editor of the Drools all participants bid against each other openly; (4)each successive bid
IDE this will provide a visual way to model rules. Since Drools rules must be higher than the old one; (5) the seller begins the auction;
(6) buyers bid against each other by raising the price, until only one U R
willing buyer remains. Proposal
$newProposal, $oldProposal
price : Integer $oldProposal
dateTime : Date
type : ProposalType
4.1 The Vocabulary $newProposal.dateTime=system.dateTime isValid : Boolean
$newProposal.type==ProposalType.BID
Buyer and
$oldProposal.type==ProposalType.BID
Our work will use a fragment of the vocabulary (see Figure 3) for and
$buyer $oldProposal.price<$newProposal.price
automated negotiation similar with the one from [2].
$buyer.proposal=$newProposal
IR
Party
Proposal
id
price : Integer
isAllowToPostBid : Boolean 1 1 I I
dateTime : Date
type : ProposalType recordSubmisionTime($newProposal) serialize($oldProposal)
isValid : Boolean
Seller {disjoint, complete}
Figure 6. Bid Improvement Rule: ”Each new bid must be an improvement
Buyer
over the last one. If the submitted bid is an improvement, then update the bid
«enumeration» Product 1..* time.”
ProposalType id
BID = Bid quantity R Proposal
AGR = Agreement type : ProductType price : Integer
dateTime : Date
Buyer type : ProposalType
Figure 3. Negotiation Vocabulary $proposal isValid : Boolean
1 1
$buyer
$proposal
$buyer.proposal=$proposal
Proposals encapsulate data about price, date and time, and product
in auction. They are exchanged between parties. A proposal is either $proposal.dateTime==null
WR
a Bid or an Agreement. A bid is a commitment from a buyer to pay
that price if the bid is declared to be a winning bid (proposal). An
agreement is a proposal upon which all parties were agreed.
Figure 7. Withdraw Proposal Rule: ”Buyers proposals that are not best pro-
posal have to be withdrawn.”
4.2 The Rules
introduces a packaging model for the rules. Actually URML does
The aim of this section is to model rules that automate the negotiation
not provide a package modeling therefore actually we consider rule
in Single Item English Auction.
diagrams in the same folder to be part of the same package.
U Proposal To illustrate URML capabilities we model one rule from each
$sProposal, $bProposal
price : Integer package obtained from the ontology.
dateTime : Date
type : ProposalType The URML representation of a validation rule is depicted in
isValid : Boolean
Figure 4. The rule uses the following vocabulary beans: Buyer,
Buyer Seller, Proposal and Product.
Seller $bProposal.product=$sProposal.product We have a buyer ($buyer), a seller ($seller), two proposals
$buyer
$bProposal.isValid=true
and $bProposal.price>0 ($bProposal and $sProposal): one for the buyer and one for
$seller the seller.
The arrow condition comes with variables (e.g. $bP roposal) and
$buyer.proposal=$bProposal
filter expressions $bProposal is buyer’s proposal and is bound to
$seller.proposal=$sProposal
VR the buyer’s proposal. For this we use a condition arrow going from
buyer to rule that says $buyer.proposal=$bProposal. The
same works for the seller.
Figure 4. Validation Rule: ”A valid proposal is a proposal that is about the
The action performs a setter call on the isValid property of the
product from seller proposal and the submitted proposal price is greater than
$bProposal.
0.”
The posting rule (Figure 5) determines when a party can post a
proposal.
Party
Improvement rules define the way bids are posted. In a Single Item
Buyer
id English Auction each successive bid must be an improvement, there-
U isAllowToPostBid : Boolean
fore its price must be greater than the $oldProposal price. This
$buyer.isAllowToPostBid=true $party is exactly what the rule from Figure 6 does.
$party instanceOf Buyer
Another protocol enforcement rule is shown in Figure 7. If the
PostR
proposal $proposal belongs to a $buyer and it is not the best pro-
posal(i.e. dateT ime is null) then withdraw $proposal.
The Figure 8 depicts the model of a display rule. This rule refers
Figure 5. Posting Rule: ”Only buyers parties are allowed to post bids.” to the package updating status and information of participants and
specifies which party can see a new proposal. In Single Item English
In [3] rules are classified in taxonomies such as: proposal valid- Auction every new proposal is known to all parties involved in auc-
ity, protocol enforcement, updating status and information of par- tion.
ticipants, agreement formation, termination. These rules taxonomy
Termination rules define conditions when an auction is terminated. //...
The Figure 9 depicts an URML model of such rule. }
Proposal function serialize(Proposal $p){
$proposal
price : Integer
Buyer dateTime : Date //...
type : ProposalType }
isValid : Boolean
$buyer
$proposal.dateTime!=null The rule is part of a specific package i.e.
and $proposal.type==ProposalType.BID
org.ruleapp.rules.improvement encoded in the cor-
$buyer.proposal=$proposal responding DRL package declaration.
DispR informParty() The rule (as seen in the URML model) uses the classes Proposal,
I Buyer and ProposalType therefore all of them should be available to
the engine (as Java Beans). We make them available by generating
Figure 8. Display Proposal Rule: ”If a new proposal has been posted into the appropriate import commands.
the system then all parties must be informed about this.” The name of the Drools rule (IR) is the same with the name from
the visual model.
The filter condition
Proposal
$proposal.type==ProposalType.AGREEMENT price : Integer
$newProposal.type==ProposalType.BID and
and $proposal.dateTime!=null dateTime : Date $oldProposal.type==ProposalType.BID and
$proposal type : ProposalType
isValid : Boolean
$oldProposal.price < $newProposal.price
generates the conditions (i.e. the when
I part) in the Drools rule. While parts such as
TR terminate()
$newProposal.type==ProposalType.BID
have immediate translation, the part
$oldProposal.price < $newProposal.price re-
Figure 9. Termination Rule: ”If type of the current proposal from working quires the generation of new variables ($nPrice and $oPrice)
memory is AGREEM EN T and dateT ime of proposal is not null then the before the condition evaluation. Readers may notice that this filter
auction can be terminated.” can be also implemented by means of an eval() call but then the
rule become less declarative.
Our actions are:
5 URML Rules as Drools Rules 1. an invoke action (I) corresponding to the function call
This Section presents how a rule modeled with URML can be seri- recordSubmisionTime($newProposal);
alized to Drools. Consider the improvement rule (see Figure 6). The 2. an update action which normally translates into a Drools standard
below code is the Drools DRL: action update
3. another invoke action (i.e. serialize($oldProposal);)
package org.ruleapp.rules.improvement; and
4. a retract action (R) generating the code
import org.ruleapp.vocabulary.Proposal; retract($oldProposal);
import org.ruleapp.vocabulary.Buyer;
import org.ruleapp.vocabulary.ProposalType;
6 Future Work
rule "IR" While the translation of all of these actions to Drools code is straight-
when forward by using DRL functions one major disadvantage of the ac-
$oldProposal:Proposal( tual URML language is that it does not offer a way to specify the
type == ProposalType.BID, order of actions in the rule action part. For example, looking to the
$oPrice:price rule diagram from Figure 6 it is not clear both for a human expert and
) a machine in which order the depicted actions have to be performed.
$newProposal:Proposal( The translation, presented in this paper was done manually and is
type == ProposalType.BID, intended as example for a potential implementation, that would have
$nPrice:price, to perform it automatically.
$nPrice > $oPrice Our proposal is to extend the URML metamodel by allowing se-
) quence actions i.e an ordered sequence of standard actions as in the
then Figure 10 .
recordSubmisionTime($newProposal); Other open issues are: (1) Drools provides DRL queries while
update($newProposal); URML does not provide any visual construct modeling that; (2)
serialize($oldProposal); URML does not provide any annotations to encode various DRL
retract($oldProposal); rules attributes.
end Drools complex constructs offering integration with databases
such as collect and accumulate are not yet supported by the
function recordSubmisionTime(Proposal $p){ visual language.
Proposal [6] Esther David, Rina Azoulay-Schwartz, and Sarit Kraus, ‘An English
$newProposal, $oldProposal Auction Protocol for Multi-attribute Items’, in Proceedings of the Work-
price : Integer
dateTime : Date shop on Agent Mediated Electronic Commerce on Agent-Mediated
type : ProposalType Electronic Commerce IV, Designing Mechanisms and Systems, volume
isValid : Boolean 2531 of Lecture Notes in Computer Science, pp. 361 – 378. Springer
Buyer Berlin / Heidelberg, (2002). http://dx.doi.org/10.1007/
3-540-36378-5_4.
$newProposal.type==ProposalType.BID
$buyer and [7] Esther David, Alex Rogers, Jeremy Schiff, Sarit Kraus, and Nicholas R.
$oldProposal.type==ProposalType.BID Jennings, ‘Optimal Design Of English Auctions With Discrete Bid Lev-
and els’, in Proceedings of the 6th ACM conference on Electronic com-
$oldProposal.price<$newProposal.price
merce, Vancouver, BC, Canada, pp. 98 – 107. ACM New York, NY,
$buyer.proposal=$newProposal USA, (2005).
IR [8] Giancarlo Guizzardi, Gerd Wagner, and Heinrich Herre, ‘On the Foun-
dations of UML as an Ontology Representation Language’, in Proceed-
ings of 14th International Conference on Engineering Knowledgein
the Age of the Semantic Web EKAW 2004, eds., Enrico Motta, Nigel
I Shadbolt, Arthur Stutt, and Nicholas Gibbins, volume 3257 of Lecture
Notes in Computer Science, pp. 47 – 62. Springer Berlin / Heidelberg,
recordSubmisionTime($newProposal) (5-8 October 2004). http://www.loa-cnr.it/Guizzardi/
EKAW.pdf.
[9] Nicholas R. Jennings, Peyman Faratin, A. R. Lomuscio, Simon Par-
U sons, Michael Wooldridge, and Carles Sierra, ‘Automated Negotiation:
Prospects, Methods and Challenges’, Group Decision and Negotia-
$newProposal
tion, 10(2), 199 – 215, (March 2001). http://dx.doi.org/10.
1023/A:1008746126376.
[10] Sarit Kraus, ‘Negotiation and cooperation in multi-agent environ-
I ments’, Special issue on economic principles of multi-agent systems,
serialize($oldProposal) 94(1-2), 79 – 98, (1997). http://iskp.csd.auth.gr/mtpx/
agents/material/kraus97negotiation.pdf.
[11] OMG. Production rule representation (prr), beta 1. http://www.
R omg.org/docs/dtc/07-11-04.pdf, November 2007.
[12] Object Management Group (OMG). UML 2.0 Superstructure
$oldProposal Specification. http://www.omg.org/cgi-bin/doc?ptc/
2003-08-02, August 2002.
[13] Mark Proctor, Michael Neale, Michael Frandsen, Sam Griffith Jr.,
Figure 10. ”The New Bid Improvement Rule” Edson Tirelli, Fernando Meyer, and Kris Verlaenen. Drools
4.0.5. http://downloads.jboss.com/drools/docs/4.0.
5.19064.GA/html_single/index.html, January 2008.
Finally user-defined actions encoded by plain Java code are not [14] Daniel Rolli and Andreas Eberhart, ‘An Auction Reference Model
yet supported. Our future work will investigate the need of an exten- for Describing and Running Auctions’, Wirtschaftsinformatik
sion of the visual language that allows UML opaque expressions to 2005, 289 – 308, (2005). http://dx.doi.org/10.1007/
3-7908-1624-8_16.
encode these actions. [15] Valentina Tamma, Michael Wooldridge, Ian Blacoe, and Ian Dickinson,
A potential URML implementation for Drools rules must extends ‘An Ontology Based Approach to Automated Negotiation.’, in Pro-
the actual Eclipse IDE by allowing at least UML class diagrams, rule ceedings of the Workshop on Ontologies in Agent Systems, Bologna,
diagrams and rule packages. Italy, AMEC02, volume 2531 of Lecture Notes in Computer Science,
pp. 317 – 334. Springer Berlin / Heidelberg, (2002). http://dx.
doi.org/10.1007/3-540-36378-5_14.
[16] Gerd Wagner, Adrian Giurca, and Sergey Lukichev, ‘A Gen-
REFERENCES eral Markup Framework for Integrity and Derivation Rules’,
in Principles and Practices of Semantic Web Reasoning, eds.,
[1] RIF Basic Logic Dialect. http://www.w3.org/2005/rules/ François Bry, François Fages, Massimo Marchiori, and Hans-
wiki/BLD, October 2007. Jürgen Ohlbach, number 05371 in Dagstuhl Seminar Proceed-
[2] Costin Badica, Adrian Giurca, and Gerd Wagner, ‘Using Rules and ings, Dagstuhl, Germany, (2005). Internationales Begegnungs- und
R2ML for Modeling Negotiation Mechanisms in E-Commerce Agent Forschungszentrum für Informatik (IBFI), Schloss Dagstuhl, Ger-
Systems’, in Proceedings of the 2nd International Conference on many. http://drops.dagstuhl.de/opus/volltexte/
Trends in Enterprise Application Architecture, TEAA2006, eds., Dirk 2006/479/pdf/05371.GiurcaAdrian.Paper.479.pdf.
Draheim and Gerald Weber, volume 4473 of Lecture Notes in Com- [17] Gerd Wagner, Adrian Giurca, and Sergey Lukichev, ‘A Usable Inter-
puter Science, pp. 84 – 99. Springer, (November 2006). http: change Format for Rich Syntax Rules. Integrating OCL, RuleML and
//dx.doi.org/10.1007/978-3-540-75912-6_7. SWRL’, in Proceedings of Reasoning on the Web 2006, Edinburgh,
[3] Claudio Bartolini, Chris Preist, and Nicholas R. Jennings, ‘A Generic Scotland, (May 2006). http://www.aifb.uni-karlsruhe.
Framework for Automated Negotiation’, Technical report, HP Labs, de/WBS/phi/RoW06/procs/wagner.pdf.
(January 2002). http://www.hpl.hp.com/techreports/ [18] Gerd Wagner, Adrian Giurca, Sergey Lukichev, Grigoris An-
2002/HPL-2002-2.pdf. toniou, Carlos Viegas Damasio, and Norbert E. Fuchs, ‘Lan-
[4] Saartje Brockmans, Peter Haase, Pascal Hitzler, and Rudi Studer, ‘A guage Improvements and Extensions’, Technical Report I1-
Metamodel and UML Profile for Rule-Extended OWL DL Ontologies’, D8, REWERSE, (April 2006). http://rewerse.net/
in Proceedings of 3rd European Semantic Web Conference, ESWC deliverables-restricted/i1-d8.pdf.
2006, Budva, Montenegro, volume 4011 of Lecture Notes in Computer [19] Peter R. Wurman, Michael P. Wellman, and William E. Walsh, ‘A
Science, pp. 303 – 316. Springer Berlin / Heidelberg, (June 2006). Parametrization of the Auction Design Space’, Games and Economic
http://dx.doi.org/10.1007/11762256_24. Behavior, 35, 304 – 338, (2001). http://www4.ncsu.edu/
[5] Stephen Cranefield and Martin Purvis, ‘UML as an Ontol- ˜wurman/Papers/Wurman-GEB-00.pdf.
ogy Modelling Language’, in Proceedings IJCAI-99 Work- [20] Peter R. Wurman, Michael P. Wellman, and William E. Walsh, ‘Speci-
shop on Intelligent Information Integration, (1999). http: fying Rules for Electronic Auctions’, AI Magazine, 23, (2002). http:
//hcs.science.uva.nl/usr/richard/workshops/ //www4.ncsu.edu/˜wurman/Papers/AI-Mag-WWW.pdf.
ijcai99/UML_Ontology_Modelling.pdf.