Package org.fireflow.model

Examples of org.fireflow.model.WorkflowProcess


    /* (non-Javadoc)
     * @see org.fireflow.engine.IProcessInstance#getWorkflowProcess()
     */
    public WorkflowProcess getWorkflowProcess() throws EngineException {
        WorkflowDefinition workflowDef = rtCtx.getDefinitionService().getWorkflowDefinitionByProcessIdAndVersionNumber(this.getProcessId(), this.getVersion());
        WorkflowProcess workflowProcess = null;

        workflowProcess = workflowDef.getWorkflowProcess();

        return workflowProcess;
    }
View Full Code Here


     * 触发process instance相关的事件
     * @param e
     * @throws org.fireflow.engine.EngineException
     */
    protected void fireProcessInstanceEvent(ProcessInstanceEvent e) throws EngineException {
        WorkflowProcess workflowProcess = this.getWorkflowProcess();
        if (workflowProcess == null) {
            return;
        }

        List<EventListener> listeners = workflowProcess.getEventListeners();
        for (int i = 0; i < listeners.size(); i++) {
            EventListener listener = listeners.get(i);
            Object obj = rtCtx.getBeanByName(listener.getClassName());
            if (obj != null) {
                ((IProcessInstanceEventListener) obj).onProcessInstanceEventFired(e);
View Full Code Here

                    taskInstance.getActivity(),
                    "DefaultToolTaskInstanceRunner:TaskInstance的任务类型错误,只能为TOOL类型");
        }
        Task task = taskInstance.getTask();
        if (task == null) {
            WorkflowProcess process = taskInstance.getWorkflowProcess();
            throw new EngineException(taskInstance.getProcessInstanceId(), process,
                    taskInstance.getTaskId(),
                    "The Task is null,can NOT start the taskinstance,");
        }
        if (((ToolTask) task).getApplication() == null || ((ToolTask) task).getApplication().getHandler() == null) {
            WorkflowProcess process = taskInstance.getWorkflowProcess();
            throw new EngineException(taskInstance.getProcessInstanceId(), process,
                    taskInstance.getTaskId(),
                    "The task.getApplication() is null or task.getApplication().getHandler() is null,can NOT start the taskinstance,");
        }

        Object obj = runtimeContext.getBeanByName(((ToolTask) task).getApplication().getHandler());

        if (obj==null || !(obj instanceof IApplicationHandler)){
            WorkflowProcess process = taskInstance.getWorkflowProcess();
            throw new EngineException(taskInstance.getProcessInstanceId(), process,
                    taskInstance.getTaskId(),
                    "Run tool task instance error! Not found the instance of "+((ToolTask) task).getApplication().getHandler()+" or the instance not implements IApplicationHandler");
           
        }
View Full Code Here

      final String parentTaskInstanceId) throws EngineException,
      KernelException {
    final String wfprocessId = workflowProcessId;
   
    final WorkflowDefinition workflowDef = runtimeContext.getDefinitionService().getTheLatestVersionOfWorkflowDefinition(wfprocessId);
    final WorkflowProcess wfProcess = workflowDef.getWorkflowProcess();

    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
View Full Code Here

                        workflowProcessFileNames.get(i).trim());
                if (inStream == null) {
                    throw new IOException("没有找到名称为" + workflowProcessFileNames.get(i) + "的流程定义文件");
                }
               
                WorkflowProcess workflowProcess = parser.parse(inStream);

                WorkflowDefinition workflowDef = new WorkflowDefinition();
                workflowDef.setVersion(new Integer(1));

                workflowDef.setWorkflowProcess(workflowProcess);

                String latestVersionKey = workflowProcess.getId() + "_V_" + workflowDef.getVersion();
                workflowDefinitionMap.put(latestVersionKey, workflowDef);
                latestVersionKeyMap.put(workflowProcess.getId(), latestVersionKey);

            }
        }

    }
