Mozart.BpmProcess (Mozart v0.3.6)

This module implements a BPM Domain Specific Language (DSL) framework. To use, insert use Mozart.BpmProcess into your modules.

defmodule Mozart.MyBpmApplication do
  use Mozart.BpmProcess

  # Your process model definitions
end

Summary

Functions

Used to specify one of many alternate execution paths. Arguments are a task name and a block of tasks.

Used to select one of many execution paths. Arguments are a task name and a list of cases.

Used to implement a business process event. Arguments are

Used to implement a business process model. Arguments are a name followed by one or more task functions.

Used to define parallel execution paths. Arguments are the task name and a list of routes.

Used to specify a task that has no behavior. Used for prototyping. Has a single name argument

Used to suspend an execution path until receiving a specified PubSub event. Arguemnts are a task name and captured function

Used to define one of many parallel execution paths within a parallel task. Arguments are a task name a block of tasks.

Used to set data properties based on evaluation of rules in a rule table. Arguments are a task name, a set of inputs and a rule table.

A task that send a PubSub event to a receiving receive_task. Arguments are a task name and a PubSub message.

Used to specify a task completed by calling an Elixir function. Arguments are a task name, a set of comma delitmited inputs a captured Elixir function.

Used to specify a task completed by spawning and completing a subprocess. Arguments are a task name and the name of the subprocess model.

Used to specify a timed delay in an execution path. Arguments are a task name and a duration in milliseconds.

Used to specify a task performed by a user belonging to a specified workgroup. Arguments are a task name and a set of comma delimited workgroups.

Functions

Link to this macro

case_i(expr, list)

(macro)

Used to specify one of many alternate execution paths. Arguments are a task name and a block of tasks.

defprocess "two case process" do
  case_task("yes or no", [
    case_i &ME.x_less_than_y/1 do
      user_task("1", groups: "admin")
      user_task("2", groups: "admin")
    end,
    case_i &ME.x_greater_or_equal_y/1 do
      user_task("3", groups: "admin")
      user_task("4", groups: "admin")
    end
  ])
end
Link to this macro

case_task(name, cases)

(macro)

Used to select one of many execution paths. Arguments are a task name and a list of cases.

defprocess "two case process" do
  case_task("yes or no", [
    case_i &ME.x_less_than_y/1 do
      user_task("1", groups: "admin")
      user_task("2", groups: "admin")
    end,
    case_i &ME.x_greater_or_equal_y/1 do
      user_task("3", groups: "admin")
      user_task("4", groups: "admin")
    end
  ])
end
Link to this macro

defevent(name, opts, list)

(macro)

Used to implement a business process event. Arguments are:

  • the name of the event
  • process: the name of the process that the event will act upon
  • exit_task: the name of the task to be exited
  • selector: a function that matches on the target event
  • do: one or more tasks to be executed when the target task is exited.
    defevent "exit loan decision 1",
    process: "exit a user task 1",
    exit_task: "user task 1",
    selector: &BpmAppWithEvent.event_selector/1 do
      prototype_task("event 1 prototype task 1")
      prototype_task("event 1 prototype task 2")
    end
Link to this macro

defprocess(name, list)

(macro)

Used to implement a business process model. Arguments are a name followed by one or more task functions.

defprocess "two timer task process" do
  timer_task("one second timer task", duration: 1000)
  timer_task("two second timer task", duration: 2000)
end
Link to this macro

parallel_task(name, routes)

(macro)

Used to define parallel execution paths. Arguments are the task name and a list of routes.

defprocess "two parallel routes process" do
  parallel_task("a parallel task", [
    route do
      user_task("1", groups: "admin")
      user_task("2", groups: "admin")
    end,
    route do
      user_task("3", groups: "admin")
      user_task("4", groups: "admin")
    end
  ])
end
Link to this macro

prototype_task(name)

(macro)

Used to specify a task that has no behavior. Used for prototyping. Has a single name argument

defprocess "two prototype task process" do
  prototype_task("prototype task 1")
  prototype_task("prototype task 2")
end
Link to this macro

receive_task(name, list)

(macro)

Used to suspend an execution path until receiving a specified PubSub event. Arguemnts are a task name and captured function

def receive_loan_income(msg) do
  case msg do
    {:barrower_income, income} -> %{barrower_income: income}
    _ -> nil
  end
end

defprocess "receive barrower income process" do
  receive_task("receive barrower income", selector: &MyBpmApplication.receive_loan_income/1)
end
Link to this macro

repeat_task(name, condition, list)

(macro)
Link to this macro

route(list)

(macro)

Used to define one of many parallel execution paths within a parallel task. Arguments are a task name a block of tasks.

defprocess "two parallel routes process" do
  parallel_task("a parallel task", [
    route do
      user_task("1", groups: "admin")
      user_task("2", groups: "admin")
    end,
    route do
      user_task("3", groups: "admin")
      user_task("4", groups: "admin")
    end
  ])
end
Link to this macro

rule_task(name, list)

(macro)

Used to set data properties based on evaluation of rules in a rule table. Arguments are a task name, a set of inputs and a rule table.

rule_table = """
F     income      || status
1     > 50000     || approved
2     <= 49999    || declined
"""

defprocess "single rule task process" do
  rule_task("loan decision", inputs: "income", rule_table: rule_table)
end
Link to this macro

send_task(name, list)

(macro)

A task that send a PubSub event to a receiving receive_task. Arguments are a task name and a PubSub message.

defprocess "send barrower income process" do
  send_task("send barrower income", message: {:barrower_income, 100_000})
end
Link to this macro

service_task(name, list)

(macro)

Used to specify a task completed by calling an Elixir function. Arguments are a task name, a set of comma delitmited inputs a captured Elixir function.

def square(data) do
  Map.put(data, :square, data.x * data.x)
end

defprocess "one service task process" do
  service_task("a service task", function: &MyBpmApplication.square/1, inputs: "x")
end
Link to this macro

subprocess_task(name, list)

(macro)

Used to specify a task completed by spawning and completing a subprocess. Arguments are a task name and the name of the subprocess model.

defprocess "subprocess task process" do
  subprocess_task("subprocess task", model: "two service tasks")
end
Link to this macro

timer_task(name, list)

(macro)

Used to specify a timed delay in an execution path. Arguments are a task name and a duration in milliseconds.

defprocess "two timer task process" do
  timer_task("one second timer task", duration: 1000)
  timer_task("two second timer task", duration: 2000)
end
Link to this macro

user_task(name, args)

(macro)

Used to specify a task performed by a user belonging to a specified workgroup. Arguments are a task name and a set of comma delimited workgroups.

defprocess "single user task process" do
  user_task("add one to x", groups: "admin,customer_service")
end