Hi,

I got a problem with JavaBean slot updating from Jess script.  I wrote the Jess 
script and Java code as following. I defined a customer shadow fact in Jess and 
add a customer instance to working memory then I found the rule 
'bronze-customer' is fired, but the corresponding attribute 'customerType' in 
customer bean hadn't been changed at all. 
Could you find the problem for me? Thank you in advance.

Jess script fragment
(defclass customer ecommerce.Customer)
(defrule bronze-customer
    ?c <- (customer (shopAccount ?r&:(not (eq ?r nil))) )
    =>
   (modify ?c (customerType 1)))

  
The Customer bean is:
public class Customer {
        
        private String customername;
        private ShopAccount account;
        private int customerType;
        
        // The constructor
        public Customer(String aCustomerName) {
                customername = aCustomerName;
        }

        // Get the customer name
        public String getCustomerName() {
                return customername;
        }

        // Set the customer name
        public void setCustomerName(String string) {
                customername = string;
        }
        
        public void setShopAccount(ShopAccount a){
                account = a;
        }
        
        public ShopAccount getShopAccount(){
                return account;
        }
        
        //set the customer type
        public void setCustomerType(int type){
                customerType = type;
        }
        
        public int getCustomerType(){
                return customerType;
        }
        
        public boolean hasShopAccount(){
                if(this.account != null)
                        return true;
                return false;
        }
        
        private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
        public void addPropertyChangeListener(PropertyChangeListener p)
        {
                pcs.addPropertyChangeListener(p);
        }
        public void removePropertyChangeListener(PropertyChangeListener p)
        {
                pcs.removePropertyChangeListener(p);
        }
}

And the adding of customer instance to Jess working memory from Java:
                Customer customerjan = new Customer("Jan");
                
                Rete engine = new Rete();
                engine.watchAll();
                String rulesFile = "/shopAP.clp";               
                try
                {
            engine.executeCommand("(batch \"" + rulesFile + "\")");
                        engine.reset();
                        engine.definstance("customer",customerjan,true);
                                        
                }catch(JessException je)
                {
                        System.out.println(je.getLineNumber());
                        System.out.println(je.getProgramText());
                        System.out.println(je.getMessage());
                }




Best regards, 
  
Xuelian
[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