Hi Lucia,

Basically the issue is that Jess has two completely different text- like data types: RU.STRING, which are double-quoted Strings that can contain spaces and punctuation, and RU.SYMBOL, which don't have quotes and generally look like Java identifiers. They're not the same, and comparing them always returns false -- i.e.,

Jess> (eq "HELLO" HELLO)
FALSE

You need to know which you're dealing with, and use one type or the other consistently. JavaBeans with String properties always use RU.STRING. On the other hand, the function ValueVector.add(String), which you're calling in your Java code snippet below, will create a Jess value of type RU.SYMBOL . Instead, you probably want to say


result = jessEngine.runQueryStar("llamados", new ValueVector().add(new Value("metodo1", RU.STRING)));



Just make sure you use RU.STRING everywhere, and your code should work fine.

On Sep 2, 2009, at 3:54 PM, Lucia Masola wrote:

Hello, I'm writting an expert system in jess. It includes the two kinds of templates, the ones that you can define from java (using declare from-class) and the ones that you define directly in the clp archive. The beans are all of the same kind, all of the contains Strings.

I've experimenting some problems when I want to execute a query that is defined in the clp archive from java, regarding a template defined a java bean. When i want to pass a parameter, the rules does not match with any of the facts. Jess engine had stored the strings of the beans with "". Does anyone can give me a tip in how to execute a query from java regarding facts created as java bean objects???

Here is the query that i run from java:
QueryResult result;
        try {
result = jessEngine.runQueryStar("llamados", new ValueVector().add("metodo1"));
             while (result.next()) {
System.out.println(result.getString("caller_id") + " " + result.getString("callee_id")));
                 addFanInMetric(ff);
                }
        } catch (JessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Here is the clp archive:

(import JessIntegrationModel.*)


(deftemplate Call    (declare (from-class Call)))

(deftemplate llamado_no_directo
    "comment"
    (slot caller_id)
    (slot calle_id))

(deftemplate metodoFamiliar
    (slot metodo1)
    (slot metodo2)
)

(deftemplate metodoFamiliar_counted
    (slot metodo1)
    (slot metodo2)
)


(defrule propagarLlamadas
       (declare (salience 500))
    (Call (callee_id ?metodoLlamado)(caller_id ?metodoLlamador))
    (metodoFamiliar (metodo1 ?metodoLlamado)(metodo2 ?metodoFamiliar))
(not (metodoFamiliar_counted(metodo1 ?metodoLlamado)(metodo2 ? metodoFamiliar)))
    =>
(assert (metodoFamiliar_counted(metodo1 ?metodoLlamado)(metodo2 ? metodoFamiliar))) (assert (llamado_no_directo(calle_id ?metodoFamiliar)(caller_id ? metodoLlamador)))
    )


(defquery llamados
    "comment"
    (declare (variables ?ln))
    (call_counted (caller_id ?Caller) (callee_id ?ln))

    )

(defquery llamadosNoDirectos
    "comment"
    (declare (variables ?ln))
    (llamado_no_directo (caller_id ?Caller) (calle_id ?ln))

    )






---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com







--------------------------------------------------------------------
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].
--------------------------------------------------------------------

Reply via email to