View Full Code Here

        Task task = taskInstance.getTask();
        SubWorkflowProcess Subflow = ((SubflowTask) task).getSubWorkflowProcess();

        WorkflowDefinition subWorkflowDef = runtimeContext.getDefinitionService().getTheLatestVersionOfWorkflowDefinition(Subflow.getWorkflowProcessId());
        if (subWorkflowDef == null) {
            WorkflowProcess parentWorkflowProcess = taskInstance.getWorkflowProcess();
            throw new EngineException(taskInstance.getProcessInstanceId(), parentWorkflowProcess,
                    taskInstance.getTaskId(),
                    "系统中没有Id为" + Subflow.getWorkflowProcessId() + "的流程定义");
        }
        WorkflowProcess subWorkflowProcess = subWorkflowDef.getWorkflowProcess();

        if (subWorkflowProcess == null) {
            WorkflowProcess parentWorkflowProcess = taskInstance.getWorkflowProcess();
            throw new EngineException(taskInstance.getProcessInstanceId(), parentWorkflowProcess,
                    taskInstance.getTaskId(),
                    "系统中没有Id为" + Subflow.getWorkflowProcessId() + "的流程定义");
        }
       
View Full Code Here

     * @return
     * @throws KernelException
     */
    public INetInstance createNetInstance(WorkflowDefinition workflowDef) throws KernelException {
        if (workflowDef==null)return null;
        WorkflowProcess workflowProcess = null;
        workflowProcess = workflowDef.getWorkflowProcess();//解析fpdl

        if (workflowProcess == null ){
          throw new KernelException(null,null,"The WorkflowProcess property of WorkflowDefinition[processId="+workflowDef.getProcessId()+"] is null. ");
        }
        String validateMsg =  workflowProcess.validate();//校验工作流定义是否有效
        if (validateMsg != null){
          throw new KernelException(null,null,validateMsg);
        }
        NetInstance netInstance = new NetInstance(workflowProcess, kernelExtensions);

View Full Code Here

                    return new InputSource(bytels);
                }
            });
            Document document = reader.read(in);

            WorkflowProcess wp = parse(document);//解析
            return wp;
        } catch (DocumentException e) {
            e.printStackTrace();
            throw new FPDLParserException("Error parsing document.", e);
        } finally {
View Full Code Here

     */
    @SuppressWarnings("static-access")
  protected WorkflowProcess parse(Document document) throws FPDLParserException {
        Element workflowProcessElement = document.getRootElement();
//流程ID
        WorkflowProcess wp = new WorkflowProcess(workflowProcessElement.attributeValue(NAME));
        wp.setSn(UUID.randomUUID().toString());//使用UUID作为流程实例ID
        //流程整体描述
        wp.setDescription(Util4Parser.elementAsString(workflowProcessElement,
                DESCRIPTION));
        //流程Task creator
        wp.setTaskInstanceCreator(workflowProcessElement.attributeValue(TASK_INSTANCE_CREATOR));

        wp.setFormTaskInstanceRunner(workflowProcessElement.attributeValue(FORM_TASK_INSTANCE_RUNNER));
        wp.setToolTaskInstanceRunner(workflowProcessElement.attributeValue(TOOL_TASK_INSTANCE_RUNNER));
        wp.setSubflowTaskInstanceRunner(workflowProcessElement.attributeValue(SUBFLOW_TASK_INSTANCE_RUNNER));

        wp.setFormTaskInstanceCompletionEvaluator(workflowProcessElement.attributeValue(FORM_TASK_INSTANCE_COMPLETION_EVALUATOR));
        wp.setToolTaskInstanceCompletionEvaluator(workflowProcessElement.attributeValue(TOOL_TASK_INSTANCE_COMPLETION_EVALUATOR));
        wp.setSubflowTaskInstanceCompletionEvaluator(workflowProcessElement.attributeValue(SUBFLOW_TASK_INSTANCE_COMPLETION_EVALUATOR));
//流程显示名称
        wp.setDisplayName(workflowProcessElement.attributeValue(DISPLAY_NAME));
        //下面两个属性,暂时还未使用
        wp.setResourceFile(workflowProcessElement.attributeValue(RESOURCE_FILE));
        wp.setResourceManager(workflowProcessElement.attributeValue(RESOURCE_MANAGER));

        //解析datafields
        this.loadDataFields(wp, wp.getDataFields(), Util4Parser.child(
                workflowProcessElement, this.DATA_FIELDS));
        //开始节点
        loadStartNode(wp, Util4Parser.child(workflowProcessElement, START_NODE));
//整体流程对应的task ,这个属性好像暂时未启用
        loadTasks(wp, wp.getTasks(),Util4Parser.child(
                    workflowProcessElement, TASKS) );
//所有业务节点,同时将这个节点的所有的属性都解析出来保存到节点信息中。
        loadActivities(wp, wp.getActivities(), Util4Parser.child(
                workflowProcessElement, ACTIVITIES));
        //工作流同步器节点
        loadSynchronizers(wp, wp.getSynchronizers(), Util4Parser.child(
                workflowProcessElement, SYNCHRONIZERS));
        //结束节点
        loadEndNodes(wp, wp.getEndNodes(), Util4Parser.child(
                workflowProcessElement, END_NODES));
        //转移线
        loadTransitions(wp, Util4Parser.child(workflowProcessElement,
                TRANSITIONS));
//循环线
        loadLoops(wp,Util4Parser.child(workflowProcessElement, LOOPS));
//所有的监听器
        loadEventListeners(wp.getEventListeners(), Util4Parser.child(workflowProcessElement, EVENT_LISTENERS));
//加载扩展属性
        Map<String, String> extAttrs = wp.getExtendedAttributes();
        loadExtendedAttributes(extAttrs, Util4Parser.child(
                workflowProcessElement, EXTENDED_ATTRIBUTES));

        return wp;

View Full Code Here

     */
    protected WorkflowProcess parse(Document document) throws FPDLParserException {

        Element workflowProcessElement = document.getDocumentElement();

        WorkflowProcess wp = new WorkflowProcess(workflowProcessElement.getAttribute(NAME));
        wp.setSn(UUID.randomUUID().toString());
        wp.setDescription(Util4JAXPParser.elementAsString(workflowProcessElement,
                DESCRIPTION));
        wp.setDisplayName(workflowProcessElement.getAttribute(DISPLAY_NAME));
        wp.setResourceFile(workflowProcessElement.getAttribute(RESOURCE_FILE));
        wp.setResourceManager(workflowProcessElement.getAttribute(RESOURCE_MANAGER));

        wp.setTaskInstanceCreator(workflowProcessElement.getAttribute(TASK_INSTANCE_CREATOR));

        wp.setFormTaskInstanceRunner(workflowProcessElement.getAttribute(FORM_TASK_INSTANCE_RUNNER));

        wp.setToolTaskInstanceRunner(workflowProcessElement.getAttribute(TOOL_TASK_INSTANCE_RUNNER));

        wp.setSubflowTaskInstanceRunner(workflowProcessElement.getAttribute(SUBFLOW_TASK_INSTANCE_RUNNER));

        wp.setFormTaskInstanceCompletionEvaluator(workflowProcessElement.getAttribute(FORM_TASK_INSTANCE_COMPLETION_EVALUATOR));

        wp.setToolTaskInstanceCompletionEvaluator(workflowProcessElement.getAttribute(TOOL_TASK_INSTANCE_COMPLETION_EVALUATOR));
        wp.setSubflowTaskInstanceCompletionEvaluator(workflowProcessElement.getAttribute(SUBFLOW_TASK_INSTANCE_COMPLETION_EVALUATOR));


        this.loadDataFields(wp, wp.getDataFields(), Util4JAXPParser.child(
                workflowProcessElement, DATA_FIELDS));

        this.loadTasks(wp, wp.getTasks(), Util4JAXPParser.child(
                workflowProcessElement, TASKS));

        loadStartNode(wp, Util4JAXPParser.child(workflowProcessElement, START_NODE));
        loadActivities(wp, wp.getActivities(), Util4JAXPParser.child(
                workflowProcessElement, ACTIVITIES));
        loadSynchronizers(wp, wp.getSynchronizers(), Util4JAXPParser.child(
                workflowProcessElement, SYNCHRONIZERS));
        loadEndNodes(wp, wp.getEndNodes(), Util4JAXPParser.child(
                workflowProcessElement, END_NODES));
        loadTransitions(wp, Util4JAXPParser.child(workflowProcessElement,
                TRANSITIONS));
        loadLoops(wp, Util4JAXPParser.child(workflowProcessElement,
                LOOPS));
        loadEventListeners(wp.getEventListeners(), Util4JAXPParser.child(workflowProcessElement, EVENT_LISTENERS));

        Map<String, String> extAttrs = wp.getExtendedAttributes();
        loadExtendedAttributes(extAttrs, Util4JAXPParser.child(
                workflowProcessElement, EXTENDED_ATTRIBUTES));

        return wp;

View Full Code Here

TOP

Related Classes of org.fireflow.model.WorkflowProcess

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.