Package io.toro.martini
Class WorkflowMethods
- java.lang.Object
-
- io.toro.martini.WorkflowMethods
-
public final class WorkflowMethods extends Object
-
-
Constructor Summary
Constructors Constructor Description WorkflowMethods(Supplier<com.torocloud.workflow.WorkflowLoader> defaultWorkflowLoader, com.torocloud.workflow.InvocableChainFactory invocableChainFactory, com.torocloud.workflow.WorkflowEventManager workflowEventManager, MartiniPackageProvider packageProvider)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static GloopModel
invokeWorkflow(String workflowName)
Execute a Workflow service belonging to a certain package.static GloopModel
invokeWorkflow(String workflowName, GloopModel input)
Execute a Workflow service belonging to a certain package.static GloopModel
invokeWorkflow(String workflowName, Map<String,Object> input)
Execute a Workflow service belonging to a certain package.static com.torocloud.workflow.Workflow
resolve(String namespace)
Resolve the workflow object based on the providednamespace
.static com.torocloud.workflow.Workflow
resolve(String packageName, String namespace)
Resolve the workflow object from other packagepackageName
based on the providednamespace
.static List<com.torocloud.workflow.PostEventWorkflow>
sendEvent(com.torocloud.workflow.WorkflowEvent workflowEvent)
Send event to all running workflow.static com.torocloud.workflow.PostEventWorkflow
sendEvent(com.torocloud.workflow.WorkflowEvent workflowEvent, String contextId)
Sent event to a specific workflow by contextId
-
-
-
Constructor Detail
-
WorkflowMethods
public WorkflowMethods(Supplier<com.torocloud.workflow.WorkflowLoader> defaultWorkflowLoader, com.torocloud.workflow.InvocableChainFactory invocableChainFactory, com.torocloud.workflow.WorkflowEventManager workflowEventManager, MartiniPackageProvider packageProvider)
-
-
Method Detail
-
invokeWorkflow
public static GloopModel invokeWorkflow(@GloopParameter(allowNull=false) String workflowName, GloopModel input)
Execute a Workflow service belonging to a certain package.Example scenarios: - When the Workflow service has multiple input properties, you can put the expected properties in gloop model.
Example 1: Creating and passing a GloopModel directly GloopModel input = new GloopModel(); input.setProperty("message", "Hello"); input.setProperty("person", new GloopModel() .setProperty("firstname", "John") .setProperty("lastname", "Doe")); GloopModel result = WorkflowMethods.invokeWorkflow("WorkflowWithMultipleInputs", input); Example 2: - When the Workflow service has a single input property, you can pass the input directly GloopModel input = new GloopModel() input.setProperty("firstname", "John"); input.setProperty("lastname", "Doe"); GloopModel result = WorkflowMethods.invokeWorkflow("WorkflowWithSingleInput", input);
- Parameters:
workflowName
- The name of the Workflow file (with or without the file extension) to execute. If nested within a directory, parent directories must be prefixed while using . as a separator (e.g path.to.WorkflowService.input
- object containing the inputs for the Workflow service- Returns:
- the GloopModel of the Context
- See Also:
invokeWorkflow(String, GloopModel)
-
invokeWorkflow
public static GloopModel invokeWorkflow(@GloopParameter(allowNull=false) String workflowName, Map<String,Object> input)
Execute a Workflow service belonging to a certain package.Example scenarios: - When the Workflow service has multiple input properties, you can pass them as a map.
Example 1: Passing a map with multiple properties and declared like json style userInput = [ "message":"Hello", "person": [ "firstname":"John", "lastname":"Doe" ] ] - which is equivalent to GloopModel with two properties "message" and "person" GloopModel result = WorkflowMethods.invokeWorkflow("userWorkflow", userInput); Example 2: Passing the model directly to map GloopModel input = new GloopModel(); input.setProperty("message", "Hello"); input.setProperty("person", new GloopModel() .setProperty("firstname", "John") setProperty("lastname", "Doe")); userInput = [input:input] - which is equivalent to GloopModel with a single property "input" GloopModel result = WorkflowMethods.invokeWorkflow("customerWorkflow", userInput);
- Parameters:
workflowName
- The name of the Workflow file (with or without the file extension) to execute. If nested within a directory, parent directories must be prefixed while using . as a separator (e.g path.to.WorkflowService.input
- map containing the inputs for the Workflow service- Returns:
- the GloopModel of the Context
- See Also:
invokeWorkflow(String, Map)
-
invokeWorkflow
public static GloopModel invokeWorkflow(@GloopParameter(allowNull=false) String workflowName)
Execute a Workflow service belonging to a certain package.- Parameters:
workflowName
- The name of the Workflow file (with or without the file extension) to execute. If nested within a directory, parent directories must be prefixed while using . as a separator (e.g path.to.WorkflowService.- Returns:
- the GloopModel of the Context
- See Also:
invokeWorkflow(String)
-
sendEvent
public static List<com.torocloud.workflow.PostEventWorkflow> sendEvent(com.torocloud.workflow.WorkflowEvent workflowEvent)
Send event to all running workflow.- Parameters:
workflowEvent
- The name of the event to send.- Returns:
- the list of post event process result of each workflow
-
sendEvent
public static com.torocloud.workflow.PostEventWorkflow sendEvent(com.torocloud.workflow.WorkflowEvent workflowEvent, String contextId)
Sent event to a specific workflow by contextId- Parameters:
workflowEvent
- The name of the event to send.contextId
- The contextId of the workflow where the event will be sent.- Returns:
- the post event process result of the workflow
-
resolve
public static com.torocloud.workflow.Workflow resolve(@GloopParameter(allowNull=false) String namespace)
Resolve the workflow object based on the providednamespace
.- Parameters:
namespace
- the name of the workflow file- Returns:
- the workflow object
- Throws:
com.torocloud.workflow.exception.WorkflowNotFoundException
- the workflow not found
-
resolve
public static com.torocloud.workflow.Workflow resolve(@GloopParameter(allowNull=false) String packageName, @GloopParameter(allowNull=false) String namespace)
Resolve the workflow object from other packagepackageName
based on the providednamespace
.- Parameters:
namespace
- the name of the workflow filepackageName
- the name of the package- Returns:
- the workflow object
- Throws:
com.torocloud.workflow.exception.WorkflowNotFoundException
- the workflow not foundio.toro.martini.ipackage.exception.PackageNotFoundException
- the package not found
-
-