JESS: Unruly rules

"Donald Winston" <[email protected]>
Newsgroups gmane.comp.java.jess
Message-ID <5107_1289138359_oA7DuJ7E005918_02ADC616-E9FF-4D32-947D-B927E49E53B5@yahoo.com>
(deftemplate dataset
    (slot name)
    (slot nobs (default 0))
    (slot nvars (default 0))
    (multislot variables)
    (multislot variableTypes)
    (slot submitEditDatasetForm)
    (slot has-errors (default FALSE))
    (slot isFree (default TRUE)))

(deftemplate subscription-prices
    (slot maxDataElements)
    (slot monthlyPrice)
    (slot yearlyPrice))

(deffacts initial-facts
    (nextPage nil)
    (R nil)
    (subscription-prices (monthlyPrice 25) (yearlyPrice 100) (maxDataElements 500)))

(defrule set-dataset-isFree
    (page "show-dataset.xslt")
    ?x <- (dataset (nobs ?) (nvars ?))
    ?y <- (subscription-prices (maxDataElements ?))
=>
    (if (> (* ?x.nobs ?x.nvars) ?y.maxDataElements) then
        (modify ?x
                (isFree FALSE))))

This works but seems to me to defeat the purpose of using a rule engine. Is this where predicate constraints are used?
I did the following and it appears to work:

(defrule set-dataset-isFree
    (page "show-dataset.xslt")
    (dataset (nobs ?nobs))
    ?x <- (dataset (nvars ?nvars))
    (subscription-prices (maxDataElements ?y&: (< ?y (* ?nobs ?nvars))))
=>
    (modify ?x (isFree FALSE)))

Am I going down the right path here? It looks like I'll be doing a lot of this.

Donald Paul Winston
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.