Examples of IProcessInstance


Examples of org.fireflow.engine.IProcessInstance

        ((TaskInstance) taskInstance).setStartedTime(runtimeContext.getCalendarService().getSysDate());
        //TODO wmj2003 应该是update TaskInstance
        persistenceService.saveOrUpdateTaskInstance(taskInstance);


        IProcessInstance subProcessInstance = currentSession.createProcessInstance(subWorkflowProcess.getName(),taskInstance);

        //初始化流程变量,从父实例获得初始值
        Map<String ,Object> processVars = ((TaskInstance) taskInstance).getAliveProcessInstance().getProcessInstanceVariables();
        List<DataField> datafields = subWorkflowProcess.getDataFields();
        for (int i = 0; datafields != null && i < datafields.size(); i++) {
            DataField df = datafields.get(i);
            //TODO wmj2003 疑问,这里的逻辑都不对吧? 直接 subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
            //还需要判断什么类型啊?反正value是Object
            if (df.getDataType().equals(DataField.STRING)) {
                if (processVars.get(df.getName()) != null && (processVars.get(df.getName()) instanceof String)) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
                } else if (df.getInitialValue() != null) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), df.getInitialValue());
                } else {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), "");
                }
            } else if (df.getDataType().equals(DataField.INTEGER)) {
                if (processVars.get(df.getName()) != null && (processVars.get(df.getName()) instanceof Integer)) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
                } else if (df.getInitialValue() != null) {
                    try {
                        Integer intValue = new Integer(df.getInitialValue());
                        subProcessInstance.setProcessInstanceVariable(df.getName(), intValue);
                    } catch (Exception e) {
                    }
                } else {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), new Integer(0));
                }
            } else if (df.getDataType().equals(DataField.FLOAT)) {
                if (processVars.get(df.getName()) != null && (processVars.get(df.getName()) instanceof Float)) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
                } else if (df.getInitialValue() != null) {
                    Float floatValue = new Float(df.getInitialValue());
                    subProcessInstance.setProcessInstanceVariable(df.getName(), floatValue);
                } else {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), new Float(0));
                }
            } else if (df.getDataType().equals(DataField.BOOLEAN)) {
                if (processVars.get(df.getName()) != null && (processVars.get(df.getName()) instanceof Boolean)) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
                } else if (df.getInitialValue() != null) {
                    Boolean booleanValue = new Boolean(df.getInitialValue());
                    subProcessInstance.setProcessInstanceVariable(df.getName(), booleanValue);
                } else {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), Boolean.FALSE);
                }
            } else if (df.getDataType().equals(DataField.DATETIME)) {
                //TODO 需要完善一下 ( 父子流程数据传递——时间类型的数据还未做传递-不知道为什么?)
              //wmj2003 20090925 补充上了
                if (processVars.get(df.getName()) != null && (processVars.get(df.getName()) instanceof Date)) {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), processVars.get(df.getName()));
                } else if (df.getInitialValue() != null) {
          try {
                    SimpleDateFormat dFormat = new SimpleDateFormat(df.getDataPattern());
            Date dateTmp = dFormat.parse(df.getInitialValue());
            subProcessInstance.setProcessInstanceVariable(df.getName(), dateTmp);
          } catch (ParseException e) {
            subProcessInstance.setProcessInstanceVariable(df.getName(), null);
            e.printStackTrace();
          }
                  
                } else {
                    subProcessInstance.setProcessInstanceVariable(df.getName(), null);
                }
            }
        }
        //TODO 应将下面这句删除!这里还需要吗?应该直接subProcessInstance.run()就可以了。
        runtimeContext.getPersistenceService().saveOrUpdateProcessInstance(subProcessInstance);
        subProcessInstance.run();
    }
View Full Code Here

Examples of org.fireflow.engine.IProcessInstance

            if (value < volume) {// 如果Value小于容量则继续等待其他弧的汇聚。 (哪些状态为dead的token到此结束,不再向下传递)
                return
            }
        }
        //如果汇聚点的容量和同步器节点的容量相同
        IProcessInstance processInstance = tk.getProcessInstance();
        // Synchronize的fire条件应该只与joinPoint的value有关(value==volume),与alive无关
        NodeInstanceEvent event2 = new NodeInstanceEvent(this);
        event2.setToken(tk);
        event2.setEventType(NodeInstanceEvent.NODEINSTANCE_FIRED);
        fireNodeEvent(event2);
View Full Code Here

Examples of org.fireflow.engine.IProcessInstance

        }

        tk.setNodeId(this.getSynchronizer().getId());//到开始节点(同步器)

        IProcessInstance processInstance = tk.getProcessInstance();//从token中获得流程实例对象

        //触发token_entered事件
        NodeInstanceEvent event1 = new NodeInstanceEvent(this);
        event1.setToken(tk);
        event1.setEventType(NodeInstanceEvent.NODEINSTANCE_TOKEN_ENTERED); //token进入
View Full Code Here

Examples of org.fireflow.engine.IProcessInstance

            if (value < volume) {// 如果Value小于容量则继续等待其他弧的汇聚。
                return;
            }
        }

        IProcessInstance processInstance = tk.getProcessInstance();
        NodeInstanceEvent event2 = new NodeInstanceEvent(this);
        event2.setToken(tk);
        event2.setEventType(NodeInstanceEvent.NODEINSTANCE_FIRED);
        fireNodeEvent(event2);
       
View Full Code Here

