Package org.apache.oodt.cas.workflow.structs

Examples of org.apache.oodt.cas.workflow.structs.WorkflowInstance


                        // this means that this workflow was killed, so
                        // gracefully exit
                        break;
                    }

                    WorkflowInstance updatedInst = null;
                    try {
                        updatedInst = instanceRepository
                                .getWorkflowInstanceById(workflowInst.getId());
                        workflowInst = updatedInst;
                    } catch (InstanceRepositoryException e) {
View Full Code Here


     * @see org.apache.oodt.cas.workflow.instrepo.WorkflowInstanceRepository#getWorkflowInstanceById(java.lang.String)
     */
    public WorkflowInstance getWorkflowInstanceById(String workflowInstId)
            throws InstanceRepositoryException {
        IndexSearcher searcher = null;
        WorkflowInstance wInst = null;

        try {
            searcher = new IndexSearcher(idxFilePath);
            Term instIdTerm = new Term("workflow_inst_id", workflowInstId);
            org.apache.lucene.search.Query query = new TermQuery(instIdTerm);
View Full Code Here

            if (hits.length() > 0) {
                wInsts = new Vector(hits.length());

                for (int i = 0; i < hits.length(); i++) {
                    Document doc = hits.doc(i);
                    WorkflowInstance wInst = toWorkflowInstance(doc);
                    wInsts.add(wInst);
                }
            }

        } catch (IOException e) {
View Full Code Here

            if (hits.length() > 0) {
                wInsts = new Vector(hits.length());

                for (int i = 0; i < hits.length(); i++) {
                    Document doc = hits.doc(i);
                    WorkflowInstance wInst = toWorkflowInstance(doc);
                    wInsts.add(wInst);
                }
            }

        } catch (IOException e) {
View Full Code Here

                instIds = new Vector(pageSize);

                for (int i = startNum; i < Math.min(hits.length(),
                        (startNum + pageSize)); i++) {
                    Document instDoc = hits.doc(i);
                    WorkflowInstance inst = toWorkflowInstance(instDoc);
                    instIds.add(inst.getId());

                }
            } else {
                LOG.log(Level.WARNING, "No workflow instances found "
                        + "when attempting to paginate!");
View Full Code Here

            }
        }
    }

    private WorkflowInstance toWorkflowInstance(Document doc) {
        WorkflowInstance inst = new WorkflowInstance();

        // first read all the instance info
        inst.setId(doc.get("workflow_inst_id"));
        inst.setStatus(doc.get("workflow_inst_status"));
        inst.setCurrentTaskId(doc.get("workflow_inst_current_task_id"));
        inst.setCurrentTaskStartDateTimeIsoStr(doc
                .get("workflow_inst_currenttask_startdatetime"));
        inst.setCurrentTaskEndDateTimeIsoStr(doc
                .get("workflow_inst_currenttask_enddatetime"));
        inst.setStartDateTimeIsoStr(doc.get("workflow_inst_startdatetime"));
        inst.setEndDateTimeIsoStr(doc.get("workflow_inst_enddatetime"));

        // read the workflow instance metadata
        Metadata sharedContext = new Metadata();
        String[] instMetFields = doc.getValues("workflow_inst_met_flds");
        if (instMetFields != null && instMetFields.length > 0) {
            for (int i = 0; i < instMetFields.length; i++) {
                String fldName = instMetFields[i];
                String[] vals = doc.getValues(fldName);
                if (vals != null && vals.length > 0) {
                    for (int j = 0; j < vals.length; j++) {
                        sharedContext.addMetadata(fldName, vals[j]);
                    }
                }
            }
        }

        inst.setSharedContext(sharedContext);

        // now read all of the workflow info

        Workflow workflow = new Workflow();

        workflow.setId(doc.get("workflow_id"));
        workflow.setName(doc.get("workflow_name"));
        workflow.setTasks(toTasks(doc));

        inst.setWorkflow(workflow);

        return inst;
    }
