Package org.fireflow.engine

Examples of org.fireflow.engine.IProcessInstance


    if (wfProcess == null) {
      throw new RuntimeException(
          "Workflow process NOT found,id=[" + wfprocessId
              + "]");
    }
    IProcessInstance processInstance =  (IProcessInstance) this.execute(new IWorkflowSessionCallback() {

      public Object doInWorkflowSession(RuntimeContext ctx)
          throws EngineException, KernelException {

        ProcessInstance processInstance = new ProcessInstance();
        processInstance.setCreatorId(creatorId);
        processInstance.setProcessId(wfProcess.getId());
        processInstance.setVersion(workflowDef.getVersion());
        processInstance.setDisplayName(wfProcess.getDisplayName());
        processInstance.setName(wfProcess.getName());
        processInstance.setState(IProcessInstance.INITIALIZED);
        processInstance.setCreatedTime(ctx.getCalendarService()
            .getSysDate());
        processInstance
            .setParentProcessInstanceId(parentProcessInstanceId);
        processInstance.setParentTaskInstanceId(parentTaskInstanceId);
       
        ctx.getPersistenceService().saveOrUpdateProcessInstance(
            processInstance);
       
        return processInstance;
      }
    });
   
    // 初始化流程变量
    processInstance.setProcessInstanceVariables(new HashMap<String, Object>());
   
    List<DataField> datafields = wfProcess.getDataFields();
    for (int i = 0; datafields != null && i < datafields.size(); i++) {
      DataField df =  datafields.get(i);
      if (df.getDataType().equals(DataField.STRING)) {
        if (df.getInitialValue() != null) {
          processInstance.setProcessInstanceVariable(df
              .getName(), df.getInitialValue());
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), "");
        }
      } else if (df.getDataType().equals(DataField.INTEGER)) {
        if (df.getInitialValue() != null) {
          try {
            Integer intValue = new Integer(df
                .getInitialValue());
            processInstance.setProcessInstanceVariable(df
                .getName(), intValue);
          } catch (Exception e) {
          }
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), new Integer(0));
        }
      } else if (df.getDataType().equals(DataField.LONG)) {
        if (df.getInitialValue() != null) {
          try {
            Long longValue = new Long(df.getInitialValue());
            processInstance.setProcessInstanceVariable(df
                .getName(), longValue);
          } catch (Exception e) {
          }
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), new Long(0));
        }
      } else if (df.getDataType().equals(DataField.FLOAT)) {
        if (df.getInitialValue() != null) {
          Float floatValue = new Float(df.getInitialValue());
          processInstance.setProcessInstanceVariable(df
              .getName(), floatValue);
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), new Float(0));
        }
      } else if (df.getDataType().equals(DataField.DOUBLE)) {
        if (df.getInitialValue() != null) {
          Double doubleValue = new Double(df
              .getInitialValue());
          processInstance.setProcessInstanceVariable(df
              .getName(), doubleValue);
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), new Double(0));
        }
      } else if (df.getDataType().equals(DataField.BOOLEAN)) {
        if (df.getInitialValue() != null) {
          Boolean booleanValue = new Boolean(df
              .getInitialValue());
          processInstance.setProcessInstanceVariable(df
              .getName(), booleanValue);
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), Boolean.FALSE);
        }
      } else if (df.getDataType().equals(DataField.DATETIME)) {
        // TODO 需要完善一下
        if (df.getInitialValue() != null
            && df.getDataPattern() != null) {
          try {
            SimpleDateFormat dFormat = new SimpleDateFormat(
                df.getDataPattern());
            Date dateTmp = dFormat.parse(df
                .getInitialValue());
            processInstance.setProcessInstanceVariable(df
                .getName(), dateTmp);
          } catch (Exception e) {
            processInstance.setProcessInstanceVariable(df
                .getName(), null);
            e.printStackTrace();
          }
        } else {
          processInstance.setProcessInstanceVariable(df
              .getName(), null);
        }
      }
    }
    return processInstance;
