OFBiz workflow source code learning (3)-wfprocessmgr Interface

Source: Internet
Author: User
Wfprocessmgr Interface

The workflow manager (wfprocessmgr) represents a template for a specific process, which is used to create an instance of the workflow flow. Logically, it is the creation factory and positioner of a workflow. It provides metadata for external access, such as the environment required by the process and the results generated by the process.

Knowledge Point 1: wfprocessmgrAll attributes of are read-only. When wfprocessmgrWhen it is installed, its attributes are set and cannot be modified later. This is different from the attributes of other objects and interfaces.

The workflow manager name is represented by name. In a business domain, name uniquely identifies a workflow manager.

The category attribute is used to classify the workflow manager. It is set during workflow manager initialization and cannot be modified.

The version attribute indicates the version of the workflow manager.

The description attribute indicates the descriptive content of the workflow manager.

The sample code is as follows:

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: The workflow manager is used to generate and associate zero-to-multiple processes with them.

The code is described as follows:

Public int howmanyprocess () throws wfexception {

Return processlist. Size (); // number of processes

}

Public list getsequenceprocess (INT maxnumber) throws wfexception {

If (maxnumber> 0)

Return new arraylist (processlist. sublist (0, maxnumber-1 ));

Return processlist; // returns the list of processes in sequence mode.

}

Public iterator getiteratorprocess () throws wfexception {

Return processlist. iterator ();

}

Public Boolean ismemberofprocess (wfprocess member) throws wfexception {

Return processlist. Contains (member); // whether a process is included in the Process List

}

Knowledge 3: The workflow manager has two statuses: EnabledAnd disabled. EnabledIndicates that a new process can be generated in the current State; DisabledIndicates that a new process cannot be generated in the current status.

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 (); // there can be only two States

This. State = newstate;

}

Knowledge Point 4: When the workflow manager generates a process, it first generates a process instance, and then the process instance and requesterAssociation. The process instance status is not_running.not_started..

Public wfprocess CreateProcess (wfrequester requester) throws wfexception, notenabled,

Invalidrequester, requesterrequired {

If (State. Equals ("disabled "))

Throw new notenabled (); // the current state of the workflow manager does not allow the creation of new processes

 

If (requester = NULL)

Throw new requesterrequired (); // the requester must be specified.

 

// Test if the requestor is OK: How?

Wfprocess process = wffacloud. getwfprocess (processdef, this); // define the production process using the process

 

Try {

Process. setrequester (requester); // set requester

} Catch (cannotchangerequester CCR ){

Throw new wfexception (CCR. getmessage (), CCR );

}

Processlist. Add (process); // Add to the queue

Debug. logverbose ("[wfprocessmgr. CreateProcess]: process created.", module );

Return process;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.