An attempt to write a workflow engine that supports a natural language for workflow definition.
- scalaflow-core
- scalaflow-grapher
- scalaflow-atompub
The core components for defining a ScalaFlow. Also includes the WorkflowInstance classes for using a ScalaFlow as seen below.
object CustomerCoffeeWorkflow extends ScalaFlow("Customer Coffee") {
state('start) {
event('Place_Order) -> 'Order_Placed
}
state('Order_Placed) {
event('Pay) -> 'Paid
event('Update_Order) -> 'Order_Updated
}
state('Order_Updated) {
event('Update_Accepted) -> 'Order_Placed
event('Update_Rejected) -> 'Order_Placed
}
state('Paid) {
event('Pickup) -> 'Drink_Received
}
state('Drink_Received) {
event('leave) -> 'Drink
}
endstate('Drink)
}
scala> val wi = WorkflowInstance definedAs CustomerCoffeeWorkflow
wi: org.doxla.scalaflow.engine.WorkflowInstance = WorkflowInstance currently in start
scala> wi !?
res11: List[Symbol] = List('Place_Order)
scala> wi ! 'Place_Order
res12: Boolean = true
scala> wi
res13: org.doxla.scalaflow.engine.WorkflowInstance = WorkflowInstance currently in Order_Placed
scala> wi !?
res14: List[Symbol] = List('Pay, 'Update_Order)
scala> wi ! 'Pay
res15: Boolean = true
scala> wi !?
res16: List[Symbol] = List('Pickup)
scala> wi
res17: org.doxla.scalaflow.engine.WorkflowInstance = WorkflowInstance currently in Paid
A very basic extension of Google's guice-grapher module. To generate for cool visual representations of ScalaFlows. Use Graphviz viewer to view the generated files.
Example code from here
val renderer = new ScalaFlowGraphvizRenderer()
val printWriter = new PrintWriter(new File("testoutput.dot"), "UTF-8")
renderer.setOut(printWriter)
renderer.setRankdir("TB")
new ScalaFlowGrapher(renderer).of(CustomerCoffeeWorkflow).graph
I started playing with some ideas for generating atompub XML documents. Still very much work in progress.