Source

osworkflow / docs / 3.3 Common and Global Actions.html

<html>
    <head>
        <title>OSWorkflow - 
         Common and Global Actions
        </title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <ul>
	<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>
</ul>


<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>
</div></div>

<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>

<div class="code"><div class="codeContent">
<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>
</div></div>

                    			    </td>
		    </tr>
	    </table>
    </body>
</html>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.