⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workflowclient.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            Debug.logVerbose("Starting activity.", module);            if (!activityRunning(assign.activity())) {                start(assign.activity().runtimeKey());            } else {                            Debug.logWarning("Activity already running; not starting.", module);            }        } else {            Debug.logVerbose("Not starting assignment.", module);        }                  }    /**     * Start the activity.     * @param workEffortId The WorkEffort entity ID for the activitiy.     * @return GenericResultWaiter of the start job.     * @throws WfException     */    public void start(String workEffortId) throws WfException {        if (dispatcher == null) {            throw new WfException("LocalDispatcher is null; cannot create job for activity startup");              }                WfActivity activity = WfFactory.getWfActivity(delegator, workEffortId);        if (Debug.verboseOn()) Debug.logVerbose("Starting activity: " + activity.name(), module);        if (activityRunning(activity))            throw new WfException("Activity is already running");                    Job job = new StartActivityJob(activity);        if (Debug.verboseOn()) Debug.logVerbose("Job: " + job, module);        try {            dispatcher.getJobManager().runJob(job);        } catch (JobManagerException e) {            throw new WfException(e.getMessage(), e);        }                   }    /**     * Complete an activity assignment and follow the next transition(s).     * @param workEffortId The WorkEffort entity ID for the activity.     * @param partyId The assigned / to be assigned users party ID.     * @param roleTypeId The assigned / to be assigned role type ID.     * @param fromDate The assignment's from date.     * @return GenericResultWaiter for the complete job.     * @throws WfException     */    public void complete(String workEffortId, String partyId, String roleTypeId, Timestamp fromDate, Map result) throws WfException {                            WfAssignment assign = WfFactory.getWfAssignment(delegator, workEffortId, partyId, roleTypeId, fromDate);        if (result != null && result.size() > 0)            assign.setResult(result);        assign.complete();            }        /**     * Suspend an activity     * @param workEffortId The WorkEffort entity key for the activity object     * @throws WfException     */    public void suspend(String workEffortId) throws WfException {        WfActivity activity = WfFactory.getWfActivity(delegator, workEffortId);                if (Debug.verboseOn()) Debug.logVerbose("Suspending activity: " + activity.name(), module);        if (!activityRunning(activity))            throw new WfException("Activity is not running");                    activity.suspend();    }                   /**     * Resume an activity     * @param workEffortId The WorkEffort entity key for the activity object     * @throws WfException     */    public void resume(String workEffortId) throws WfException {        WfActivity activity = WfFactory.getWfActivity(delegator, workEffortId);        if (Debug.verboseOn()) Debug.logVerbose("Resuming activity: " + activity.name(), module);        if (activityRunning(activity))            throw new WfException("Activity is already running");        activity.resume();    }        /**     * Abort a process     * @param workEffortId The workeffort entity key for the process to abort     * @throws WfException     */    public void abortProcess(String workEffortId) throws WfException {        WfProcess process = WfFactory.getWfProcess(delegator, workEffortId);                process.abort();    }                    /**     * Append data to the execution object's process context.     * @param workEffortId The WorkEffort entity key for the execution object.     * @param append The data to append.     * @throws WfException     */    public void appendContext(String workEffortId, Map append) throws WfException {        WfExecutionObject obj = getExecutionObject(workEffortId);        if (obj != null) {            Map oCtx = obj.processContext();            oCtx.putAll(append);            obj.setProcessContext(oCtx);            if (Debug.verboseOn()) Debug.logVerbose("ProcessContext (" + workEffortId + ") => " + obj.processContext(), module);        }    }    /**     * Returns the process context of the execution object.     * @param workEffortId The WorkEffort entity key for the execution object.     * @throws WfException     */    public Map getContext(String workEffortId) throws WfException {        WfExecutionObject obj = getExecutionObject(workEffortId);        if (obj == null) throw new WfException("Invalid Execution Object (null value)");        if (Debug.verboseOn()) Debug.logVerbose("ProcessContext (" + workEffortId + ") => " + obj.processContext(), module);        return obj.processContext();    }    /**     * Gets the state of the execution object defined by the work effort key.     * @param workEffortId The WorkEffort entity key for the execution object.     * @throws WfException     */    public String getState(String workEffortId) throws WfException {        WfExecutionObject obj = getExecutionObject(workEffortId);        if (obj == null) throw new WfException("Invalid Execution Object (null value)");        if (Debug.verboseOn()) Debug.logVerbose("Current State (" + workEffortId + ") => " + obj.state(), module);        return obj.state();    }    /**     * Set the state of the execution object defined by the work effort key.     * @param workEffortId The WorkEffort entity key for the execution object.     * @param state The new state of the execution object.     * @return Current state of the execution object as a string.     * @throws WfException If state change is not allowed.     */    public void setState(String workEffortId, String state) throws WfException {        WfExecutionObject obj = getExecutionObject(workEffortId);        if (obj == null) throw new WfException("Invalid Execution Object (null value)");        obj.changeState(state);        if (Debug.verboseOn()) Debug.logVerbose("Current State (" + workEffortId + ") => " + obj.state(), module);    }    /**     * Gets the priority of the execution object defined by the work effort key.     * @param workEffortId The WorkEffort entity key for the execution object.     * @return Priority of the execution object as a long.     * @throws WfException     */    public long getPriority(String workEffortId) throws WfException {        WfExecutionObject obj = getExecutionObject(workEffortId);        if (obj == null) throw new WfException("Invalid Execution Object (null value)");        if (Debug.verboseOn()) Debug.logVerbose("Current Priority (" + workEffortId + ") => " + obj.priority(), module);        return obj.priority();    }    /**     * Set the priority of the execution object defined by the work effort key.     * @param workEffortId The WorkEffort entity key for the execution object.     * @param priority The new priority of the execution object.     * @throws WfException If state change is not allowed.     */    public void setPriority(String workEffortId, long priority) throws WfException {        WfExecutionObject obj = getExecutionObject(workEffortId);        if (obj == null) throw new WfException("Invalid Execution Object (null value)");        obj.setPriority(priority);        if (Debug.verboseOn()) Debug.logVerbose("Current Priority (" + workEffortId + ") => " + obj.priority(), module);    }    // Get the execution object for the workeffort    private WfExecutionObject getExecutionObject(String workEffortId) {        WfExecutionObject obj = null;        try {            obj = (WfExecutionObject) WfFactory.getWfActivity(delegator, workEffortId);        } catch (WfException e) {// ingore        }        if (obj == null) {            try {                obj = (WfExecutionObject) WfFactory.getWfProcess(delegator, workEffortId);            } catch (WfException e) {// ignore            }        }        return obj;    }    // Test an activity for running state.    private boolean activityRunning(String workEffortId) throws WfException {        return activityRunning(WfFactory.getWfActivity(delegator, workEffortId));    }    // Test an activity for running state.    private boolean activityRunning(WfActivity activity) throws WfException {        if (activity.state().equals("open.running"))            return true;        return false;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -