I am myself answering me because I found the first mistake and it works.
But if anybody knows a way more simple to do the same thing, I will be glad
to learn it. 
Here is the right code, it is automatically generate :
                
                  rete.executeCommand("(set-reset-globals nil)");
                  rete.executeCommand("(reset)");
                
                rete.executeCommand("(defglobal ?*obj* = (new
MarchePublicBeanPlan))");
                
                rete.executeCommand("(assert (existPlancher))");
                    
                rete.executeCommand("(defrule creationEscalierBeton "+
                                                        "  (existPlancher) "
+
                                                        "  (betonFournit)" +
                                                        "=> " +
                                                        "  (assert
(existEscalierBeton))" +
                                                        "  (call ?*obj*
setAction \"creationEscalierBeton\")" +
                                                        "  (store RESULT
(call ?*obj* getAction))" +
                                                        ") ");
        

                 rete.executeCommand("(defrule fournitureBeton "+
                                                        "
(not(betonFournit)) " +
                                                        " =>" +
                                                        "  (assert
(betonFournit)) " +
                                                        "  (call ?*obj*
setAction \"fournitureBeton\")" +
                                                        "  (store RESULT
(call ?*obj* getAction))" +
                                                        ") ");
                
And right now, it is passing only one time in the bean. I didn't change
anything, but it works correctly. 
Thank you.
Daniela                                                                 

-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la
part de Daniela CLARO
Envoyi : jeudi 26 janvier 2006 15:43
@ : jess-users@sandia.gov
Objet : JESS: Relation between a Java Bean and Jess - retrieving results

Hi everybody,
 As I am developing using JESS, I have some doubts. Here is more one...
Consider that I have one fact and the two rules below. They are
automatically created using Java and Rete. Actually, I used the STORE and a
bean because I want to retrieve (FETCH) a list of results. For example, I
know that when running this algorithm if I used "printout" I will receive as
response: 
fournitureBeton
creationEscalierBeton. 

Actually I want to retrieve these values. Probably my use of STORE is not
correct and you have another simple solution. The problem here is that even
if I declared my bean as global, this means, it will be instanciated only
one time, as I saw the answers I received, it is passing two times when I
call it. Thus I can conclude that it is creating two instances of my bean,
one for creationEscalierBeton and another for fournitureBeton. Thus this is
the reason that my "StringBuffer" inside the bean only have one result.
Actually I want to retrieve an order list telling which rule is fired
firstly, and so on. I want to retrieve as  System.out.println("Order List: "
+ rete.fetch("RESULT"));



Do you know another way to FETCH the RESULT value since this RESULT should
be a list of the name of my rules or the name that I am saying? 
If in the place of the set and store I used printout, everything works as I
need. However the problem is that I need to retrieve these results. 

Best regards,
Daniela

  
(assert (existPlancher))

(defglobal ?*obj* = (new MarchePublicBeanPlan))

(defrule creationEscalierBeton 
        (existPlancher) 
        (betonFournit)
=> 
        (assert (existEscalierBeton))
        (set ?*obj*  action "creationEscalierBeton")
        (store RESULT (get ?*obj* action))
) 
        

(defrule fournitureBeton 
        (not(betonFournit)) 
=>
        (assert (betonFournit))
        (set ?*obj*  action "fournitureBeton")
        (store RESULT (get ?*obj* action))
) 

I have this bean: 
import java.io.Serializable;

public class MarchePublicBeanPlan implements Serializable{
  private String action;
  public StringBuffer plan;

  public MarchePublicBeanPlan() {
    System.out.println("************* Inside BEAN******************");
    action = null;
    plan = new StringBuffer();
  }
  public void setAction(String action) {
    System.out.println("************ACTION:"+action);
    plan.append(action);
  }
  public String getAction() {
    System.out.println("************PLAN:"+plan.toString());
    return plan.toString();
  }
}
And this is the answer I get when I rete.run it. 
####################STARTING RETE################
************* Inside BEAN******************
************* Inside BEAN******************
************ACTION:fournitureBeton
************PLAN:fournitureBeton
Order List: "fournitureBeton"

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


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