TermFinderFacadeLocal.java from Texai at Krugle
Show TermFinderFacadeLocal.java syntax highlighted
/*
* TermFinderFacadeLocal.java
*
* Created on April 4, 2007, 2:56 PM
*
* Description: Defines methods to find terms in a particular knowledge base shard.
*
* Copyright (C) 2007 Stephen L. Reed.
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.texai.kb.ejb.session.shared;
import com.sleepycat.persist.EntityStore;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.texai.kb.entity.AtomicTerm;
import org.texai.kb.entity.BinaryGAF;
import org.texai.kb.entity.Formula;
import org.texai.kb.entity.NonAtomicTerm;
import org.texai.kb.entity.PByteArray;
import org.texai.kb.entity.PDate;
import org.texai.kb.entity.PDouble;
import org.texai.kb.entity.PLong;
import org.texai.kb.entity.PString;
import org.texai.kb.entity.PVariable;
import org.texai.kb.entity.QuaternaryGAF;
import org.texai.kb.entity.QuintaryGAF;
import org.texai.kb.entity.AbstractReifiedTerm;
import org.texai.kb.entity.Rule;
import org.texai.kb.entity.Symbol;
import org.texai.kb.entity.AbstractTerm;
import org.texai.kb.entity.LocalTermIdReference;
import org.texai.kb.entity.RemoteTermIdReference;
import org.texai.kb.entity.TernaryGAF;
import org.texai.kb.entity.UnaryGAF;
/**
*
* @author reed
*/
public interface TermFinderFacadeLocal {
/** Returns the highest term id without incrementing it.
*
* @return the highest term id without incrementing it
*/
int peekHighestTermId();
/** Finds the LocalTermIdReference having the given termId.
*
* @param termId the given term id
* @return the LocalTermIdReference having the given termId
* @throws TexaiException if the term is not found
*/
LocalTermIdReference findLocalTermIdReferenceByTermId(final int termId);
/** Finds the LocalTermIdReference having the given UUID.
*
* @param uuid the given UUID
* @return the LocalTermIdReference having the given UUID
*/
LocalTermIdReference findLocalTermIdReferenceByUUID(final UUID uuid);
/** Finds the RemoteTermIdReference having the given termId.
*
* @param termId the given term id
* @return the RemoteTermIdReference having the given termId
*/
RemoteTermIdReference findRemoteTermIdReferenceByTermId(final int termId);
/** Finds the Term having the given termType and termId.
*
* @param termType the given term type
* @param termId the given term id
* @return the Term having the given termType and termId
* @throws TexaiException if the term is not found
*/
AbstractTerm findTermByTermTypeAndId(final byte termType, final int termId);
/** Finds the Symbol having the given termId.
*
* @param termId the given term id
* @return the Symbol having the given termId
* @throws TexaiException if the term is not found
*/
Symbol findSymbolByTermId(final int termId);
/** Finds the Symbol having the given nameValue or null if not found.
*
* @param nameValue the given name value
* @return the Symbol having the given nameValue or null if not found
*/
Symbol findSymbolByNameValue(final String nameValue);
/** Finds the PVariable having the given termId.
*
* @param termId the given term id
* @return the PVariable having the given termId
* @throws TexaiException if the term is not found
*/
PVariable findPVariableByTermId(final int termId);
/** Finds the PVariable having the given nameValue or null if not found.
*
* @param nameValue the given name value
* @return the PVariable having the given nameValue or null if not found
*/
PVariable findPVariableByNameValue(final String nameValue);
/** Finds the PLong having the given termId.
*
* @param termId the given term id
* @return the PLong having the given termId
* @throws TexaiException if the term is not found
*/
PLong findPLongByTermId(final int termId);
/** Finds the PLong having the given longValue or null if not found.
*
* @param longValue the given long value
* @return the PLong having the given nameValue or null if not found
*/
PLong findPLongByLongValue(final Long longValue);
/** Finds the PDouble having the given termId.
*
* @param termId the given term id
* @return the PDouble having the given termId
* @throws TexaiException if the term is not found
*/
PDouble findPDoubleByTermId(final int termId);
/** Finds the PDouble having the given doubleValue or null if not found.
*
* @param doubleValue the given double value
* @return the PDouble having the given doubleValue or null if not found
*/
PDouble findPDoubleByDoubleValue(final Double doubleValue);
/** Finds the PString having the given termId.
*
* @param termId the given term id
* @return the PString having the given termId
* @throws TexaiException if the term is not found
*/
PString findPStringByTermId(final int termId);
/** Finds the PString having the given stringValue or null if not found.
*
* @param stringValue the given string value
* @return the PString having the given stringValue or null if not found
*/
PString findPStringByStringValue(final String stringValue);
/** Finds the PByteArray having the given termId.
*
* @param termId the given term id
* @return the PByteArray having the given termId
* @throws TexaiException if the term is not found
*/
PByteArray findPByteArrayByTermId(final int termId);
/** Finds the PDate having the given termId.
*
* @param termId the given term id
* @return the PDate having the given termId
* @throws TexaiException if the term is not found
*/
PDate findPDateByTermId(final int termId);
/** Finds the PDate having the given dateValue or null if not found.
*
* @param dateValue the given date value
* @return the PDate having the given dateValue or null if not found
*/
PDate findPDateByDateValue(final Date dateValue);
/** Finds the AtomicTerm having the given UUID.
*
* @param uuid the given uuid
* @return the AtomicTerm having the given termId
* @throws TexaiException if the term is not found
*/
AtomicTerm findAtomicTermByUUID(final UUID uuid);
/** Finds the AtomicTerm having the given termId.
*
* @param termId the given term id
* @return the AtomicTerm having the given termId
* @throws TexaiException if the term is not found
*/
AtomicTerm findAtomicTermByTermId(final int termId);
/** Finds the AtomicTerm having the given termName or null if not found.
*
* @param termName the given term name
* @return the AtomicTerm having the given termName or null if not found
*/
AtomicTerm findAtomicTermByTermName(final String termName);
/** Finds the NonAtomicTerm having the given UUID.
*
* @param uuid the given uuid
* @return the NonAtomicTerm having the given termId
* @throws TexaiException if the term is not found
*/
NonAtomicTerm findNonAtomicTermByUUID(final UUID uuid);
/** Finds the NonAtomicTerm having the given termId.
*
* @param termId the given term id
* @return the NonAtomicTerm having the given termId
* @throws TexaiException if the term is not found
*/
NonAtomicTerm findNonAtomicTermByTermId(final int termId);
/** Finds the NonAtomicTerm having the given termName or null if not found.
*
* @param termName the given term name
* @return the NonAtomicTerm having the given termName or null if not found
*/
NonAtomicTerm findNonAtomicTermByTermName(final String termName);
/** Finds the Formula having the given termId.
*
* @param termId the given term id
* @return the Formula having the given termId
* @throws TexaiException if the term is not found
*/
Formula findFormulaByTermId(final int termId);
/** Finds the Formula having the given term list or null if not found.
*
* @param termList the given term list
* @return the Formula having the given term list or null if not found
*/
Formula findFormulaByTermList(final List<AbstractTerm> termList);
/** Finds the Formula having the given formulaString or null if not found.
*
* @param formulaString the given formula string
* @return the Formula having the given formulaString or null if not found
*/
Formula findFormulaByFormulaString(final String formulaString);
/** Finds the Rule having the given UUID.
*
* @param uuid the given uuid
* @return the Rule having the given termId
* @throws TexaiException if the term is not found
*/
Rule findRuleByUUID(final UUID uuid);
/** Finds the Rule having the given termId.
*
* @param termId the given term id
* @return the Rule having the given termId
* @throws TexaiException if the term is not found
*/
Rule findRuleByTermId(final int termId);
/** Finds the Rule having the given formula or null if not found.
*
* @param formula the given formula
* @return the Rule having the given formula or null if not found
*/
Rule findRuleByFormula(
final Formula formula);
/** Finds the UnaryGAF having the given UUID.
*
* @param uuid the given uuid
* @return the UnaryGAF having the given termId
* @throws TexaiException if the term is not found
*/
UnaryGAF findUnaryGAFByUUID(final UUID uuid);
/** Finds the UnaryGAF having the given termId.
*
* @param termId the given term id
* @return the UnaryGAF having the given termId
* @throws TexaiException if the term is not found
*/
UnaryGAF findUnaryGAFByTermId(final int termId);
/** Finds the UnaryGAF having the given constitutents or null if not found.
*
* @param predicate the given predicate
* @param args the argument list
* @param context the context
* @return the UnaryGAF having the given constitutents or null if not found
*/
UnaryGAF findUnaryGAFByConstituents(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context);
/** Finds the BinaryGAF having the given UUID.
*
* @param uuid the given uuid
* @return the BinaryGAF having the given termId
* @throws TexaiException if the term is not found
*/
BinaryGAF findBinaryGAFByUUID(final UUID uuid);
/** Finds the BinaryGAF having the given termId.
*
* @param termId the given term id
* @return the BinaryGAF having the given termId
* @throws TexaiException if the term is not found
*/
BinaryGAF findBinaryGAFByTermId(final int termId);
/** Finds the BinaryGAF having the given constitutents or null if not found.
*
* @param predicate the given predicate
* @param args the argument list
* @param context the context
* @return the BinaryGAF having the given constitutents or null if not found
*/
BinaryGAF findBinaryGAFByConstituents(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context);
/** Finds the TernaryGAF having the given UUID.
*
* @param uuid the given uuid
* @return the TernaryGAF having the given termId
* @throws TexaiException if the term is not found
*/
TernaryGAF findTernaryGAFByUUID(final UUID uuid);
/** Finds the TernaryGAF having the given termId.
*
* @param termId the given term id
* @return the TernaryGAF having the given termId
* @throws TexaiException if the term is not found
*/
TernaryGAF findTernaryGAFByTermId(final int termId);
/** Finds the TernaryGAF having the given constitutents or null if not found.
*
* @param predicate the given predicate
* @param args the argument list
* @param context the context
* @return the TernaryGAF having the given constitutents or null if not found
*/
TernaryGAF findTernaryGAFByConstituents(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context);
/** Finds the QuaternaryGAF having the given UUID.
*
* @param uuid the given uuid
* @return the QuaternaryGAF having the given termId
* @throws TexaiException if the term is not found
*/
QuaternaryGAF findQuaternaryGAFByUUID(final UUID uuid);
/** Finds the QuaternaryGAF having the given termId.
*
* @param termId the given term id
* @return the QuaternaryGAF having the given termId
* @throws TexaiException if the term is not found
*/
QuaternaryGAF findQuaternaryGAFByTermId(final int termId);
/** Finds the QuaternaryGAF having the given constitutents or null if not found.
*
* @param predicate the given predicate
* @param args the argument list
* @param context the context
* @return the QuaternaryGAF having the given constitutents or null if not found
*/
QuaternaryGAF findQuaternaryGAFByConstituents(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context);
/** Finds the QuintaryGAF having the given UUID.
*
* @param uuid the given uuid
* @return the QuintaryGAF having the given termId
* @throws TexaiException if the term is not found
*/
QuintaryGAF findQuintaryGAFByUUID(final UUID uuid);
/** Finds the QuintaryGAF having the given termId.
*
* @param termId the given term id
* @return the QuintaryGAF having the given termId
* @throws TexaiException if the term is not found
*/
QuintaryGAF findQuintaryGAFByTermId(final int termId);
/** Finds the QuintaryGAF having the given constitutents or null if not found.
*
* @param predicate the given predicate
* @param args the argument list
* @param context the context
* @return the QuintaryGAF having the given constitutents or null if not found
*/
QuintaryGAF findQuintaryGAFByConstituents(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context);
/** Creates the Symbol having the given nameValue.
*
* @param nameValue the given name value
* @return the Symbol having the given nameValue
*/
Symbol createSymbolByNameValue(final String nameValue);
/** Creates the PVariable having the given nameValue.
*
* @param nameValue the given name value
* @return the PVariable having the given nameValue
*/
PVariable createPVariableByNameValue(final String nameValue);
/** Creates the PLong having the given longValue.
*
* @param longValue the given long value
* @return the PLong having the given nameValue
*/
PLong createPLongByLongValue(final Long longValue);
/** Creates the PDouble having the given doubleValue.
*
* @param doubleValue the given double value
* @return the PLong having the given doubleValue
*/
PDouble createPDoubleByDoubleValue(final Double doubleValue);
/** Creates the PString having the given stringValue.
*
* @param stringValue the given double value
* @return the PLong having the given doubleValue
*/
PString createPStringByStringValue(final String stringValue);
/** Creates the PDate having the given dateValue.
*
* @param dateValue the given date value
* @return the PDate having the given dateValue
*/
PDate createPDateByDateValue(final Date dateValue);
/** Creates the bootstrap AtomicTerm having the given termName.
*
* @param uuid the UUID
* @param termName the term name
* @param prettyName the pretty name
* @return the AtomicTerm having the given termName
*/
AtomicTerm createBootstrapAtomicTerm(
final UUID uuid,
final String termName,
final String prettyName);
/** Creates the AtomicTerm having the given termName.
*
* @param termName the term name
* @param prettyName the pretty name
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the AtomicTerm having the given termName
*/
AtomicTerm createAtomicTermByTermName(
final String termName,
final String prettyName,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates the NonAtomicTerm having the given termName.
*
* @param termName the term name
* @param prettyName the pretty name
* @param formula the formula
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the NonAtomicTerm having the given termName or a new one having
* the given constituents
*/
NonAtomicTerm createNonAtomicTermByTermName(
final String termName,
final String prettyName,
final Formula formula,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates the Formula having the given term list.
*
* @param formulaTerms the list of terms that constitute this formula
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the persisted Formula having the given term list
*/
Formula createFormulaByTermList(
final List<AbstractTerm> formulaTerms,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates (with the term list omitted) the Formula having the given formulaString.
*
* @param termId the given term id
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the persisted Formula having the given formulaString or a new Formula having the
* given term list
*/
Formula createFormulaByFormulaString(
final String formulaString,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates the Rule having the given formula.
*
* @param formula the given formula
* @param context the context
* @param strength the strength
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the Rule having the given formulaString
*/
Rule createRuleByFormula(
final Formula formula,
final AbstractReifiedTerm context,
final Double strength,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates the UnaryGAF having the given constitutents.
*
* @param predicate the given predicate
* @param args the argument list
* @param context the context
* @param strength the assertion strength
* @param generatedPhrase the generated phrase for this ground atomic formula
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the UnaryGAF having the given constitutents
*/
UnaryGAF createUnaryGAFByConstituents(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context,
final Double strength,
final String generatedPhrase,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/**
* Creates the BinaryGAF having the given constitutents.
*
* @param predicate the given predicate
* @param args the argument list
* @param context the context
* @param strength the assertion strength
* @param generatedPhrase the generated phrase for this ground atomic formula
* @param validateWellFormedFormula the indicator to validate the gaf as a well-formed formula
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the BinaryGAF having the given constitutents
*/
BinaryGAF createBinaryGAFByConstituents(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context,
final Double strength,
final String generatedPhrase,
boolean validateWellFormedFormula,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates the TernaryGAF having the given constitutents.
*
* @param predicate the given predicate
* @param args the argument list
* @param context the context
* @param strength the assertion strength
* @param generatedPhrase the generated phrase for this ground atomic formula
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the TernaryGAF having the given constitutents
*/
TernaryGAF createTernaryGAFByConstituents(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context,
final Double strength,
final String generatedPhrase,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates the QuaternaryGAF having the given constitutents.
*
* @param predicate the given predicate
* @param args the argument list
* @param context the context
* @param strength the assertion strength
* @param generatedPhrase the generated phrase for this ground atomic formula
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the QuaternaryGAF having the given constitutents
*/
QuaternaryGAF createQuaternaryGAFByConstituents(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context,
final Double strength,
final String generatedPhrase,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates the QuintaryGAF having the given constitutents.
*
* @param predicate the given predicate
* @param args the argument list
* @param context the context
* @param strength the assertion strength
* @param generatedPhrase the generated phrase for this ground atomic formula
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the QuintaryGAF having the given constitutents
*/
QuintaryGAF createQuintaryGAFByConstituents(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context,
final Double strength,
final String generatedPhrase,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates the defined atomic term.
*
* @param termName the term name
* @param prettyName the pretty name
* @param commentString the comment string
* @param isaTerms the list of isa (type) terms
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the specified defined term
*/
AtomicTerm createDefinedTerm(
final String termName,
final String prettyName,
final String commentString,
final List<AbstractReifiedTerm> isaTerms,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates the specified binary predicate term with default list of isa (type) terms [BinaryPredicate, PredicateFocalInArg1],
* and list of genlPreds (super property) terms [conceptuallyRelated].
*
* @param termName the predicate name
* @param prettyName the pretty name
* @param commentString the comment string
* @param creator the creator
* @param argConstraintTerms the list of argument constraint terms
* @param creationPurpose the creation purpose
* @return the specified binary predicate term
*/
AtomicTerm createBinaryPredicateTerm(
final String termName,
final String prettyName,
final String commentString,
final List<AbstractReifiedTerm> argConstraintTerms,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Creates the specified binary predicate term.
*
*
* @param termName the predicate name
* @param prettyName the pretty name
* @param commentString the comment string
* @param isaTerms the list of isa (type) terms, defaults to [BinaryPredicate, PredicateFocalInArg1]
* @param genlPredTerms the list of genlPreds (super property) terms, defaults to [conceptuallyRelated]
* @param argConstraintTerms the list of argument constraint terms
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the specified binary predicate term
*/
AtomicTerm createBinaryPredicateTerm(
final String termName,
final String prettyName,
final String commentString,
final List<AbstractReifiedTerm> isaTerms,
final List<AbstractReifiedTerm> genlPredTerms,
final List<AbstractReifiedTerm> argConstraintTerms,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/**
* Creates the specified collection term.
*
* @param termName the term name
* @param prettyName the pretty name
* @param commentString the comment string
* @param isaTerms the list of isa (type) terms
* @param genlsTerms the list of genls (superclass) terms
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the specified collection term
*/
AtomicTerm createCollectionTerm(
final String termName,
final String prettyName,
final String commentString,
final List<AbstractReifiedTerm> isaTerms,
final List<AbstractReifiedTerm> genlsTerms,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/**
* Creates the specified context term.
*
* @param termName the term name
* @param prettyName the pretty name
* @param commentString the comment string
* @param isaTerms the list of isa (type) terms which defaults to [Microtheory] when empty
* @param genlMtTerms the list of genlMt (super context) terms which defaults to [BaseKB] when empty
* @param creator the creator
* @param creationPurpose the creation purpose
* @return the specified collection term
*/
AtomicTerm createContextTerm(
final String termName,
final String prettyName,
final String commentString,
final List<AbstractReifiedTerm> isaTerms,
final List<AbstractReifiedTerm> genlMtTerms,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose);
/** Returns a description of why the given formula is not well formed, or an empty string if the formula is well formed.
*
* @param predicate the predicate
* @param args the argument list
* @param context the context
*/
String getReasonWhyFormulaIsNotWellFormed(
final AbstractReifiedTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context);
/** Sets the entity store.
*
* @param entityStore
*/
void setEntityStore(final EntityStore entityStore);
/** Initializes the primary and secondary indicies. */
void initializeIndices();
/** Persists the term id sequence for this shard. */
void persistTermIdSequence();
}
See more files for this project here