Trace:
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
workflow:custom_function [2020/03/04 09:41] admin |
workflow:custom_function [2022/03/31 07:19] admin removed |
||
---|---|---|---|
Line 1: | Line 1: | ||
~~NOTRANS~~ | ~~NOTRANS~~ | ||
- | ~~Title: Custom function~~ | + | ~~Title: Custom Function~~ |
A function is the code block behind a task. It's very simple to create a new function because a function is defined as simple Java interface: | A function is the code block behind a task. It's very simple to create a new function because a function is defined as simple Java interface: | ||
Line 24: | Line 24: | ||
* Runs the function. | * Runs the function. | ||
* If the function returns <code>true</code>, the function is fully done, and the workflow jumps to the next step. | * If the function returns <code>true</code>, the function is fully done, and the workflow jumps to the next step. | ||
- | * In case there are more then one next steps, the finish function of IWorkflowStep has to be called. | + | * In case there are more than one next step, the finish function of IWorkflowStep has to be called. |
- | * An exception will be thrown otherwise. | + | * Otherwise, an exception will be thrown. |
* If finish is already called, it does not matter whether <code>true</code> or <code>false</code> is returned. | * If finish is already called, it does not matter whether <code>true</code> or <code>false</code> is returned. | ||
* | * | ||
Line 34: | Line 34: | ||
/** | /** | ||
- | * Notifies, that the workflow is cancelled. | + | * Notifies that the workflow is cancelled. |
* | * | ||
* @throws Throwable if canceling fails. | * @throws Throwable if canceling fails. | ||
Line 42: | Line 42: | ||
} | } | ||
</file> | </file> | ||
- | The interface already has an abstract implementation and so it's really super simple to create a new function. Our example will send an email, so it's the EmailFunction: | + | The interface already has an abstract implementation, so it's really simple to create a new function. Our example will send an email, so it's the EmailFunction: |
<file java EmailFunction.java> | <file java EmailFunction.java> | ||
Line 89: | Line 89: | ||
</file> | </file> | ||
- | The implementation is straight forward. It extends the AbstractFunction and implements run method. The email settings will be read from the [[jvx:common:setup:zones|application configuration]] and the email settings will be read from the input parameters. Finally, the email will be sent. | + | The implementation is straightforward. It extends the AbstractFunction and implements run method. The email settings will be read from the [[jvx:common:setup:zones|application configuration]], and the email settings will be read from the input parameters. Here's an example: |
- | But there's still one open question: How do we define the input parameters? | + | <file xml> |
+ | <application> | ||
+ | ... | ||
+ | <mail> | ||
+ | <smtp> | ||
+ | <host>smtp.yourserver.com</host> | ||
+ | <port>587</port> | ||
+ | <username>username</username> | ||
+ | <password>password</password> | ||
+ | <tlsenabled>true</tlsenabled> | ||
+ | <defaultsender>Noreply <noreply@yourserver.com></defaultsender> | ||
+ | </smtp> | ||
+ | </mail> | ||
+ | </application> | ||
+ | </file> | ||
+ | |||
+ | Finally, the email will be sent. | ||
+ | |||
+ | But there's still one open question: how do we define the input parameters? | ||
- | Simply use the Functions screen and enter all required information: | + | Simply use the functions screen and enter all required information: |
{{:workflow:wf_emailfunction.png?nolink|}} | {{:workflow:wf_emailfunction.png?nolink|}} | ||
- | That's it. Start using your new function. | + | That's it! Start using your new function. |