/** * Create a new variable and bind it using the given object condition and value source. * @param condition The object condition. * @param name The variable name. * @param valuesource The value source. * @return The new variable. */ public Variable generateVariableBinding(ConstrainableCondition condition, String name, OAVObjectType type, Object valuesource) { Variable tmpvar = new Variable(name, type, false, true); variables.put(name, tmpvar); BoundConstraint bc = new BoundConstraint(valuesource, tmpvar); boundconstraints.put(tmpvar, bc); condition.addConstraint(bc); bcons.put(tmpvar, condition); return tmpvar; }
/** * Create a new variable and bind it using the given object condition and value source. * @param condition The object condition. * @param name The variable name. * @param valuesource The value source. * @return The new variable. */ public Variable generateVariableBinding(ConstrainableCondition condition, String name, OAVObjectType type, Object valuesource) { Variable tmpvar = new Variable(name, type, false, true); variables.put(name, tmpvar); BoundConstraint bc = new BoundConstraint(valuesource, tmpvar); boundconstraints.put(tmpvar, bc); condition.addConstraint(bc); bcons.put(tmpvar, condition); return tmpvar; }
/** * Terminate agent rule. * Terminates the agent and removes it from the platform. */ protected static Rule createTerminateAgentRule() { ObjectCondition ragentcon = new ObjectCondition(OAVBDIRuntimeModel.agent_type); ragentcon.addConstraint(new BoundConstraint(null, new Variable("?ragent", OAVBDIRuntimeModel.agent_type))); ragentcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.agent_has_state, OAVBDIRuntimeModel.AGENTLIFECYCLESTATE_TERMINATED)); IAction action = new IAction() { public void execute(IOAVState state, IVariableAssignments assignments) { Object ragent = assignments.getVariableValue("?ragent"); cleanupAgent(state, ragent); } }; Rule agent_terminating = new Rule("agent_terminated", ragentcon, action); return agent_terminating; }
/** * Create the plan creation rule. * @param usercond The ADF part of the target condition. * @param mplan The plan model element. */ public static Object[] createPlanCreationUserRule(Object mplan) { Variable ragent = new Variable("?ragent", OAVBDIRuntimeModel.agent_type); Variable mplanvar = new Variable("?mplan", OAVBDIMetaModel.plan_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); ObjectCondition ragentcon = new ObjectCondition(OAVBDIRuntimeModel.agent_type); ragentcon.addConstraint(new BoundConstraint(null, ragent)); ragentcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.agent_has_state, OAVBDIRuntimeModel.AGENTLIFECYCLESTATE_ALIVE)); ObjectCondition rcapacon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); rcapacon.addConstraint(new BoundConstraint(null, rcapa)); rcapacon.addConstraint(new LiteralConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.capability_has_plans}, mplan, IOperator.CONTAINS)); // Hack??? How to pass mplan to action!? rcapacon.addConstraint(new BoundConstraint(new Constant(mplan), mplanvar)); return new Object[]{ new AndCondition(new ICondition[]{ragentcon, rcapacon}), PLAN_CREATION}; }
/** * Create the plan context invalid rule. * @param usercond The ADF part of the target condition. * @param mplan The plan model element. */ public static Object[] createPlanContextInvalidUserRule(Object mplan) { Variable rplan = new Variable("?rplan", OAVBDIRuntimeModel.plan_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); ObjectCondition plancon = new ObjectCondition(OAVBDIRuntimeModel.plan_type); plancon.addConstraint(new BoundConstraint(null, rplan)); plancon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, mplan)); ObjectCondition capcon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capcon.addConstraint(new BoundConstraint(null, rcapa)); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_plans, rplan, IOperator.CONTAINS)); return new Object[]{new AndCondition(new ICondition[]{plancon, capcon}), PLAN_ABORT, null, null, Boolean.TRUE}; }
/** * Trigger plan creation on fact removed event. */ protected static Rule createExternalAccessFactRemovedTriggeredRule() { Variable ea = new Variable("?ea", OAVBDIRuntimeModel.externalaccess_type); Variable wa = new Variable("?wa", OAVBDIRuntimeModel.waitabstraction_type); Variable rel = new Variable("?rel", OAVBDIRuntimeModel.processableelement_type); Variable rpe = new Variable("?rpe", OAVBDIRuntimeModel.changeevent_type); ObjectCondition eacon = new ObjectCondition(OAVBDIRuntimeModel.externalaccess_type); eacon.addConstraint(new BoundConstraint(null, ea)); eacon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.externalaccess_has_waitabstraction, wa)); ObjectCondition changecon = new ObjectCondition(OAVBDIRuntimeModel.changeevent_type); changecon.addConstraint(new BoundConstraint(null, rpe)); changecon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.changeevent_has_type, OAVBDIRuntimeModel.CHANGEEVENT_FACTREMOVED)); changecon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.changeevent_has_element, rel)); ObjectCondition wacon = new ObjectCondition(OAVBDIRuntimeModel.waitabstraction_type); wacon.addConstraint(new BoundConstraint(null, wa)); wacon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.waitabstraction_has_factremoveds, rel, IOperator.CONTAINS)); Rule externalaccess_facttrigger = new Rule("externalaccess_factremovedtrigger", new AndCondition(new ICondition[]{eacon, changecon, wacon}), EXTERNALACCESS_NOTIFY, IPriorityEvaluator.PRIORITY_1); return externalaccess_facttrigger; }
/** * Create a goal, when the ADF creation condition triggers. * @param model The goal model element. */ public static Object[] createGoalCreationUserRule(Object model) { Variable ragent = new Variable("?ragent", OAVBDIRuntimeModel.agent_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); Variable mgoal = new Variable("?mgoal", OAVBDIMetaModel.goal_type); ObjectCondition ragentcon = new ObjectCondition(OAVBDIRuntimeModel.agent_type); ragentcon.addConstraint(new BoundConstraint(null, ragent)); ragentcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.agent_has_state, OAVBDIRuntimeModel.AGENTLIFECYCLESTATE_ALIVE)); ObjectCondition capcon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capcon.addConstraint(new BoundConstraint(null, rcapa)); capcon.addConstraint(new BoundConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.capability_has_goals}, mgoal, IOperator.CONTAINS)); ObjectCondition mgoalcon = new ObjectCondition(OAVBDIMetaModel.goal_type); mgoalcon.addConstraint(new BoundConstraint(null, mgoal)); mgoalcon.addConstraint(new LiteralConstraint(null, model)); return new Object[]{ new AndCondition(new ICondition[]{ragentcon, mgoalcon, capcon}), GOAL_CREATION_ACTION}; }
/** * Create the maintaingoal succeeded rule. * @param usercond The ADF part of the target condition. * @param model The goal model element. */ public static Object[] createMaintaingoalSucceededUserRule(Object model) { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); // goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.maintaingoal_type, IOperator.INSTANCEOF)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, model)); ObjectCondition capacon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capacon.addConstraint(new BoundConstraint(null, rcapa)); capacon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); return new Object[]{ new AndCondition(new ICondition[]{goalcon, capacon}), GOAL_IDLE, IPriorityEvaluator.PRIORITY_1}; }
/** * Create the achievegoal succeeded rule (for goals with target condition). * @param usercond The ADF part of the target condition. * @param model The goal model element. */ public static Object[] createAchievegoalSucceededUserRule(Object model) { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, model)); ObjectCondition capacon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capacon.addConstraint(new BoundConstraint(null, rcapa)); capacon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); return new Object[]{ new AndCondition(new ICondition[]{goalcon, capacon}), GOAL_SUCCEEDED, IPriorityEvaluator.PRIORITY_1}; }
/** * Set a suspended goal to option state, when the ADF suspension condition triggers. * @param usercond The ADF condition part. * @param model The goal model element. */ public static Object[] createGoalOptionUserRule(Object model) { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_SUSPENDED)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, model)); ObjectCondition capcon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capcon.addConstraint(new BoundConstraint(null, rcapa)); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); return new Object[]{ new AndCondition(new ICondition[]{goalcon, capcon}), GOAL_OPTION_ACTION}; }
/** * Set a goal to suspended state, when the ADF context condition triggers. * @param usercond The ADF part of the context condition (will be negated automatically). * @param model The goal model element. */ public static Object[] createGoalSuspendUserRule(Object model) { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_SUSPENDED, IOperator.NOTEQUAL)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, model)); ObjectCondition capcon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capcon.addConstraint(new BoundConstraint(null, rcapa)); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); return new Object[]{ new AndCondition(new ICondition[]{goalcon, capcon}), GOAL_SUSPEND_ACTION, null, null, Boolean.TRUE}; // Invert user condition. }
/** * Create the goal failed rule (when no plans available). * (state = nocandidates, recur = false) */ protected static Rule createGoalFailedRule() { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.processableelement_has_state, OAVBDIRuntimeModel.PROCESSABLEELEMENT_NOCANDIDATES)); goalcon.addConstraint(new LiteralConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.goal_has_recur}, Boolean.FALSE)); Rule goal_failed = new Rule("goal_failed", goalcon, GOAL_FAILED); return goal_failed; }
/** * Reactivate a plan when goal cleanup is finished. */ public static Rule createPlanInstanceCleanupFinishedRule() { Variable rplan = new Variable("?rplan", OAVBDIRuntimeModel.plan_type); ObjectCondition plancon = new ObjectCondition(OAVBDIRuntimeModel.plan_type); plancon.addConstraint(new BoundConstraint(null, rplan)); plancon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.plan_has_subgoals, null)); plancon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.plan_has_processingstate, OAVBDIRuntimeModel.PLANPROCESSINGTATE_GOALCLEANUP)); IAction action = new IAction() { public void execute(IOAVState state, IVariableAssignments assignments) { Object rplan = assignments.getVariableValue("?rplan"); state.setAttributeValue(rplan, OAVBDIRuntimeModel.plan_has_processingstate, OAVBDIRuntimeModel.PLANPROCESSINGTATE_READY); } }; Rule planinstance_goalcleanupfinished = new Rule("planinstance_goalcleanupfinished", plancon, action); return planinstance_goalcleanupfinished; }
/** * Start dropping a goal, when the ADF context condition triggers. * @param usercond The ADF part of the context condition. * @param model The goal model element. */ public static Object[] createGoalDroppingUserRule(Object model) { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); ObjectCondition rgoalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); rgoalcon.addConstraint(new BoundConstraint(null, rgoal)); rgoalcon.addConstraint(new AndConstraint( new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_DROPPING, IOperator.NOTEQUAL), new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_DROPPED, IOperator.NOTEQUAL))); rgoalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, model)); ObjectCondition rcapcon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); rcapcon.addConstraint(new BoundConstraint(null, rcapa)); rcapcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); return new Object[]{new AndCondition(new ICondition[]{rgoalcon, rcapcon}), GOAL_DROPPING_ACTION}; }
/** * Rule to abort a plan when the corresponding goal was deactivated. */ public static Rule createPlanInstanceAbortRule() { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); Variable rplan = new Variable("?rplan", OAVBDIRuntimeModel.plan_type); Variable rcapa = new Variable("?rcapa", OAVBDIRuntimeModel.capability_type); ObjectCondition goalcon = new ObjectCondition(rgoal.getType()); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_INPROCESS, IOperator.NOTEQUAL)); ObjectCondition plancon = new ObjectCondition(rplan.getType()); plancon.addConstraint(new BoundConstraint(null, rplan)); plancon.addConstraint(new OrConstraint( new LiteralConstraint(OAVBDIRuntimeModel.plan_has_lifecyclestate, OAVBDIRuntimeModel.PLANLIFECYCLESTATE_NEW), new LiteralConstraint(OAVBDIRuntimeModel.plan_has_lifecyclestate, OAVBDIRuntimeModel.PLANLIFECYCLESTATE_BODY))); plancon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.plan_has_reason, rgoal)); ObjectCondition capcon = new ObjectCondition(rcapa.getType()); capcon.addConstraint(new BoundConstraint(null, rcapa)); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_plans, rplan, IOperator.CONTAINS)); Rule abort_plan = new Rule("planinstance_abort", new AndCondition(new ICondition[]{goalcon, plancon, capcon}), PLAN_ABORT); return abort_plan; }
/** * Create the achievegoal succeeded rule (for goals without target condition). * The goal succeeds, when one plan succeeds. */ protected static Rule createAchievegoalSucceededRule() { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); Variable rplan = new Variable("?rplan", OAVBDIRuntimeModel.plan_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.goal_has_finishedplans, rplan, IOperator.CONTAINS)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.achievegoal_type, IOperator.INSTANCEOF)); goalcon.addConstraint(new LiteralConstraint(new OAVAttributeType[]{ OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.achievegoal_has_targetcondition}, null)); ObjectCondition plancon = new ObjectCondition(OAVBDIRuntimeModel.plan_type); plancon.addConstraint(new BoundConstraint(null, rplan)); plancon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.plan_has_processingstate, OAVBDIRuntimeModel.PLANPROCESSINGTATE_FINISHED)); plancon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.plan_has_lifecyclestate, OAVBDIRuntimeModel.PLANLIFECYCLESTATE_PASSED)); ObjectCondition capcon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); Rule achievegoal_succeeded = new Rule("achievegoal_succeeded", new AndCondition(new ICondition[]{plancon, goalcon, capcon}), GOAL_SUCCEEDED_PLAN_REMOVE, IPriorityEvaluator.PRIORITY_1); return achievegoal_succeeded; }
/** * Start dropping a goal that is succeeded or failed. */ public static Rule createGoalDroppingRule() { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); Variable mgoal = new Variable("?mgoal", OAVBDIMetaModel.goal_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.element_has_model, mgoal)); goalcon.addConstraint(new AndConstraint( new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_DROPPING, IOperator.NOTEQUAL), new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_DROPPED, IOperator.NOTEQUAL))); goalcon.addConstraint(new OrConstraint( new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_SUCCEEDED), new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_FAILED))); // goalcon.addConstraint(new LiteralConstraint(new OAVAttributeType[]{OAVBDIRuntimeModel.element_has_model, OAVAttributeType.OBJECTTYPE}, OAVBDIMetaModel.maintaingoal_type, IOperator.NOTEQUAL)); ObjectCondition capcon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); // Hack!!! Higher priority required to avoid deliberation activating goal that is already finished in option state (e.g. due to immediately fulfilled target condition) Rule goal_dropping = new Rule("goal_dropping", new AndCondition(new ICondition[]{goalcon, capcon}), GOAL_DROPPING_ACTION, IPriorityEvaluator.PRIORITY_1); return goal_dropping; }
/** * Create achievegoal processing rule. */ protected static Rule createAchievegoalProcessingRule() { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_ACTIVE)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_IDLE)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.achievegoal_type, IOperator.INSTANCEOF)); ObjectCondition capcon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); Rule achievegoal_processing = new Rule("achievegoal_processing", new AndCondition(new ICondition[]{goalcon, capcon}), GOAL_PROCESSING); return achievegoal_processing; }
/** * Create querygoal processing rule. */ protected static Rule createQuerygoalProcessingRule() { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_ACTIVE)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_IDLE)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.querygoal_type, IOperator.INSTANCEOF)); ObjectCondition capcon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); Rule querygoal_processing = new Rule("querygoal_processing", new AndCondition(new ICondition[]{goalcon, capcon}), GOAL_PROCESSING); return querygoal_processing; }
/** * Create performgoal processing rule. */ protected static Rule createPerformgoalProcessingRule() { Variable rgoal = new Variable("?rgoal", OAVBDIRuntimeModel.goal_type); ObjectCondition goalcon = new ObjectCondition(OAVBDIRuntimeModel.goal_type); goalcon.addConstraint(new BoundConstraint(null, rgoal)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_lifecyclestate, OAVBDIRuntimeModel.GOALLIFECYCLESTATE_ACTIVE)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.goal_has_processingstate, OAVBDIRuntimeModel.GOALPROCESSINGSTATE_IDLE)); goalcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.element_has_model, OAVBDIMetaModel.performgoal_type, IOperator.INSTANCEOF)); ObjectCondition capacon = new ObjectCondition(OAVBDIRuntimeModel.capability_type); capacon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.capability_has_goals, rgoal, IOperator.CONTAINS)); Rule performgoal_processing = new Rule("performgoal_processing", new AndCondition(new ICondition[]{goalcon, capacon}), GOAL_PROCESSING); return performgoal_processing; }