osworkflow / docs / 3.3 Common and Global Actions.html

        <title>OSWorkflow - 
         Common and Global Actions
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />

	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
	<li>Back to <a href="3.2 Workflow Concepts.html" title="3.2 Workflow Concepts">3.2 Workflow Concepts</a></li>
	<li>Forward to <a href="3.4 Functions.html" title="3.4 Functions">3.4 Functions</a></li>

<p>Two convenient features that can help reduce code duplication when defining workflow descriptors are common actions, and global actions.</p>

<p>The basic idea is simple. Both of these types of actions can be defined at the top of the workflow descriptor, after the initial-actions element.</p>

<p>Common actions are useful in cases where at various points of the workflow, a particular action needs to be available. For example, this could be a 'send email' action. The action would likely have some pre-functions, perhaps a validator, perhaps even an inline script. All in all it might be 7-8 lines of xml. Since this action is needed in multiple places, the code would have to be duplicated wherever it's needed. </p>

<p>Defining it as a common action avoids this need for duplication. The action would be defined once as a common action. Then any steps that need to have that action available would simply reference it like this:</p>

<div class="code"><div class="codeContent">
<pre class="code-java">&lt;common-action id=<span class="code-quote">"100"</span> /&gt;</pre>

<p>Global actions are slightly different. They are defined the same way (in a global-actions element after initial-actions), but instead of having to be explicitly referenced by a particular step, they are always available to ALL steps. An example of a global action for example could be 'terminate workflow', where at any stage, it is possible to end the workflow (for example, by setting its state to KILLED), and perhaps log it and send an email (defined as functions in the global action).</p>

<p>In both cases, all global and common actions should have unique ID's that do not clash with any other action ID's in the workflow descriptor.</p>

<p>Common and Global actions may not require a transition to another step.  In this case, the result of the action may specify the next step as 0 to signify that no transition is required, as with the following example.</p>

<pre class="code-java">&lt;unconditional-result old-status=<span class="code-quote">"Finished"</span> step=<span class="code-quote">"0"</span> 
                      status=<span class="code-quote">"Underway"</span> owner=<span class="code-quote">"${someOwner}"</span>/&gt;</pre>

Tip: Use camelCasing e.g. ProjME to search for