Package org.apache.oodt.cas.workflow.lifecycle

Examples of org.apache.oodt.cas.workflow.lifecycle.WorkflowState


   * @param status
   *          The provided status to set.
   */
  @Deprecated
  public void setStatus(String status) {
    WorkflowState state = new WorkflowState();
    state.setName(status);
    this.state = state;
  }
View Full Code Here


          String msg = "Task: [" + workflowTask.getTaskName()
              + "] for instance id: ["
              + taskProcessor.getWorkflowInstance().getId()
              + "] completed successfully";
          LOG.log(Level.INFO, msg);
          WorkflowState state = lifecycle.createState("ExecutionComplete", "transition", msg);
          taskProcessor.getWorkflowInstance().setState(state);
          persist(taskProcessor.getWorkflowInstance());
        } catch (Exception e) {
          e.printStackTrace();
          String msg = "Exception executing task: ["
              + workflowTask.getTaskName() + "]: Message: " + e.getMessage();
          LOG.log(Level.WARNING, msg);
          WorkflowState state = lifecycle.createState("Failure", "done", msg);
          taskProcessor.getWorkflowInstance().setState(state);
          persist(taskProcessor.getWorkflowInstance());
        }

      }
View Full Code Here

    this.excusedSubProcessorIds = new Vector<String>();
    this.minReqSuccessfulSubProcessors = -1;
    this.lifecycleManager = lifecycleManager;
    this.workflowInstance = workflowInstance;
    this.helper = new WorkflowProcessorHelper(lifecycleManager);
    WorkflowState initState = helper.getLifecycleForProcessor(this)
        .createState("Null", "initial",
            "Instance created by workflow processor.");
    this.workflowInstance.setState(initState);
  }
