Package edu.neu.ccs.task

Examples of edu.neu.ccs.task.Task


  protected void initPlan(int id, User user, Agent agent) throws Exception {
    TaskEngine engine = agent.getEngine();
    TaskModelSet modelSet = engine.getModelSet();
    QName topName = new QName(modelSet.getDefaultModel().getURI(), top);
    TaskPlan topPlan = engine.newTaskPlan(topName);
    Task topTask = topPlan.getTask();
   
    for (Map.Entry<String, String> e : topInputs.entrySet())
      topTask.setSlotValueScript(e.getKey(), e.getValue(), "init agent");
   
    if ( ! user.isGuest()) {
      int userId = user.getId();
      Slot userSlot = topTask.getType().getSlotIfExists("user");
      if ((userSlot != null) && userSlot.isInput() && !topInputs.containsKey("user")) {
        if (userSlot.getType().equals("string"))
          topTask.setSlotValue("user", Integer.toString(userId));
        else if (userSlot.getType().equals("number"))
          topTask.setSlotValue("user", userId);
      }
    }
   
    Slot lastConvSlot = topTask.getType().getSlotIfExists("lastConversation");
    if ((lastConvSlot != null) &&
      lastConvSlot.isInput() &&
      lastConvSlot.getType().equals("number") &&
      !topInputs.containsKey("lastConversation")) {
     
      Conversation c = user.getLastConversation(id);
      topTask.setSlotValue("lastConversation", c==null ? null : c.getStart());
    }
   
    if (Bool.isFalse(topTask.isApplicable()))
      throw new IllegalArgumentException("task not applicable: " + topTask);
   
    List<String> undefs = topTask.getUndefinedInputs();
    if ( ! undefs.isEmpty())
      throw new IllegalArgumentException("undefined inputs: " + undefs);
   
    agent.setFocus(topPlan);
  }
View Full Code Here


      }
    }
   
    String exitUrl = null;
    Plan top = agent.getTop();
    Task topTask = top.getThisTask();
    Slot exitUrlSlot = topTask.getType().getSlotIfExists("exitUrl");
    if ((exitUrlSlot != null) &&
      exitUrlSlot.isOutput() &&
      "string".equals(exitUrlSlot.getType()) &&
      topTask.isDefinedSlot("exitUrl")) {
      Object exitUrlObj = topTask.getSlotValue("exitUrl");
      if (exitUrlObj != null)
        exitUrl = exitUrlObj.toString();
    }
   
    output = Command.exit("finished", exitUrl);
View Full Code Here

  private void initPlan(String user) {
    TaskEngine engine = agent.getEngine();
    TaskModelSet modelSet = engine.getModelSet();
    QName topName = new QName(modelSet.getDefaultModel().getURI(), top);
    TaskPlan topPlan = engine.newTaskPlan(topName);
    Task topTask = topPlan.getTask();
   
    for (Map.Entry<String, String> e : topInputs.entrySet())
      topTask.setSlotValueScript(e.getKey(), e.getValue(), "init agent");
   
    if (user != null) {
      Slot userSlot = topTask.getType().getSlotIfExists("user");
      if ((userSlot != null) &&
        userSlot.isInput() &&
        userSlot.getType().equals("string") &&
        !topInputs.containsKey("user"))
        topTask.setSlotValue("user", user);
    }
   
    if (Bool.isFalse(topTask.isApplicable()))
      throw new IllegalArgumentException("task not applicable: " + topTask);
   
    List<String> undefs = topTask.getUndefinedInputs();
    if ( ! undefs.isEmpty())
      throw new IllegalArgumentException("undefined inputs: " + undefs);
   
    agent.setFocus(topPlan);
  }
View Full Code Here

    Map<String, String> slots = new HashMap<String, String>();
    String name = parseTask(str, slots);
   
    TaskPlan plan = getEngine().newTaskPlan(
      XMLUtil.parseQName(getModelSet(), name));
    Task task = plan.getTask();
    for (Map.Entry<String, String> e : slots.entrySet())
      task.setSlotValueScript(e.getKey(), e.getValue(), "run task");
   
    if (plan.isStartable())
      agent.setFocus(plan);
    else {
      List<String> undef = task.getUndefinedInputs();
      if (undef.isEmpty())
        out.println("Cannot run " + task + ": precondition not met");
      else
        out.println("Undefined input: " + undef);
    }
View Full Code Here

  }
 
  private boolean performAtomic(Plan p) {
    if (p instanceof TaskPlan) {
      TaskPlan plan = (TaskPlan) p;
      Task task = plan.getTask();

      // First try to do it as a dialogue turn
      List<Turn> turns = getModelSet().getTurns(plan.getQName());
      for (Turn turn : Priority.copyShuffleSort(turns))
        if (Bool.maybeTrue(turn.isApplicable(task))) {
View Full Code Here

    }
    return currentTurn != null;
  }
 
  private void performedFocus(Boolean success) {
    Task task = getFocusTask();
    task.setWhen(System.currentTimeMillis());
    if (success != null)
      task.setSuccess(success);
    focus.close();
    setCurrentTurn(null);
    engine.update();
  }
View Full Code Here

TOP

Related Classes of edu.neu.ccs.task.Task

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.