/**
 * Copyright 2010 David L. Whitehurst
 * 
 * Licensed under the Apache License, Version 2.0 
 * (the "License"); You may not use this file except 
 * in compliance with the License. You may obtain a 
 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, 
 * software distributed under the License is distributed on an 
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 * either express or implied. See the License for the specific 
 * language governing permissions and limitations under the 
 * License.
 * 
 */
package org.dlw.ai.blackboard.knowledge;

import java.util.ArrayList;

import javax.persistence.*;

import org.dlw.ai.blackboard.BlackboardContext;
import org.dlw.ai.blackboard.domain.Assumption;
import org.dlw.ai.blackboard.domain.Sentence;
import org.dlw.ai.blackboard.rule.Rule;

/**
 * This interface defines the signature knowledge source object. Any default
 * implementation e.g.
 * {@link org.dlw.ai.blackboard.knowledge.primitive.CommonPrefixKnowledgeSource}
 * extends {@link InferenceEngine} ultimately through the implementation of this
 * interface and the extension {@link org.dlw.ai.blackboard.BlackboardContext}
 * directly within the implementation.
 * 
 * @author <a href="mailto:dlwhitehurst@gmail.com">David L. Whitehurst</a>
 * @version 1.0.0-RC (hibernate-mysql branch)
 * 
 */
@Entity
@Table(name="knowledge_source")
public abstract class KnowledgeSource extends BlackboardContext implements InferenceEngine, Comparable<KnowledgeSource>{

    private Long id;
    
    /**
     * Attribute priority
     */
    private Integer priority;

    /**
     * Attribute to hold rules for KnowledgeSource
     */
    private ArrayList<Rule> rules = new ArrayList<Rule>();
    
    /**
     * Reset knowledge source
     */
    public abstract void reset();

    /**
     * Find dependent knowledge sources and tell them to add, retract, etc. a
     * statement
     * 
     * @param direction
     * @param statement
     */
    public abstract void notifyDependents(String direction, Assumption statement);

    /* (non-Javadoc)
     * @see java.lang.Comparable#compareTo(java.lang.Object)
     */
    public abstract int compareTo(KnowledgeSource o);

    /* (non-Javadoc)
     * @see org.dlw.ai.blackboard.knowledge.InferenceEngine#evaluate(org.dlw.ai.blackboard.domain.Sentence)
     */
    public void evaluate(Sentence sentence) {
    }

    /**
     * @param priority the priority to set
     */
    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    /**
     * @return the priority
     */
    public Integer getPriority() {
        return priority;
    }

    /**
     * @param rules
     *            the rules to set
     */
    public void setRules(ArrayList<Rule> rules) {
        this.rules = rules;
    }

    /**
     * @return the rules
     */
    public ArrayList<Rule> getRules() {
        return rules;
    }

    /**
     * @return the id
     */
    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }
    
}

@@ -1568,16 +1568,136 @@
 urce%3E%7B%0A%0A
+    /**%0A     * unique serial identifier%0A     */%0A    private static final long serialVersionUID = 3094361637466019949L;%0A%0A
     priv
@@ -3361,16 +3361,693 @@
 d;%0A    %7D
+%0A%0A    /* (non-Javadoc)%0A     * @see org.dlw.ai.blackboard.BlackboardContext#equals(java.lang.Object)%0A     */%0A    @Override%0A    public boolean equals(Object o) %7B%0A        // TODO Auto-generated method stub%0A        return super.equals(o);%0A    %7D%0A%0A    /* (non-Javadoc)%0A     * @see org.dlw.ai.blackboard.BlackboardContext#hashCode()%0A     */%0A    @Override%0A    public int hashCode() %7B%0A        // TODO Auto-generated method stub%0A        return super.hashCode();%0A    %7D%0A%0A    /* (non-Javadoc)%0A     * @see org.dlw.ai.blackboard.BlackboardContext#toString()%0A     */%0A    @Override%0A    public String toString() %7B%0A        // TODO Auto-generated method stub%0A        return super.toString();%0A    %7D
 %0A    %0A%7D%0A

generate toString, equals, and hashcode