View Full Code Here

   * Advances this WorkflowProcessor to its next {@link WorkflowState}.
   */
  public void nextState() {
    if (this.workflowInstance != null
        && this.workflowInstance.getState() != null) {
      WorkflowState currState = this.workflowInstance.getState();
      WorkflowState nextState = null;
      if (currState.getName().equals("Null")) {
        nextState = this.helper.getLifecycleForProcessor(this).createState(
            "Loaded",
            "initial",
            "Workflow Processor: nextState: " + "loading workflow instance: ["
View Full Code Here

        return processor;
      }

      if (isCompositeProcessor(inst)) {
        processor = getProcessorFromInstanceGraph(inst, lifecycle);
        WorkflowState processorState = getLifecycle(
            inst.getParentChildWorkflow()).createState(
            "Loaded",
            "initial",
            "Sequential Workflow instance with id: [" + inst.getId()
                + "] loaded by processor queue.");
        inst.setState(processorState);
        persist(inst);

        // handle its pre-conditions
        for (WorkflowCondition cond : inst.getParentChildWorkflow()
            .getPreConditions()) {
          WorkflowInstance instance = new WorkflowInstance();
          WorkflowState condWorkflowState = lifecycle
              .getDefaultLifecycle()
              .createState(
                  "Null",
                  "initial",
                  "Sub Pre Condition Workflow created by Workflow Processor Queue for workflow instance: "
                      + "[" + inst.getId() + "]");
          instance.setState(condWorkflowState);
          instance.setPriority(inst.getPriority());
          WorkflowTask conditionTask = toConditionTask(cond);
          instance.setCurrentTaskId(conditionTask.getTaskId());
          Graph condGraph = new Graph();
          condGraph.setExecutionType("condition");
          condGraph.setCond(cond);
          condGraph.setTask(conditionTask);
          ParentChildWorkflow workflow = new ParentChildWorkflow(condGraph);
          workflow.setId("pre-cond-workflow-"
              + inst.getParentChildWorkflow().getId());
          workflow.setName("Pre Condition Workflow-" + cond.getConditionName());
          workflow.getTasks().add(conditionTask);
          instance.setParentChildWorkflow(workflow);
          this.addToModelRepo(workflow);
          persist(instance);
          WorkflowProcessor subProcessor = fromWorkflowInstance(instance);
          processor.getSubProcessors().add(subProcessor);
          synchronized (processorCache) {
            processorCache.put(instance.getId(), subProcessor);
          }
        }

        // handle its tasks
        for (WorkflowTask task : inst.getParentChildWorkflow().getTasks()) {
          WorkflowInstance instance = new WorkflowInstance();
          WorkflowState taskWorkflowState = lifecycle.getDefaultLifecycle()
              .createState(
                  "Null",
                  "initial",
                  "Sub Task Workflow created by Workflow Processor Queue for workflow instance: "
                      + "[" + inst.getId() + "]");
          instance.setState(taskWorkflowState);
          instance.setPriority(inst.getPriority());
          instance.setCurrentTaskId(task.getTaskId());
          Graph taskGraph = new Graph();
          taskGraph.setExecutionType("task");
          taskGraph.setTask(task);
          ParentChildWorkflow workflow = new ParentChildWorkflow(taskGraph);
          workflow.setId("task-workflow-"
              + inst.getParentChildWorkflow().getId());
          workflow.setName("Task Workflow-" + task.getTaskName());
          workflow.getTasks().add(task);
          workflow.getGraph().setTask(task);
          instance.setParentChildWorkflow(workflow);
          this.addToModelRepo(workflow);
          persist(instance);
          WorkflowProcessor subProcessor = fromWorkflowInstance(instance);
          processor.getSubProcessors().add(subProcessor);
          synchronized (processorCache) {
            processorCache.put(instance.getId(), subProcessor);
          }
        }

        // handle its post conditions
        for (WorkflowCondition cond : inst.getParentChildWorkflow()
            .getPostConditions()) {
          WorkflowInstance instance = new WorkflowInstance();
          WorkflowState condWorkflowState = lifecycle
              .getDefaultLifecycle()
              .createState(
                  "Null",
                  "initial",
                  "Sub Post Condition Workflow created by Workflow Processor Queue for workflow instance: "
                      + "[" + inst.getId() + "]");
          instance.setState(condWorkflowState);
          instance.setPriority(inst.getPriority());
          WorkflowTask conditionTask = toConditionTask(cond);
          instance.setCurrentTaskId(conditionTask.getTaskId());
          Graph condGraph = new Graph();
          condGraph.setExecutionType("condition");
          condGraph.setCond(cond);
          condGraph.setTask(conditionTask);
          ParentChildWorkflow workflow = new ParentChildWorkflow(condGraph);
          workflow.setId("post-cond-workflow-"
              + inst.getParentChildWorkflow().getId());
          workflow
              .setName("Post Condition Workflow-" + cond.getConditionName());
          workflow.getTasks().add(conditionTask);
          instance.setParentChildWorkflow(workflow);
          this.addToModelRepo(workflow);
          persist(instance);
          WorkflowProcessor subProcessor = fromWorkflowInstance(instance);
          processor.getSubProcessors().add(subProcessor);
          synchronized (processorCache) {
            processorCache.put(instance.getId(), subProcessor);
          }
        }

      } else {
        // it's not a composite workflow, and it's either just a task processor
        // or a condition processor
        if (inst.getParentChildWorkflow().getGraph().getExecutionType()
            .equals("task")) {
          processor = new TaskProcessor(lifecycle, inst);
          WorkflowState taskProcessorState = getLifecycle(
              inst.getParentChildWorkflow()).createState(
              "Loaded",
              "initial",
              "Task Workflow instance with id: [" + inst.getId()
                  + "] loaded by processor queue.");
          inst.setState(taskProcessorState);

          // handle its pre-conditions
          for (WorkflowCondition cond : inst.getParentChildWorkflow()
              .getGraph().getTask().getPreConditions()) {
            WorkflowInstance instance = new WorkflowInstance();
            WorkflowState condWorkflowState = lifecycle
                .getDefaultLifecycle()
                .createState(
                    "Null",
                    "initial",
                    "Sub Pre Condition Workflow for Task created by Workflow Processor Queue for workflow instance: "
                        + "[" + inst.getId() + "]");
            instance.setState(condWorkflowState);
            instance.setPriority(inst.getPriority());
            WorkflowTask conditionTask = toConditionTask(cond);
            instance.setCurrentTaskId(conditionTask.getTaskId());
            Graph condGraph = new Graph();
            condGraph.setExecutionType("condition");
            condGraph.setCond(cond);
            condGraph.setTask(conditionTask);
            ParentChildWorkflow workflow = new ParentChildWorkflow(condGraph);
            workflow.setId("pre-cond-workflow-"
                + inst.getParentChildWorkflow().getGraph().getTask()
                    .getTaskId());
            workflow.setName("Task Pre Condition Workflow-"
                + cond.getConditionName());
            workflow.getTasks().add(conditionTask);
            instance.setParentChildWorkflow(workflow);
            this.addToModelRepo(workflow);
            persist(instance);
            WorkflowProcessor subProcessor = fromWorkflowInstance(instance);
            processor.getSubProcessors().add(subProcessor);
            synchronized (processorCache) {
              processorCache.put(instance.getId(), subProcessor);
            }
          }

          // handle its post-conditions
          for (WorkflowCondition cond : inst.getParentChildWorkflow()
              .getGraph().getTask().getPostConditions()) {
            WorkflowInstance instance = new WorkflowInstance();
            WorkflowState condWorkflowState = lifecycle
                .getDefaultLifecycle()
                .createState(
                    "Null",
                    "initial",
                    "Sub Post Condition Workflow for Task created by Workflow Processor Queue for workflow instance: "
                        + "[" + inst.getId() + "]");
            instance.setState(condWorkflowState);
            instance.setPriority(inst.getPriority());
            WorkflowTask conditionTask = toConditionTask(cond);
            instance.setCurrentTaskId(conditionTask.getTaskId());
            Graph condGraph = new Graph();
            condGraph.setExecutionType("condition");
            condGraph.setCond(cond);
            condGraph.setTask(conditionTask);
            ParentChildWorkflow workflow = new ParentChildWorkflow(condGraph);
            workflow.setId("post-cond-workflow-"
                + inst.getParentChildWorkflow().getGraph().getTask()
                    .getTaskId());
            workflow.setName("Task Post Condition Workflow-"
                + cond.getConditionName());
            workflow.getTasks().add(conditionTask);
            instance.setParentChildWorkflow(workflow);
            this.addToModelRepo(workflow);
            persist(instance);
            WorkflowProcessor subProcessor = fromWorkflowInstance(instance);
            processor.getSubProcessors().add(subProcessor);
            synchronized (processorCache) {
              processorCache.put(instance.getId(), subProcessor);
            }
          }

        } else if (inst.getParentChildWorkflow().getGraph().getExecutionType()
            .equals("condition")) {
          processor = new ConditionProcessor(lifecycle, inst);
          WorkflowState condProcessorState = getLifecycle(
              inst.getParentChildWorkflow()).createState(
              "Loaded",
              "initial",
              "Condition Workflow instance with id: [" + inst.getId()
                  + "] loaded by processor queue.");
View Full Code Here

        if (!processor.isAnyCategory("done", "holding")
            && !processor.isAnyState("Executing")
            && processor.getRunnableWorkflowProcessors().size() > 0) {
          for (TaskProcessor tp : processor.getRunnableWorkflowProcessors()) {
            WorkflowState state = lifecycle.createState("WaitingOnResources",
                "waiting", "Added to Runnable queue");
            tp.getWorkflowInstance().setState(state);
            persist(tp.getWorkflowInstance());
            LOG.log(Level.INFO, "Added processor with priority: ["
                + tp.getWorkflowInstance().getPriority() + "]");
View Full Code Here

        // category
        doc.add(new Field("workflow_inst_status", workflowInst.getStatus(),
                Field.Store.YES, Field.Index.UN_TOKENIZED));
       
        if(workflowInst.getState() != null){
          WorkflowState state = workflowInst.getState();
       
          if(state.getDescription() != null){
            doc.add(new Field("workflow_inst_state_desc",
                state.getDescription(), Field.Store.YES, Field.Index.UN_TOKENIZED));
          }
         
          if(state.getMessage() != null){
            doc.add(new Field("workflow_inst_state_message",
                state.getMessage(), Field.Store.YES, Field.Index.UN_TOKENIZED));
          }
         
          if(state.getCategory() != null && state.getCategory().getName() != null){
            doc.add(new Field("workflow_inst_state_category",
                state.getCategory().getName(), Field.Store.YES, Field.Index.UN_TOKENIZED));
          }
        }       
       
        doc
                .add(new Field("workflow_inst_current_task_id", workflowInst
View Full Code Here

       
        inst.setTimesBlocked(Integer.parseInt(doc.get("workflow_inst_timesblocked") !=
          null ? doc.get("workflow_inst_timesblocked"):"0"));
       
        // try and construct a state
        WorkflowState state = new WorkflowState();
        state.setName(doc.get("workflow_inst_status"));
        if(doc.get("workflow_inst_state_category") != null){
          WorkflowLifecycleStage category = new WorkflowLifecycleStage();
          category.setName(doc.get("workflow_inst_state_category"));
          state.setCategory(category);
        }
       
        if(doc.get("workflow_inst_state_desc") != null){
          state.setDescription(doc.get("workflow_inst_state_desc"));
        }
       
        if(doc.get("workflow_inst_state_message") != null){
          state.setMessage(doc.get("workflow_inst_state_message"));
        }       
        inst.setState(state);
        inst.setCurrentTaskId(doc.get("workflow_inst_current_task_id"));
        inst.setCurrentTaskStartDateTimeIsoStr(doc
                .get("workflow_inst_currenttask_startdatetime"));
View Full Code Here

    inst.setCurrentTaskId(workflow.getTasks().get(0).getTaskId());
    inst.setSharedContext(metadata);
    inst.setPriority(Priority.getDefault()); // FIXME: this should be sensed or
                                             // passed in
    WorkflowLifecycle cycle = getLifecycleForWorkflow(workflow);
    WorkflowState state = cycle.createState("Null", "initial",
        "Workflow created by Engine.");
    inst.setState(state);
    persist(inst);
    return inst;
  }
View Full Code Here

    return tasks;
  }

  public void validateWorkflowProcessor(WorkflowProcessor wp) {
    if (wp instanceof TaskProcessor) {
      WorkflowState state = wp.getState();
      WorkflowLifecycle lc = this.lifecycle.getLifecycleForWorkflow(wp
          .getWorkflowInstance().getWorkflow());
      if (lc == null)
        lc = this.lifecycle.getDefaultLifecycle();
      if ((state.getName().equals("WaitingOnResources") && state.getPrevState()
          .getName().equals("Executing"))
          || state.getName().equals("Executing"))
        wp.setState(lc.createState("Queued", "waiting",
            "Marked back to queued state because of system failure"));
      else
        wp.setState(state);
    } else {
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.workflow.lifecycle.WorkflowState

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.