Examples of org.fireflow.engine.IProcessInstance

  /* (non-Javadoc)
   * @see org.fireflow.engine.event.ITaskInstanceEventListener#onTaskInstanceEventFired(org.fireflow.engine.event.TaskInstanceEvent)
   */
  public void onTaskInstanceEventFired(TaskInstanceEvent e) throws EngineException {
    IWorkflowSession session = e.getWorkflowSession();
    IProcessInstance proceInst = e.getProcessInstance();
    ITaskInstance taskInst = (ITaskInstance)e.getSource();
    IWorkItem wi = e.getWorkItem();
    if (e.getEventType()==TaskInstanceEvent.BEFORE_TASK_INSTANCE_START){
      beforeTaskInstanceStart(session,proceInst,taskInst);
    }else if (e.getEventType()==TaskInstanceEvent.AFTER_TASK_INSTANCE_COMPLETE){
View Full Code Here

Examples of org.fireflow.engine.IProcessInstance

    public void testSaveOrUpdateProcessInstance() {
        System.out.println("--------saveOrUpdateProcessInstance--------");
        final String parentProcessInstanceId = "parent process instance 123";
        final String parentTaskInstanceId = "parent task instance 123";

        IProcessInstance processInstance1 = (IProcessInstance) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {

                ProcessInstance processInstance = new ProcessInstance();
                processInstance.setCreatedTime(createdTime);
                processInstance.setDisplayName(displayName);
                processInstance.setEndTime(endTime);
                processInstance.setExpiredTime(expiredTime);
                processInstance.setName(name);
                processInstance.setParentProcessInstanceId(parentProcessInstanceId);
                processInstance.setParentTaskInstanceId(parentTaskInstanceId);
                processInstance.setProcessId(processId);
                processInstance.setStartedTime(startedTime);
                processInstance.setState(state);
                processInstance.setVersion(version);

                persistenceService.saveOrUpdateProcessInstance(processInstance);

                return processInstance;
            }
        });

        System.out.println("The new process instance id  = " + processInstance1.getId());
        aliveProcessInstanceId = processInstance1.getId();
        IProcessInstance processInstance2 = persistenceService.findProcessInstanceById(processInstance1.getId());

        assertFalse(processInstance1.hashCode() == processInstance2.hashCode());
        assertEquals(processInstance1.getId(), processInstance2.getId());
        assertEquals(processInstance2.getName(), name);
        assertEquals(processInstance2.getDisplayName(), displayName);
        assertEquals(processInstance2.getProcessId(), processId);
        assertEquals(dFormat.format(processInstance2.getCreatedTime()), dFormat.format(createdTime));
        assertEquals(dFormat.format(processInstance2.getStartedTime()), dFormat.format(startedTime));
        assertEquals(dFormat.format(processInstance2.getExpiredTime()), dFormat.format(expiredTime));
        assertEquals(dFormat.format(processInstance2.getEndTime()), dFormat.format(endTime));
        assertEquals(processInstance2.getState(), state);
        assertEquals(processInstance2.getVersion(), version);
        assertEquals(processInstance2.getParentProcessInstanceId(), parentProcessInstanceId);
        assertEquals(processInstance2.getParentTaskInstanceId(), parentTaskInstanceId);
    }
View Full Code Here

Examples of org.fireflow.engine.IProcessInstance

     * Test of findProcessInstanceById method, of class PersistenceServiceHibernateImpl.
     */
    @Test
    public void testFindProcessInstanceById() {
        System.out.println("--------findProcessInstanceById--------");
        IProcessInstance processInstance = persistenceService.findProcessInstanceById(this.aliveProcessInstanceId);
        assertNotNull(processInstance);
        assertEquals(processInstance.getProcessId(), this.processId);
    }
View Full Code Here

Examples of org.fireflow.engine.IProcessInstance

     * Test of findAliveProcessInstanceById method, of class PersistenceServiceHibernateImpl.
     */
    @Test
    public void testFindAliveProcessInstanceById() {
        System.out.println("--------findAliveProcessInstanceById--------");
        IProcessInstance processInstance = persistenceService.findAliveProcessInstanceById(this.aliveProcessInstanceId);
        assertNotNull(processInstance);
        assertEquals(processInstance.getProcessId(), this.processId);
    }
View Full Code Here

Examples of org.fireflow.engine.IProcessInstance

*/
public class EmailSender implements IApplicationHandler {

  @Override
  public void execute(ITaskInstance arg0) {
    IProcessInstance processInstance = ((TaskInstance)arg0).getAliveProcessInstance();
    //从流程变量中取出相关的信息
    String applicant = (String)processInstance.getProcessInstanceVariable("applicant");//申请人
    Integer leaveDays = (Integer)processInstance.getProcessInstanceVariable("leaveDays");//请假天数
    Boolean approvalFlag = (Boolean)processInstance.getProcessInstanceVariable("approvalFlag");//审批标志
    System.out.println("\n\n=========EmailSender:模拟发送邮件给申请人.....");
    System.out.println("申请人是:"+applicant);
    System.out.println("请假天数是:"+leaveDays);
    System.out.println("审批通过否:"+(approvalFlag?"通过":"不通过"));
    System.out.println("==============EmailSender执行结束================");
View Full Code Here

Examples of org.fireflow.engine.IProcessInstance

                try {
                  //IWorkflowSession是流程操作的入口,需要从runtimeContext获得。
                    IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
                   
                    //创建流程实例
                    IProcessInstance processInstance = workflowSession.createProcessInstance(
                            "LeaveApplicationProcess",CurrentUserAssignmentHandler.APPLICANT);
                   
                    //运行流程实例
                    processInstance.run();

                    return processInstance;
                } catch (EngineException ex) {
                    Logger.getLogger(LeaveApplicationTester.class.getName()).log(Level.SEVERE, null, ex);
                } catch (KernelException ex) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.