/** * See {@link #update(List, List)}. Deleting an {@link Update} is calling * update with the add and delete lists reversed. * * @param update * The update to be processed. * @throws MSTQueryException */ public Result delete(Update update) throws MSTQueryException { return update(update.getDeleteList(), update.getAddList()); }
/** * See {@link #update(List, List)}. * * @param update * The update to be processed. * @throws MSTQueryException */ public Result insert(Update update) throws MSTQueryException { return update(update.getAddList(), update.getDeleteList()); }
/** * Check that no beliefs are inserted/deleted that are already knowledge * * @param knowledgeDefined * @param knowledgeDeclared * @param beliefUpdates * all belief updates, both from inserts, deletes, and actionspecs. * @throws ParserException */ private void checkNoBeliefsInsertedAsKnowledge(Map<String, SourceInfo> knowledgeDefined, Map<String, SourceInfo> knowledgeDeclared, Set<Update> beliefUpdates) { for (Update update : beliefUpdates) { checkNoPredicatesBeliefAndKnowledge(knowledgeDefined, knowledgeDeclared, update.getAddList()); checkNoPredicatesBeliefAndKnowledge(knowledgeDefined, knowledgeDeclared, update.getDeleteList()); } }
/** * Inserts a new goal into the goal base. Checks whether the formula (update) * already occurs in the goal base. * * Public as used by the {@link GOALMentalStateConverter}... * * @param update * The update to be inserted. * @return true if anything changed. * @throws MSTDatabaseException */ public Result insert(Update update) throws MSTDatabaseException { Result result = this.owner.createResult(BASETYPE.GOALBASE, getName()); SingleGoal goal = createGoal(update); if (this.goals.add(goal)) { result.added(update.getAddList()); } return result; }
/** * @param goal * The goal to remove and clean up. * @return True when the remove was successful. * @throws MSTQueryException * @throws MSTDatabaseException */ Result remove(SingleGoal goal) throws MSTQueryException, MSTDatabaseException { Result result = this.owner.createResult(BASETYPE.GOALBASE, getName()); if (this.goals.remove(goal)) { result.removed(goal.getGoal().getAddList()); goal.cleanUp(); } return result; }
/** * Extracts relevant info for validation. */ private void processInfo() { // Extract relevant info from referenced files. this.knowledge.addAll(this.program.getKnowledge()); this.beliefs.addAll(this.program.getBeliefs()); this.goals.addAll(this.program.getGoals()); // Extract relevant info from macros. for (Macro macro : this.program.getMacros()) { processInfoMacro(macro); } // Extract relevant info from rules. for (Rule rule : this.program.getRules()) { processInfoRule(rule); } // Add goals in referenced files as goal definitions. for (Query query : this.program.getGoals()) { this.goalDbfs.addAll(query.toUpdate().getAddList()); } } }
SwiPrologGoal(GoalBase owner, Update goal) throws MSTDatabaseException { super(owner.getOwner(), goal); try { this.database = (PrologDatabase) owner.getOwner().getOwner().getKRInterface().getDatabase( owner.getOwner().getAgentId() + ":" + owner.getName() + ":" + goal, goal.getAddList(), false); owner.getOwner().createdDatabase(this.database, BASETYPE.GOALBASE); } catch (KRDatabaseException e) { throw new MSTDatabaseException( "could not create a database for '" + goal + "' of '" + owner.getOwner().getOwner() + "'.", e); } }
for (DatabaseFormula formula : lit.getFormula().toUpdate().getAddList()) { try { super.getGraph().add(formula, true, false); for (DatabaseFormula formula : adopt.getUpdate().getAddList()) { super.getGraph().add(formula, true, true); for (DatabaseFormula formula : drop.getUpdate().getAddList()) { super.getGraph().add(formula, false, true); InsertAction insert = (InsertAction) action; for (DatabaseFormula formula : insert.getUpdate().getAddList()) { super.getGraph().add(formula, true, false);
for (DatabaseFormula formula : subject.getPositivePostcondition().getPostCondition().getAddList()) { try { super.getGraph().add(formula, true, false); for (DatabaseFormula formula : subject.getNegativePostcondition().getPostCondition().getAddList()) { try { super.getGraph().add(formula, false, true);
if (query.isUpdate()) { Update goal = query.toUpdate(); for (DatabaseFormula formula : goal.getAddList()) { try { super.getGraph().add(formula, true, true);