JESS: [EXTERNAL] Representing jess rule from nested objects
[email protected] Thu, 11 Jul 2013 13:07:51 +0800
| Newsgroups | gmane.comp.java.jess |
|---|---|
| Message-ID | <473EC65F3730D84CB06326B8ABEA78200188205CF346@SGPPCMMGMB03.INTRANET.BARCAPINT.COM> |
--_000_473EC65F3730D84CB06326B8ABEA78200188205CF346SGPPCMMGMB0_
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Hi Jess Experts,
I am a JESS newbie and want to understand whether I am writing the below =
rule in JESS correctly:
We have a User Object and each user has a set of applications associated.=
=20Each application has a set of accounts and in turn each account has a =
set of profiles.
User Hierarchy:
User {username}
List of Applications {Application - {appName, userName}}
List of Accounts - { Account - {accountName, appName, username}}
List of Profiles - {Profile - {name, accountName, username}}
The rule we want to check is
If an user has a Profile (name =3D A) in account 1, Profile (name =3D B) =
in the same account (account 1)
and Profile (name =3D C) in account 2, Profile (name =3D D) in account 2
then fire the rule.
Jess Rule:
(defrule AFTS_RULE_01
(User (userName ?userName))
(Application (appName ?appName&:(eq ?appName "AFTS")) (userName ?userName=
))
(Account (accountName ?accountName1) (userName ?userName))
(Profile (name ?name1&:(eq ?name1 "A")) (accountName ?accountName1) (user=
Name ?userName))
(Profile (name ?name2&:(eq ?name2 "B")) (accountName ?accountName1) (user=
Name ?userName))
(Account (accountName ?accountName2&~accountName1) (userName ?userName))
(Profile (name ?name3&:(eq ?name3 "C")) (accountName ?accountName2) (user=
Name ?userName))
(Profile (name ?name4&:(eq ?name4 "D")) (accountName ?accountName2) (user=
Name ?userName))
=3D>
(printout t "ATFS Rule satisfied for " ?appName crlf)
)
Currently we have introduced a variable username in all the objects to ma=
intain the relationship between the User object and the child objects.
Is the above rule representation correct or is there a better way to repr=
esent this rule in Jess?
Regards
Srinath
_______________________________________________
This message is for information purposes only, it is not a recommendation=
, advice, offer or solicitation to buy or sell a product or service nor a=
n official confirmation of any transaction. It is directed at persons who=
=20are professionals and is not intended for retail customer use. Intende=
d for recipient only. This message is subject to the terms at: www.barcla=
ys.com/emaildisclaimer.
For important disclosures, please see: www.barclays.com/salesandtradingdi=
sclaimer regarding market commentary from Barclays Sales and/or Trading, =
who are active market participants; and in respect of Barclays Research, =
including disclosures relating to specific issuers, please see http://pub=
licresearch.barclays.com.
_______________________________________________
--_000_473EC65F3730D84CB06326B8ABEA78200188205CF346SGPPCMMGMB0_
Content-Type: text/html;
charset=us-ascii
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-mi=
crosoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:wo=
rd" xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D=
"http://www.w3.org/TR/REC-html40"><head><meta http-equiv=3DContent-Type c=
ontent=3D"text/html; charset=3Dus-ascii"><meta name=3DGenerator content=3D=
"Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
=09{font-family:Calibri;
=09panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
=09{margin:0cm;
=09margin-bottom:.0001pt;
=09font-size:11.0pt;
=09font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
=09{mso-style-priority:99;
=09color:blue;
=09text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
=09{mso-style-priority:99;
=09color:purple;
=09text-decoration:underline;}
span.EmailStyle17
=09{mso-style-type:personal-compose;
=09font-family:"Calibri","sans-serif";
=09color:windowtext;}
.MsoChpDefault
=09{mso-style-type:export-only;}
@page WordSection1
=09{size:612.0pt 792.0pt;
=09margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
=09{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-GB link=3Dblue v=
link=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal>Hi Jess Expe=
rts,<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p class=3DM=
soNormal>I am a JESS newbie and want to understand whether I am writing t=
he below rule in JESS correctly:<o:p></o:p></p><p class=3DMsoNormal><o:p>=
</o:p></p><p class=3DMsoNormal>We have a User Object and each user =
has a set of applications associated. Each application has a set of accou=
nts and in turn each account has a set of profiles. <o:p></o:p></p><p cla=
ss=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>User Hierarchy:<=
o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNor=
mal>User {username}<o:p></o:p></p><p class=3DMsoNormal style=3D'text-inde=
nt:36.0pt'>List of Applications {Application – {appName, userName}}=
<o:p></o:p></p><p class=3DMsoNormal style=3D'margin-left:36.0pt;text-inde=
nt:36.0pt'>List of Accounts – { Account – {accountName, appNa=
me, username}}<o:p></o:p></p><p class=3DMsoNormal style=3D'margin-left:72=
.0pt;text-indent:36.0pt'>List of Profiles – {Profile – {name,=
=20accountName, username}}<o:p></o:p></p><p class=3DMsoNormal><o:p> =
</o:p></p><p class=3DMsoNormal>The rule we want to check is <o:p></o:p></=
p><p class=3DMsoNormal>If an user has a Profile (name =3D A) in account 1=
, Profile (name =3D B) in the same account (account 1)<o:p></o:p></p><p c=
lass=3DMsoNormal>and Profile (name =3D C) in account 2, Profile (name =3D=
=20D) in account 2<o:p></o:p></p><p class=3DMsoNormal>then fire the rule.=
<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNo=
rmal><o:p> </o:p></p><p class=3DMsoNormal><b>Jess Rule:<o:p></o:p></=
b></p><p class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>(def=
rule AFTS_RULE_01<o:p></o:p></p><p class=3DMsoNormal>(User (userName ?use=
rName))<o:p></o:p></p><p class=3DMsoNormal>(Application (appName ?appName=
&:(eq ?appName "AFTS")) (userName ?userName))<o:p></o:p></p=
><p class=3DMsoNormal>(Account (accountName ?accountName1) (userName ?use=
rName))<o:p></o:p></p><p class=3DMsoNormal>(Profile (name ?name1&:(eq=
=20?name1 "A")) (accountName ?accountName1) (userName ?userName=
))<o:p></o:p></p><p class=3DMsoNormal>(Profile (name ?name2&:(eq ?nam=
e2 "B")) (accountName ?accountName1) (userName ?userName))<o:p>=
</o:p></p><p class=3DMsoNormal>(Account (accountName ?accountName2&~a=
ccountName1) (userName ?userName))<o:p></o:p></p><p class=3DMsoNormal>(Pr=
ofile (name ?name3&:(eq ?name3 "C")) (accountName ?accountN=
ame2) (userName ?userName))<o:p></o:p></p><p class=3DMsoNormal>(Profile (=
name ?name4&:(eq ?name4 "D")) (accountName ?accountName2) (=
userName ?userName))<o:p></o:p></p><p class=3DMsoNormal>=3D><o:p></o:p=
></p><p class=3DMsoNormal>(printout t "ATFS Rule satisfied for "=
; ?appName crlf)<o:p></o:p></p><p class=3DMsoNormal>)<o:p></o:p></p><p cl=
ass=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>Currently we ha=
ve introduced a variable username in all the objects to maintain the rela=
tionship between the User object and the child objects.<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>Is the above =
rule representation correct or is there a better way to represent this ru=
le in Jess?<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p cl=
ass=3DMsoNormal>Regards<o:p></o:p></p><p class=3DMsoNormal>Srinath<o:p></=
o:p></p></div>
<P>_______________________________________________</P>
<P>This message is for information purposes only, it is not a recommendat=
ion,=20
advice, offer or solicitation to buy or sell a product or service nor an =
official confirmation of any transaction. It is directed at persons who a=
re=20
professionals and is not intended for retail customer use. Intended for=20
recipient only. This message is subject to the terms at: <A=20
href=3D"http://www.barclays.com/emaildisclaimer">www.barclays.com/emaildi=
sclaimer</A>.</P>
<P>For important disclosures, please see: <A=20
href=3D"http://www.barclays.com/salesandtradingdisclaimer">www.barclays.c=
om/salesandtradingdisclaimer</A>=20
regarding market commentary from Barclays Sales and/or Trading, who are a=
ctive=20
market participants; and in respect of Barclays Research, including discl=
osures=20
relating to specific issuers, please see <A=20
href=3D"http://publicresearch.barclays.com">http://publicresearch.barclay=
s.com</A>.</P>
<P>_______________________________________________</P>
</body></html>
--_000_473EC65F3730D84CB06326B8ABEA78200188205CF346SGPPCMMGMB0_--