Hi,
is it possible to do the following:
1 Make a deftemplate and inheriting from a dynamic java-bean and in the process adding 
some slots. 
(This works fine thru what is described in section 2.7.2 (deftemplate 
<deftemplate-name> [extends <classname>] [<doc-comment>] [(slot <slot-name> [(default 
| default-dynamic <value>)] [(type <typespec>))]*) 
2. ASSERT an ordered fact which is an instance of the deftemplate in 1 but which has 
all slots, but the ones created in the deftemplate, initialized using an instance of 
the java-bean.

Example:

package SE.ericsson.epk.NAM.DataTranscriptGeneratorPackage;
import java.awt.*;


/**
 * Java-bean style class to map between a table name and the corresponding 
 * prefix when setting upp the table in MML.
 */
public class MMLPrefixBean extends java.lang.Object implements Cloneable
{

        /**
         * Default constructor necessary for a bean.
         */
        public MMLPrefixBean()
        {
        }

        /**
         * Setter method for the prefix attribute.
         * 
         * @param prefix a three character wide string specifying the prefix to use 
when
         * configuring the table.
         * If a wider string is used as input the prefix will be shortened through cut.
         */
        public void setPrefix(String prefix)throws MMLSyntaxException {
            String oldValue=getPrefix();
            String newValue=null;
            if (prefix!=null) {
                newValue=new String(prefix.substring(0, 3));
            }   
                if (prefix.length()==3) {
                    if (oldValue!=newValue) {
                            this.prefix=newValue;
                            changes.firePropertyChange("prefix", oldValue, newValue);
                    }
                } else {
                    MMLSyntaxException MMLExc=new MMLSyntaxException();
                    this.prefix=newValue;
                    changes.firePropertyChange("prefix", oldValue, newValue);
                    throw MMLExc;
                }
        }
                
           
        public java.lang.String getPrefix()
        {
                return this.prefix;
        }

        public void setDescription(java.lang.String description)
        {
            String oldValue=this.getDescription();
            String newValue=description;
                        if (oldValue!=newValue) {
                            this.description=newValue;
                            changes.firePropertyChange("description", oldValue, 
newValue);
                        }
        }

        public java.lang.String getDescription()
        {
                return this.description;
        }

        public void setTable(java.lang.String table)
        {
            String oldValue=this.getTable();
            String newValue=table;
                if (oldValue!=newValue) {
                        this.table=newValue;
                        changes.firePropertyChange("table", oldValue, newValue);
                }       
        }

        public java.lang.String getTable()
        {
                return this.table;
        }

    public String toString() {
        return( this.getPrefix() + " : " + this.getTable() + " : " + 
this.getDescription());
    }

    public Object clone() {
        MMLPrefixBean copy=null;
        try {
            copy=new MMLPrefixBean();
            copy.setDescription(this.getDescription());
            copy.setPrefix(this.getPrefix());
            copy.setTable(this.getTable());
        }
        catch(MMLSyntaxException e) {
            System.out.println("Exception in MMLPrefixBean.clone(): ");
        }
        return copy;
    }
    
    public boolean equals (Object object){
        MMLPrefixBean otherBean=null;
        if (this.getClass()==object.getClass()) {
            otherBean=(MMLPrefixBean)object;
            return this.getPrefix().equals(otherBean.getPrefix()) && 
                    this.getDescription().equals(otherBean.getDescription()) &&
                    this.getTable().equals(otherBean.getTable());
        } else {
            return false;
        }
    }
            
    public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
        {
                changes.addPropertyChangeListener(pcl);
        }
        
    public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
        {
                        changes.removePropertyChangeListener(pcl);
        }
        
        protected java.lang.String prefix = "";
        protected java.lang.String table = "";
        protected java.lang.String description = "";
        private symantec.itools.beans.PropertyChangeSupport changes = new 
symantec.itools.beans.PropertyChangeSupport(this);

    public static void main(String[] args) {
        MMLPrefixBean anMMLPrefixBean=null;
        MMLPrefixBean anotherMMLPrefixBean=null;
        try {
            anMMLPrefixBean=new MMLPrefixBean();
            anMMLPrefixBean.setPrefix("PNB");
            anMMLPrefixBean.setDescription("Prefix for PRE-ANALYSIS OF NUMBER 
INFORMATION FOR B-NUMBER ");
            anMMLPrefixBean.setTable("B-number Pre-analysis");
            System.out.println(anMMLPrefixBean);
            anMMLPrefixBean=new MMLPrefixBean();
            anMMLPrefixBean.setPrefix("ANB");
            anMMLPrefixBean.setDescription("Prefix for ANALYSIS OF B-NUMBER ");
            anMMLPrefixBean.setTable("B-number analysis");
            System.out.println(anMMLPrefixBean);
            anotherMMLPrefixBean=(MMLPrefixBean)anMMLPrefixBean.clone();
            if (anMMLPrefixBean.equals(anotherMMLPrefixBean)) {
                System.out.println("Clone and equal works!");
            }
            anMMLPrefixBean=new MMLPrefixBean();
            anMMLPrefixBean.setDescription("Prefix which is wrong ");
            anMMLPrefixBean.setTable("Z-nummer analysis");
            anMMLPrefixBean.setPrefix("ANBQ");
            System.out.println(anMMLPrefixBean);
            
        }
        catch (MMLSyntaxException MMLExc) {
            System.out.println("Fick ett MML Exception");
            System.out.println(anMMLPrefixBean);
        }
    }
}


(defclass MMLPrefixBean 
SE.ericsson.epk.NAM.DataTranscriptGeneratorPackage.MMLPrefixBean) 
(deftemplate myprefixtemplate extends MMLPrefixBean
(slot foo)

(bind ?anMMLPrefixBean (call 
SE.ericsson.epk.NAM.DataTranscriptGeneratorPackage.Control.getDefaultMMLPrefixBean)) 
;retrieves a prefix-bean with all attributes set to default values. 

(definstance MyExtendedPrefixBean ?anMMLPrefixBean dynamic) ;this leads to the 
following error
Jess reported an error in routine DefinstanceList.definstance
        while executing (definstance MyExtendedPrefixBean ?anMMLPrefixBean dynamic).
  Message: Unknown object class MyExtendedPrefixBean.
  Program text: ( definstance MyExtendedPrefixBean ?anMMLPrefixBean dynamic )  at line 
23.

(assert ?anMMLPrefixBean)  ;this leads to the following error 
Jess reported an error in routine Value.factValue
        while executing Jess reported an error in routine Variable.resolveValue.
  Message: Null context for anMMLPrefixBean..
  Message: Not a fact: 
"<External-Address:SE.ericsson.epk.NAM.DataTranscriptGeneratorPackage.MMLPrefixBean>" 
(type = EXTERNAL_ADDRESS).

I think I understand what I do wrong in both cases but is there a simple possiblility 
to assert a fact and have all the field initialized from the bean.
/Mikael Rundqvist

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