import jess.*;
import java.util.*;

public class NewBieQuery
{
       public static void main(String [] argv) throws JessException
       {
               // Create engine, define query and data

            Rete jess = new Rete();
            jess.executeCommand("(watch all)");
                jess.executeCommand("(deftemplate prod (slot prod-ident)
(slot prod-desc))");
                jess.executeCommand("(deftemplate tech (slot tech-ident)
(slot tech-desc)) ");
                jess.executeCommand("(deftemplate problemtype (slot
problemtype-ident) (slot problemtype-category) (slot problemtype-desc)
(slot problemtype-techident) (slot problemtype-prodident))");
                jess.executeCommand("(assert (prod (prod-ident 1) (prod-desc
2900Series)))");
                jess.executeCommand("(assert (prod (prod-ident 1) (prod-desc
2400Series)))");
                jess.executeCommand("(assert (tech (tech-ident 1) (tech-desc
VLANATMS)))");
                jess.executeCommand("(assert (problemtype (problemtype-ident
test1) (problemtype-category configuration) (problemtype-desc
testing1) (problemtype-techident 1) (problemtype-prodident 1)))");
                jess.executeCommand("(assert (problemtype (problemtype-ident
test2) (problemtype-category troubleshooting) (problemtype-desc
testing2) (problemtype-techident 2) (problemtype-prodident 2)))");
                        jess.executeCommand("(assert (problemtype (problemtype-ident 
test3)
(problemtype-category troubleshooting) (problemtype-desc testing1)
(problemtype-techident 1) (problemtype-prodident 1)))");
                        jess.listFacts();
                        jess.executeCommand("(defquery q_problemtypefinal" +
                                                "(declare (variables ?param1 ?param2 
?param3))" +
                                                                        "(prod 
(prod-ident ?prodid) (prod-desc ?a&: (= (str-compare
?a ?param1) 0)))" +
                                                                        "(tech 
(tech-ident ?techid) (tech-desc ?b&: (= (str-compare
?b ?param2) 0)))" +
                                                                        "(problemtype 
(problemtype-ident ?test) (problemtype-desc
?c&: (= (str-compare ?c ?param3) 0)) (problemtype-techident ?techid)
(problemtype-prodident ?prodid)))");
                        String w = "2900Series";
                        String y = "VLANATMS";
                        String z = "testing1";
                        jess.executeCommand("(bind ?w "+ w +")"+
                                                "(bind ?y "+ y +")" +
                                                "(bind ?z "+ z +")");
                        jess.executeCommand("(printout t crlf \"Querying for word: \" 
?w crlf)" +
                                                        "(printout t crlf \"Querying 
for word: \" ?y crlf)" +
                                                        "(printout t crlf \"Querying 
for word: \" ?z crlf)" +
                                                        "(printout t \"Running 
query...\" crlf)");

                jess.executeCommand("(bind ?it (run-query q_problemtypefinal 
?w ?y ?z))" +
                                                        "(printout t \"Iterating 
results...\" crlf)");
                jess.executeCommand("(while (?it hasNext)" +
                    "(bind ?token (call ?it next))" +
                    "(bind ?fact (call ?token fact 1))" +
                    "(printout t crlf)" +
                    "(printout t \"prod-ident: \" (fact-slot-value ?fact
\"prod-ident\"))" +
                    "(printout t crlf)" +
                    "(bind ?fact (call ?token fact 2))" +
                    "(printout t \"tech-ident: \" (fact-slot-value ?fact
\"tech-ident\"))" +
                    "(printout t crlf)" +
                    "(bind ?fact (call ?token fact 3))" +
                    "(printout t \"problemtype-ident: \" (fact-slot-value
?fact \"problemtype-ident\"))" +
                    "(printout t crlf) " +
                    "(printout t \"problemtype-category: \" (fact-slot-value
?fact \"problemtype-category\"))" +
                    "(printout t crlf)" +
                    "(printout t \"problemtype-desc: \" (fact-slot-value
?fact \"problemtype-desc\")))");
       }
}


Can somebody guide me to extract the iterator results of this code
from Jess values to Java values??

Appreciate all your replies,


Thanks,



Prasath

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