View Full Code Here


    this.dynamicAssignmentHandler = dynamicAssignmentHandler;
  }

  public IProcessInstance abortProcessInstance(String processInstanceId)
      throws EngineException {
    IProcessInstance processInstance = this
        .findProcessInstanceById(processInstanceId);
    processInstance.abort();
    return processInstance;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.fireflow.engine.IWorkflowSession#restoreProcessInstance(java.lang.String)
   */
  public IProcessInstance restoreProcessInstance(String processInstanceId)
      throws EngineException {
    IProcessInstance processInstance = this
        .findProcessInstanceById(processInstanceId);
    processInstance.restore();
    return processInstance;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.fireflow.engine.IWorkflowSession#suspendProcessInstance(java.lang.String)
   */
  public IProcessInstance suspendProcessInstance(String processInstanceId)
      throws EngineException {
    IProcessInstance processInstance = this
        .findProcessInstanceById(processInstanceId);
    processInstance.suspend();
    return processInstance;
  }
View Full Code Here

    return query.getResultList();
  }

  public IProcessInstance findProcessInstanceById(String id)
  {
    IProcessInstance processInstance = this.em.find(ProcessInstance.class, id);
   
    return processInstance;
  }
View Full Code Here

    List list = query.getResultList();
    if (list.size() == 0)
      return null;
    else
    {
      IProcessInstance processInstance = (IProcessInstance) list.get(0);
      return processInstance;
    }
  }
View Full Code Here

    /* (non-Javadoc)
     * @see org.fireflow.engine.persistence.IPersistenceService#findAliveProcessInstanceById(java.lang.String)
     */
    public IProcessInstance findAliveProcessInstanceById(final String id) {
        IProcessInstance result = (IProcessInstance) this.getHibernateTemplate().execute(new HibernateCallback() {

            public Object doInHibernate(Session arg0) throws HibernateException, SQLException {
                Criteria criteria = arg0.createCriteria(ProcessInstance.class);


View Full Code Here

   */
  public IProcessInstance findProcessInstanceById(String id)
  {
    String sql = "select * from t_ff_rt_processinstance where id=?  ";

    IProcessInstance iProcessInstance = (IProcessInstance) super.getJdbcTemplate().queryForObject(sql,
        new Object[] { id }, new ProcessInstanceRowMapper());

    // 变量不需要同时查询出来,在第一次使用的时候查询,2009-11-1,非也
    // iProcessInstance.setProcessInstanceVariables(getVarMap(iProcessInstance.getId()));

View Full Code Here

  {

    String sql = "select * from t_ff_rt_processinstance where id=? and ( state=" + IProcessInstance.INITIALIZED
        + " or state=" + IProcessInstance.RUNNING + ")";

    IProcessInstance iProcessInstance = (IProcessInstance) super.getJdbcTemplate().queryForObject(sql,
        new Object[] { id }, new ProcessInstanceRowMapper());

    // 变量不需要同时查询出来,在第一次使用的时候查询,2009-11-1,非也
    // iProcessInstance.setProcessInstanceVariables(getVarMap(iProcessInstance.getId()));
    return iProcessInstance;
View Full Code Here

   
    Activity activity = activityInstance.getActivity();
    IPersistenceService persistenceService = rtCtx.getPersistenceService();
    ICalendarService calService = rtCtx.getCalendarService();

    IProcessInstance processInstance = token.getProcessInstance();
    WorkflowSession workflowSession = (WorkflowSession) ((IWorkflowSessionAware) processInstance)
        .getCurrentWorkflowSession();

    if (workflowSession == null) {
      throw new EngineException(token.getProcessInstance(),
          activityInstance.getActivity(),
          "The workflow session in process instance can NOT be null");
    }

    int createdTaskInstanceCount = 0;
    for (int i = 0; i < activity.getTasks().size(); i++) {
      Task task = activity.getTasks().get(i);
      // 1、创建Task实例,并设置工作流系统定义的属性
      ITaskInstance taskInstance = this.createTaskInstance(
          workflowSession, processInstance, task, activity);

      if (taskInstance == null) {
        continue;
      }
      createdTaskInstanceCount = createdTaskInstanceCount + 1;

      String taskType = task.getType();
      ((TaskInstance) taskInstance).setTaskType(taskType);
      ((TaskInstance) taskInstance).setStepNumber(token.getStepNumber());
      // ((TaskInstance) taskInstance).setTokenId(token.getId());
      ((TaskInstance) taskInstance).setProcessInstanceId(processInstance
          .getId());
      ((TaskInstance) taskInstance).setProcessId(processInstance
          .getProcessId());
      ((TaskInstance) taskInstance).setVersion(processInstance
          .getVersion());
      ((TaskInstance) taskInstance).setActivityId(activity.getId());
      if (Task.FORM.equals(taskType)) {
        ((TaskInstance) taskInstance)
            .setAssignmentStrategy(((FormTask) task)
View Full Code Here

TOP

Related Classes of org.fireflow.engine.IProcessInstance

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.