I am creating a Business Object/Property Group/Property using the
templates below.
In the fact CreateAccount and CreateBook, I have properties
"firstName", "lastName"
"city", "state". But looks like it is working as expected. When I dump
the facts....
under account business object, I get Properties FALSE FALSE). Does
that mean no properties
are inserted? If I am doing worng, then what is the correct way of
defining things so that each
Business Object has its set of peroperty groups and properties. And
also if I am asserting
these facts from Java, how to get the result of the Rule and how to
traverse thourgh thr result
to retrive the name of the business object, list of property
groups,and list of properties.
Any help in this regard is aprreciated!!
;create templates
(deftemplate Property (slot name) (slot datatype))
(deftemplate PropertyGroup (slot name) (multislot Properties))
(deftemplate BusinessObject (slot name) (multislot parentPaths)
(multislot Properties) (multislot PropertyGroups))
(defrule CreateAccountRule "AccountCreationRule"
(createAccount)
=>
(assert
(BusinessObject (name "Account")
(Properties
(assert (Property (name "firstName") (datatype "STRING")))
(assert (Property (name "lastName") (datatype "STRING"))))
(PropertyGroups
(assert (PropertyGroup (name "AccountAddress")
(Properties
(assert (Property (name "city") (datatype "STRING")))
(assert (Property (name "state") (datatype "STRING"))))
)))))
)
(defrule CreateBOOKOrderRule "BookCreationRule"
(createBOOK)
=>
(assert
(BusinessObject (name "JESS")
(Properties
(assert (Property (name "firstName") (datatype "STRING")))
(assert (Property (name "lastName") (datatype "STRING"))))
(PropertyGroups
(assert (PropertyGroup (name "AccountAddress")
(Properties
(assert (Property (name "city") (datatype "STRING")))
(assert (Property (name "state") (datatype "STRING"))))
)))))
)
Results
--------
Jess> (assert (createAccount))
<Fact-0>
Jess> (assert (createBOOK))
<Fact-1>
Jess> (run)
2
Jess> (facts)
f-0 (MAIN::createAccount)
f-1 (MAIN::createBOOK)
f-2 (MAIN::Property (name "firstName") (datatype "STRING"))
f-3 (MAIN::Property (name "lastName") (datatype "STRING"))
f-4 (MAIN::Property (name "city") (datatype "STRING"))
f-5 (MAIN::Property (name "state") (datatype "STRING"))
f-6 (MAIN::PropertyGroup (name "AccountAddress") (Properties <Fact-4> <Fact-5>
))
f-7 (MAIN::BusinessObject (name "JESS") (parentPaths ) (Properties <Fact-2> <
Fact-3>) (PropertyGroups <Fact-6>))
f-8 (MAIN::PropertyGroup (name "AccountAddress") (Properties FALSE FALSE))
f-9 (MAIN::BusinessObject (name "Account") (parentPaths ) (Properties FALSE FA
LSE) (PropertyGroups <Fact-8>))
For a total of 10 facts.
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------