OFBIZ Workflow Code Learning (3) - WfProcessmgr Interface

zhaozj2021-02-17  60

WfProcessmgr interface

Workflow Manager (WfProcessmgr) represents a template for a specific process, which is used to create an instance of a workflow process. Logically, it is a workflow creation plant and locator that provides some meta-information to external access, such as the environment required for the process, the result of the process, and more.

Knowledge 1: All attributes of WfProcessmgr are read-only. When WFProcessMgr is installed, its properties are set, and will not be changed later; this is different from other objects and interface properties.

The name of the workflow manager is represented by Name, in a business domain, Name uniquely launches a workflow manager.

The category property is used to classify the workflow manager, which is set when the workflow manager is initialized and cannot be modified.

The Version property represents the version of the workflow manager.

The Description attribute represents the descriptive content of the Workflow Manager.

The code example is, for example:

Public string name () throws wfexception {

Return Processdef.getstring ("name");

}

Public string category () throws wfexception {

Return ProcessDef.getstring ("category");

}

PUBLIC STRING VERSION () THROWS WFEXCEPTION {

Return Processdef.getstring ("Version");

}

Public string description () throws wfexception {

Return ProcessDef.getstring ("description");

}

Knowledge point 2: Workflow manager is used to generate zero to multiple processes and associate with them.

The code description is as follows:

Public int howmanyprocess () throws wfexception {

Return ProcessList.size (); // Data

}

Public List getsequenceProcess (int maxNumber) throws wfexception {

IF (MAXNUMBER> 0)

Return New ArrayList (ProcessList.Sublist (0, MaxNumber - 1));

Return ProcessList; // Returns the list of Process in a SEQUENCE

}

Public iterator getiteratorprocess () throws wfexception {

Return processlist.iterator ();

}

Public Boolean ismemberofprocess (wfProcess Member) throws wfException {

Return ProcessList.Contains (Member); // Does a process in the process list

}

Knowledge 3: Workflow Manager has two states: enabled and disabled. Enabled indicates a new process in the current state; Disabled means that the current state cannot produce a new process.

Public List ProcessMgrstateType () throws wfexception {

String [] list = {"enabled", "disabled"}; // String array

Return arrays.aslist (list);

}

Public void setProcessMgrstate (String newState) throws wfexception, transitionNotallowed {if (! newstate.equals ("enabled") ||! newstate.equals ("disabled")))

Throw new transitionNotallowed (); // can only have two states

THIS.STATE = NewState;

}

Knowledge 4: When the workflow manager generates the process, the process instance is generated first, and then the process instance is associated with the Requester. The state of the process instance is NOT_RUNNING.NOT_STARTED.

Public WfProcess CreateProcess (WFrequester Requester) Throws WFEXCEPTION, NOTENABLED,

INVALIDREQUESTER, RequesterRequired {

IF (state.equals ("disabled"))

Throw new notenabled (); // Workflow Manager current state does not allow new processes

IF (Requester == Null)

Throw new requesterRequired (); // must specify Requester

// Test if The Requestor is OK: How?

WfProcess Process = WFFactory.GetWFProcess (ProcessDef, this); // Flow Direction Generation Process

Try {

Process.setRequester (Requester); // Setting Requester

} Catch (CannotChangerequester CCR) {

Throw new wfexception (ccr.getMessage (), CCR);

}

ProcessList.Add (Process); // Add to Queue

Debug.logverbose ("[wfprocessmgr.createprocess]: process created.", Module);

Return Process;

}

转载请注明原文地址:https://www.9cbs.com/read-28863.html

New Post(0)