/** * Create a new action. */ public AdoptGoalAction(RGoal goal) { // System.out.println("adopting: "+goal.getId()+" "+goal.getPojoElement().getClass().getName()); this.goal = goal; if(goal.getParentPlan()!=null) this.state = goal.getParentPlan().getLifecycleState(); }
/** * Test if plan has been aborted. */ public boolean isAborted() { boolean aborted = false; // methode is part of plan api (goal treated as plan) // hence one can check if there is a plan above that was aborted if(getParentGoal()!=null && getParentGoal().getParentPlan()!=null) { RPlan plan = getParentGoal().getParentPlan(); aborted = plan.isAborted(); } return aborted; }
/** * Create a new action. */ public AdoptGoalAction(RGoal goal) { // System.out.println("adopting: "+goal.getId()+" "+goal.getPojoElement().getClass().getName()); this.goal = goal; // todo: support this also for a parent goal?! if(goal.getParent() instanceof RPlan) { this.state = goal.getParentPlan().getLifecycleState(); } }
/** * */ protected void dumpGoals() { if(goals!=null) { System.out.println("--------"); for(RGoal goal: goals) { System.out.println("goal: "+goal+" "+goal.getLifecycleState()+" "+goal.getProcessingState()+" "+goal.getParentPlan()); // if(goal.getInhibitors()!=null) // { // for(RGoal g: goal.getInhibitors()) // { // System.out.print(g+" "+g.getLifecycleState()+" "+g.getProcessingState()); // } // System.out.println(); // } System.out.println("inhibitors: "+goal.getInhibitors()); System.out.println("--------"); } } }
protected void determineValid(RPlan plan, RPlan orig, StringBuffer buf) { buf.append(plan.getId()+plan.aborted); Object reason = plan.getReason(); if(reason instanceof RGoal) { RGoal rg = (RGoal)reason; if(rg.isFinished()) System.out.println("fini goal"+" "+reason+" "+orig); RPlan pp = rg.getParentPlan(); buf.append(" reason is: "+((RProcessableElement)reason).getId()+rg.lifecyclestate); if(pp!=null) { if(pp.isFinished()) System.out.println("fini plan"+" "+pp+" "+orig); buf.append(" parent plan is: "); determineValid(pp, orig, buf); } } } }
/** * Test if the action is valid. * @return True, if action is valid. */ public boolean isValid() { return (state==null|| state.equals(goal.getParentPlan().getLifecycleState())) && RGoal.GoalLifecycleState.NEW.equals(goal.getLifecycleState()); }
/** * * @param plan * @param orig * @param buf */ protected void determineValid(RPlan plan, RPlan orig, StringBuffer buf) { buf.append(plan.getId()+plan.isFinishing()); Object reason = plan.getReason(); if(reason instanceof RGoal) { RGoal rg = (RGoal)reason; if(rg.isFinished()) System.out.println("fini goal"+" "+reason+" "+orig); RPlan pp = rg.getParentPlan(); buf.append(" reason is: "+((RProcessableElement)reason).getId()+rg.lifecyclestate); if(pp!=null) { if(pp.isFinished()) System.out.println("fini plan"+" "+pp+" "+orig); buf.append(" parent plan is: "); determineValid(pp, orig, buf); } } }
/** * Test if the action is valid. * @return True, if action is valid. */ public boolean isValid() { return (state==null || state.equals(goal.getParentPlan().getLifecycleState())) && RGoal.GoalLifecycleState.NEW.equals(goal.getLifecycleState()); }