Modelling Web Service Personalization with Rule Nets Wei Wang1 , Sheng Zong2 , Jian Yu3 , and Sira Yongchareon4 1
School of Digial Information Technology ZheJiang Technical Institute of Economics, Hangzhou 310018, China
[email protected] 2 Cooperation Communication Operating and Support Centre, China Telecom, Hangzhou 310006, China
[email protected] 3 School of Computing and Mathematical Sciences, Auckland University of Technology, Auckland 1010, New Zealand
[email protected] 4 Department of Computing, Unitec Institute of Technology, Auckland, NZ
[email protected]
Abstract. Web service personalization is an important research topic in the area of service-oriented computing which has the potential to bring more service value to end users that are fit for individual user’s particular needs. In this paper, we propose Rule nets, which is based on PrT (Predicate/Transition) nets. Rule nets has the capability to model a wide spectrum of rules for expressing personalization needs. There rules then can be woven to a business process to bring flexible personalization features to this process. The woven process can be expressed as a PrT net suitable for formal analysis and simulation using existing Petri net tools. Keywords: Web service personalization, Petri nets, business rules, Business process modelling.
1
Introduction
Personalization in the area of service-oriented computing is emerging as an important topic with the transformation of Internet and Web from traditional linking and sharing of computers and documents (i.e., ”Web of Data”) to current connecting of people (i.e., ”Web of People”) [1,2] , reflected by the popularity of social networks such as Facebook and Linkedin. To implement web service personalization, a major hurdle to cross is to ensure that personalization features of a service can be well modelled and integrated in a web services, for example, a BPEL web service process. However, the personalization logic encoded in a service processes is often hard-coded and difficult to change. Z. Huang et al. (Eds.): WISE 2013 Workshops 2013, LNCS 8182, pp. 228–238, 2014. c Springer-Verlag Berlin Heidelberg 2014
Modelling Web Service Personalization with Rule Nets
229
In this paper, we use business rules to model the personalization logic of a web service process, and then use Predicate/Transition nets (PrT nets) [3], a kind of widely used high-level Petri nets, to model both business processes and business rules, and then use an aspect-oriented mechanism to weave them into a coherent PrT net. The rationale behind our approach is that Petri nets have long been recognised as a valuable tool for modelling business processes [4], and PrT nets are suitable for dealing with logic and rules [5]. Our modelling approach features the following benefits. Firstly, a unified language is used to formally specify the software design instead of ad-hoc mixing of process specification and personalization specification. Secondly, in our approach, the modularity of the personalization logic is well-kept which eases the maintenance and evolution of the design specification. The rest of this paper is organised as follows: Section 2 briefly review business rules and how to use them to express personalization logic. Some fundamental concepts and definitions that underpin the discussion throughout the paper. Section 3 defines rule nets and explains how to model business rules with rule nets. Section 4 specifies the PrT net-based aspect and the weaving mechanism. Finally, Section 5 discusses and concludes the paper.
2
Business Rules and Personalization
In this section, we briefly review the concepts of business rule and aspectorientation. Some example rules and aspects used throughout the paper are also discussed. According to the Business Rules Group [6], a business rule is a statement that defines or constrains some aspect of a business. It is intended to assert business structure or to control the behaviour of the business. In [9], business rules are classified into four types as the following: – A constraint rule is a statement that expresses an unconditional circumstance that must be true or false. – An action-enabler rule is a statement that checks conditions and initiates some actions upon finding the conditions true. – A computation rule is a statement that checks a condition and when the result is true, provides an algorithm to calculate the value of a term. – An inference rule is a statement that tests conditions and establishes the truth of a new fact upon finding the conditions true. For instance, a travel-package-requesting scenario could have the following business rules [7]: R1 (constraint rule): a vacation request must have a departure airport and a destination airport. R2 (action-enabler rule): if no flight is found, do not look for accommodation. R3 (computation rule): if more than 2 persons travel together, give 10% discount to the total price. R4 (inference rule): if a customer is frequent customer, he gets a discount of 5%.
230
W. Wang et al.
The reason that why R4 is an inference rule is that to resolve what is a frequent customer, we need another two rules: R5 (constraint rule): if a customer has bought more than 5 travel packages, he is a frequent customer. R6 (constraint rule): if a customer has bought products for a sum exceeding 4000 euros, he is a frequent customer. Clearly all the above discussed four types of business rules can be used to declarative express individual user’s personalization logic.
3
Rule Nets
In this section, we formally define rule nets, and then demonstrate how to use rule nets to model the four types of rules discussed in Section 2. 3.1
PrT Nets
Since rule nets are a sub-set of PrT nets, here we first give the structural definition of PrT nets for the self-containness of this paper. Definition 1 (PrT nets). A PrT net N is a tuple (P, T, F, Σ, L, ϕ, M0 ) [9], where: – P is a finite set of predicates, T is a finite set of transitions (P ∩ T = ∅, P ∪ T = ∅), and F ⊆ (P × T ) ∪ (T × P ) is the set of arcs. (P, T, F) forms a directed net. – Σ is a finite set of constants, operations, and relations. – L is a labelling function on arcs. Given an arc f ∈ F , the labelling of f, L(f ), is a set of labels, which are n-tuples of individuals and variables where n is the arity of the predicate connected to the arc. – ϕ is a formula inscription function on transitions. Given a transition t ∈ T, ϕ(t) is a logical formula built from variables and the individuals, operations, and relations in structure Σ, where variables occurring free in a transition have tooccur at an adjacent input arc of the transition. – M0 = p∈P M0 (p) is the initial marking, where M0 (p) is the set of tokens residing in predicate p. Each token is a tuple of constants or structured terms constructed from the constants and operations in Σ. For the convenience of discussion, we also define the following concepts: – – – – – –
The The The The The The
preset of an element x is: • x = {y|(y, x) ∈ F }. postset of an element x is: x• = {y|(x, y) ∈ F }. input predicates of a net N is: inP (N ) = {p ∈ P |• p = ∅}. input transitions of a net N is: inT (N ) = {t ∈ T |• t = ∅}. output predicates of a net N is: outP (N ) = {p ∈ P |p• = ∅}. output transitions of a net N is: outT (N ) = {t ∈ T |t• = ∅}.
Modelling Web Service Personalization with Rule Nets
3.2
231
Rule Nets
Definition 2 (Rule nets). A PrT net N = (P, T, F, Σ, L, ϕ, M0 ) is a rule net if and only if: – There is one source place i ∈ P such that • i = ∅. – There is one sink place o ∈ P such that o• = ∅. – Every node x ∈ P ∪ T is on a path from i to o. Note that the above definition is adapted from the definition to Workflow nets [8]. So all the structural analysis approaches for Workflow nets can also be applied to rule nets. Syntactically, we classify the transitions in a rule net with three stereotypes: – An action transition TA represents a business activity, e.g., get flight. – A computation transition TC represents the specific action of assigning variables with arithmetic expressions, e.g., assigning price × 90% to the variable price. – And a dummy transition TD does nothing. Transition stereotypes provide additional information to a net at the business level; they do not change the behavioural semantics of rule nets. Definition 3 (Constraint nets). A constraint net is a rule net with only one dummy transition t, and ϕ(t) = ∅. To model a constraint rule, we use a dummy transition with its inscription representing the constraints. For example, R1 (A vacation request must have a departure airport and a destination airport) can be modelled as the constraint net in Fig. 1.
tD_CheckRequest
req.GHSW3RUWQXOO && req.DUU3RUWQXOO
Fig. 1. Constraint net R1
Definition 4 (Action-enabler nets). An action-enabler net is a rule net containing at least one action transition t, and ϕ(t) = ∅. To model an action-enabler rule, we use an action transition to represent the business activity, and the inscription of this transition representing the enabling condition. For example, R2 (If no flight is found, do not look for accommodation) can be modelled as the action-enabler net in Fig. 2.
232
W. Wang et al. tD
flt == null
tA_GetAccommodation
IOWQXOO
Fig. 2. Constraint net R2
Definition 5 (Computation nets). A computation net is a rule net with only one computation transition. For example, R3 (If more than 2 persons travel together, give 10% discount to the total price) can be modelled as the computation net in Fig. 3. Note that the computation expression is reflected in the name of the transition.
tC_price *=(1-10%)
cust.number >2
Fig. 3. Computation net R3
Definition 6 (Inference nets). An inference rule is created by composing two rule nets with AND-JOIN, OR-JOIN, or SEQ-JOIN1 . Intuitively, if we connect two rule nets with AND-JOIN, then the composed rule net means the conjunction of the two rules; if we connect two rule nets with OR-JOIN, then the composed rule net means the disjunction of the two rules. As shown in Fig 4, supposing o1 and o2 are the sink places (or the consequents) of two rule nets, then the conjunction of the two rule nets is depicted in Fig 4.a, which means that the predicate o is determined by o1 AND o2 ; while the ORJOIN of the two rules is depicted in Fig 4.b, which means that the predicate o is determined by o1 OR o2 . Note that AND-JOIN and OR-JOIN are also two workflow patterns defined in [8]. The sequential join of two rule nets means that the resolve of one rule net depends on the consequents of the other rule net. The SEQ-JOIN operation fuses the source place of the dependent net with the sink place of the independent rule net. Usually, an inference net can be built first by introducing the net representing the final goal, and then introducing the rules backwards with the SEQ-JOIN 1
For space limitations, here we only informally introduce the three operators of rule nets.
Modelling Web Service Personalization with Rule Nets
233
o1
o1
o
o o2
o2
(a) AND-JOIN
(a) OR-JOIN
Fig. 4. The AND-JOIN and OR-JOIN of two rule nets
operation based on the cause-effect relations until all the newly introduced rules are resolvable. Taking R4 (textitif a customer is frequent, he qualifies for a discount of 5%) as an example, to resolve the meaning of frequent, we need another two rules: R5 (if a customer has bought more than 5 travel packages, he is a frequent customer), and R6 (if a customer has bought products for a sum exceeding 4000 euros, he is a frequent customer). Fig. 5.a, b and c are the rule nets for R4 , R5 and R6 respectively. Because R4 depends on the consequent of R5 or R6 , we use OR-JOIN to compose them and then use SEQ-JOIN to connect the combined consequent to the rule net of R4 to form a complete inference rule net as depicted in Fig. 5.d. Looking closely, we can find that R4 is represented by a computation net, and R5 and R6 constraint nets. So an inference net is in fact the composition of other forms of rule nets. With this example, we also demonstrate the power of PrT nets in modelling complex rules.
Tc_cust.price*=(1-5%)
customer
discount
(a) R4 customer
frequent
customer
cust.pkgBought
frequent cust.sumBought
>5
>4000
(b) R5
(c) R6 OR-join
customer
cust.pkgBought
>5
Tc_cust.price*=(1-5%)
cust.sumBought
>4000
(d) The inference rule net
Fig. 5. The inference rule derived from R4 , R5 , and R6
discount
234
4
W. Wang et al.
Weaving Rule Nets into Process Nets
Corresponding to rule nets, we use the term process nets to call the PrT nets representing business processes. For example, Fig. 6 is the process net N for the travel package request process described in Section 2. Request getFlight
getAccommodation
Result
Fig. 6. Travel package request process net N
Just like aspect-oriented programming, we use pointcut to select a transition as join point. Without losing generality, every pointcut can only select one transition to simplify the definition of weaving. The advices are represented by rule nets. A rule net can be weaved into a process net either bef ore, af ter, or around a pointcut/transition. Another important concept is context net, for exposing context of the process net to the rule net. It is interesting to note that the process net and its rule nets could be authored independently, which reflects the modular feature of aspect-orientation. To weave them smoothly, we use context net to put them in the same context and mediate possible parameter inconsistencies. For example, the input parameters for the transition N.getF light is a structure < Customer, Request >, but its constraint net R1 accepts < Request > as input. Finally, we can wrap up pointcuts, advices, and context net into an aspect. To demonstrate our idea, before formally defining the above concepts, we give an example on how to weave the rule net R1 before N.getF light. Fig. 7 presents an aspect asp rule1 . The context net is built first by introducing the preset of the pointcut, i.e. transition N.getF light, as initial context, and then splitting the request to match the input of the advice net, finally merging the results and transferring them back to the cutting point. Note that we use round rectangle to represent the net R1 for simplicity. Fig. 8 is the resulting net after we weave asp rule1 into N . This net is built simply by putting the context net and the process net together, and then deleting the arcs between the cutting point and its preset because it is a bef ore cut. Note that elements with the same names are merged to reflect the expansion of context. The formal definitions on weaving business processes and rules, are given as the following. Definition 7 (Pointcuts). A pointcut over a PrT net N is a transition in N. The syntax is: pointcut < N.transition >; For brevity, a pointcut has the same name as its transition. This transition is called the cutting transition. Definition 8 (advices). An advice has the form: advice < adviceN ame > bef ore|af ter|around < cutN ame >:< R >; Where R is a rule net, which is also called the advice net of this advice. So there are three types of advice: before advice, after advice, and around advice.
Modelling Web Service Personalization with Rule Nets
235
Aspect asp_rule1{ pointcut N.getFlight; advice a_checkRequest before N.getFlight: R1; R1: checkRequest
Pa1
Pa2
req.GHSW3RUWQXOO && req.DUU3RUWQXOO
context(a_checkRequest): Nc1; Nc1:
R1
N.Request
N.getFlight
Fig. 7. Aspect asp rule1
R1
Request
getFlight
getAccommodation
Result
Fig. 8. Resulting net of weaving N and asp rule1
Definition 9 (contexts). A context has the form: context(< adviceN ame >) :< N et >; For brevity, a context has the same name as its associated net. Depending on the type of the related advice, a context net has the following constraints. – Before advice: • pointcut ⊆ inP (contextN et) & pointcut ∈ outT (contextN et). – After advice: pointcut ∈ inT (contextN et) & N.t•i ⊆ outP (contextnet). ⊆ inP (contextN et) & pointcut• ⊆ – Around advice: • pointcut outP (contextN et). These constraints ensure that the weaving of a process net and a context net always produces another consistent process net. Definition 10 (Aspects). A PrT net-based aspect A is a 3-tuple (Pcut, Adv, Ctx) where Pcut is a set of pointcuts, Adv is a set of advices, and Ctx is a set of contexts. Definition 11 (Net weaving). The weaving of a process net N and an aspect A is defined as2 : 2
We use N.x to represent component x of N .
236
W. Wang et al.
– For every before advice advi , its cutting transition N.ti , and its context net Nci , the weaving of advi and N is a new PrT net Nw : Nw .X = N.X ∪ Nci .X, where X ∈ {P, T, L, ϕ, M0 }, and Nw .F = N.F ∪ Nci .F \ N.• ti × N.{ti }. – For every after advice advi , its cutting transition N.ti , and its context net Nci , the weaving of advi is a new PrT net Nw : Nw .X = N.X ∪ Nci .X, where X ∈ {P, T, L, ϕ, M0 }, and Nw .F = N.F ∪ Nci .F \ N.{ti } × N.• ti . – For every around advice advi , its cutting transition N.ti , and its context net Nci , the weaving of advi and N is a new PrT net Nw : Nw .X = N.X ∪ Nci .X, where X ∈ {P, L, ϕ, M0 }, and Nw .T = N.T ∪ Nci .T \ N.{ti } and Nw .F = N.F ∪ Nci .F \ N.• ti × N.{ti } \ N.{ti } × N.• ti . From Definition 11, we can infer that weaving N with a before advice is to compose N with the context net of the before advice and deleting the arcs between the cutting transition and its preset, just as what we did in the example shown in Fig. 7. Weaving N with an after advice is to compose N with the context net of the after advice and deleting the arcs between the cutting transition and its postset. Finally, weaving N with an around advice is to compose N with the context net of the around advice, and deleting the cutting transition and its arcs. The reason why we let around weaving delete the cutting transition is that the semantics of the cutting transition will be reiterated in the advice net if necessary. The above weaving definition assumes that a process net does not share names with advice nets. This assumption can be relaxed by either renaming or following a naming convention [10]. If more than two advices are related to one cutting transition, a weaving sequence may be necessary. Because around weaving deletes the cutting transition, it should always be put in the last. And we should prevent relating more than two around advices to a transition.
5
Discussion and Conclusion
PrT nets are a high-level formalism of Petri nets suitable for modelling, analysing, and simulating the behaviour of software systems. In [5], the authors proposed an efficient reachability analysis technique for PrT nets based on the compact structure of planning graphs. Prod [11] is another tool for reachability analysis. In [12], PrT nets are translated to Promela, the input language of model checker Spin, and various temporal properties can be checked automatically. As far as the graphical editor is concerned, SEA [13] is an integrated environment for visual modelling and simulating PrT nets that runs on Solaris. Recently, Rock et al. extend the Petri Net Kernel tool [14] to support the graphical modelling and invariants computation of PrT nets [15]. The stream of work that is particularly relevant to our work is composing PrT nets from an aspect-oriented point of view, and weaving rules with processes. As far as we know, only Xu et al. proposed an aspect-oriented PrT net model
Modelling Web Service Personalization with Rule Nets
237
[14]. In their work, advice nets and the base net are woven in a tightly coupled fashion: they must share the same variable type at the cutting point. Instead, we use context nets to allow a flexible weaving. Also their model is not intuitive in terms of the concept mapping between aspect-oriented programming and aspectoriented PrT nets. The important concepts of advice type, i.e. bef ore, af ter, and around are lost in their model. In this paper, we have presented Rule nets, a special PrT nets used to express the personalization rules of web services. PrT nets as a kind of Petri nets are suitable for process modelling. Its logic aspect also makes it a good candidate for modelling rules. We defined a kind of special PrT, the rule nets, to model the four types of business rules. Corresponding to the principle of aspect oriented programming, we defined the net-based aspect and the weaving mechanism to integrate rules nets and process nets. The woven net not only keeps the modularity of rules, but also is ready for analysis and simulation by various PrT techniques and tools. We view our work presented in this paper as a first step towards a formalised model-driven approach of developing flexible personalised web services. Our future work includes elaborating the composition of rule nets, providing an integrated graphical environment for the modelling, weaving and analysis of rule nets, automatic translation from personalization rules to rule nets.
References 1. Han, J., Han, Y., Jin, Y., Yu, J.: Personalized active service spaces for end-user service composition. In: IEEE International Conference on Services Computing SCC, pp. 198–205 (2006) 2. Yu, J., Wang, J., Han, Y., Yang, S., Zhang, L.: Developing End-User Programmable Service-Oriented Applications with VINCA. In: Workshop on Web Logistics (2004) 3. Genrich, H.J.: Predicate/Transition Nets. In: Brauer, W., Reisig, W., Rozenberg, G. (eds.) APN 1987. LNCS, vol. 254, pp. 207–247. Springer, Heidelberg (1987) 4. van der Aalst, W.M.P., van Hee, K.: Workflow Management: Models, Methods, and Systems. MIT Press, Cambridge (2002) 5. Xu, D., Yin, J., Deng, Y., Ding, J.: A Formal Architecture Model for Logical Agent Mobility. IEEE Trans. on Software Engineering. 29(1), 31–45 (2003) 6. The Business Rules Group: Defining Business Rules, What Are They Really? http://www.businessrulesgroup.org 7. Charfi, A., Mezini, M.: Hybrid Web Service Composition: Business Processes Meet Business Rules. In: 1st International Conference on Service Oriented Computing ICSOC, pp. 30–38 (2004) 8. van der Aalst, W.M.P., van Hee, K.: Workflow Management: Models, Methods, and Systems. MIT Press, Cambridge (2002) 9. von Halle, B.: Business Rules Applied: Building Better Systems Using the Business Rules Approach. Wiley (2001) 10. Xu, D., Nygard, K.E.: Threat-Driven Modeling and Verification of Secure Software Using Aspect-Oriented Petri Nets. IEEE Trans. on Software Engineering 32(4), 265–278 (2006) 11. PROD: An Advanced Tool for Efficient Reachability Analysis, http://www.tcs.hut.fi/Software/prod/
238
W. Wang et al.
12. Ding, J., Dai, Z., Wang, J., He, X.: Formally Modeling and Analyzing a Secure Mobile Agent Finder. In: 2005 IEEE International Conference on Systems, Man and Cybernetics, pp. 47–52 (2005) 13. SEA: The System Engineering and Animation Environment, http://jerry.c-lab.de/sea/ 14. Petri Net Kernel, version 2.2, http://www.informatik.hu-berlin.de/top/pnk/index.html 15. R¨ ock, A., Kresman, R.: On Petri Nets and Predicate-Transition Nets. In: 2006 International Conference on Software Engineering Research and Practice, pp. 903– 909 (2006)