View Full Code Here

    while(true){
     
      Vector workflowQueue = engine.getWorkflowQueue();
     
      for(int i=0;i<workflowQueue.size();i++){
        WorkflowInstance wInst = (WorkflowInstance)workflowQueue.get(i)
        WorkflowTask task = getTaskById(wInst.getWorkflow(),wInst.getCurrentTaskId());
     
        //check required metadata on current task
        if (!checkTaskRequiredMetadata(task, wInst.getSharedContext())) {
                  wInst.setStatus(METADATA_MISSING);
                  try{
                    engine.persistWorkflowInstance(wInst);
                  } catch (EngineException e){
                  }
                  break;
        }
       
        //check preconditions on current task
        if (task.getConditions() != null) {
                  if(!satisfied(wInst)) {

                      /*LOG.log(Level.FINEST, "Pre-conditions for task: "
                              + task.getTaskName() + " unsatisfied.");*/
                 
                  } else {
                    //create thread, remove from queue, then if there is another task, increment and read to the queue
                   
                    engine.submitWorkflowInstancetoPool(wInst);

                      workflowQueue.remove(wInst);
                      i--;
                     
                      List tasks = wInst.getWorkflow().getTasks();
                      for(int j=0;j<tasks.size();j++){
                        if( ((WorkflowTask)tasks.get(j)).getTaskId().equals(wInst.getCurrentTaskId()) && j<(tasks.size()-1)){
                          wInst.setCurrentTaskId( ((WorkflowTask)tasks.get(j+1)).getTaskId() );
                          workflowQueue.add(wInst);
                        }
                      }
                  }
              }   
View Full Code Here

        return eventName;
    }

    public static WorkflowInstance getWorkflowInstance(ResultSet rs)
            throws SQLException {
        WorkflowInstance workflowInst = new WorkflowInstance();
        workflowInst.setStatus(rs.getString("workflow_instance_status"));
        workflowInst.setId(rs.getString("workflow_instance_id"));
        workflowInst.setCurrentTaskId(rs.getString("current_task_id"));
        workflowInst.setStartDateTimeIsoStr(rs.getString("start_date_time"));
        workflowInst.setEndDateTimeIsoStr(rs.getString("end_date_time"));
        workflowInst.setCurrentTaskStartDateTimeIsoStr(rs
                .getString("current_task_start_date_time"));
        workflowInst.setCurrentTaskEndDateTimeIsoStr(rs
                .getString("current_task_end_date_time"));
        Workflow workflow = new Workflow();
        workflow.setId(rs.getString("workflow_id"));
        workflowInst.setWorkflow(workflow);
        return workflowInst;
    }
View Full Code Here

        // to start the workflow, we create a default workflow instance
        // populate it
        // persist it
      // add it to the workflowQueue

        WorkflowInstance wInst = new WorkflowInstance();
        wInst.setWorkflow(workflow);
        wInst.setCurrentTaskId(((WorkflowTask) workflow.getTasks().get(0))
                .getTaskId());
        wInst.setSharedContext(metadata);
        wInst.setStatus(CREATED);
        persistWorkflowInstance(wInst);

        wInst.setStatus(QUEUED);
        String startDateTimeIsoStr = DateConvert.isoFormat(new Date());
        wInst.setStartDateTimeIsoStr(startDateTimeIsoStr);

        workflowQueue.add(wInst);
        persistWorkflowInstance(wInst);

        return wInst;
View Full Code Here

     *      org.apache.oodt.cas.metadata.Metadata)
     */
    public synchronized boolean updateMetadata(String workflowInstId,
            Metadata met) {
        // okay, try and look up that worker
      WorkflowInstance wInst = null;
      try{
         wInst = this.instRep.getWorkflowInstanceById(workflowInstId);
           if (wInst != null) {
              wInst.setSharedContext(met);
              persistWorkflowInstance(wInst);
           } else {
             LOG.log(Level.WARNING,
                       "WorkflowEngine: Attempt to update metadata context "
                               + "for workflow instance id: " + workflowInstId
                               + ", however, this engine is "
                               + "not tracking its execution");
               return false;
           }
         
        } catch (Exception e) {
              LOG.log(Level.WARNING, "Exception persisting workflow instance: ["
                    + wInst.getId() + "]: Message: "
                    + e.getMessage());
              return false;
        }
        return true;
    }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.workflow.structs.WorkflowInstance

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.