Skip to content

crivano/jflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JFlow

JFlow is a simple open-source library for defining and running workflows in java. It is specifically designed to be easily included in other applications.

Main goals are:

  • To have zero dependencies
  • To be embeddable just by implementing interfaces
  • To have a simple user interface to edit workflow definitions
  • To have a easily readable codebase
  • To support persistence on different databases

Web Editor

JFlow

A workflow process definition is basically an array of task definitions, and it can be easily edited using a web application. An example of an web app that edits process definitions can be seen on this live demo (in Portuguese). It's source code is available at the front-end directory.

Example / Usage

A worflow can be defined like this:

// Create the process definition
ProcessDefinition pd = new ProcessDefinitionSupport();

// Create the task definition
TaskDefinition td = new TaskDefinitionSupport("1", "test", TaskKindSupport.FORM, "Form", null,
  ResponsibleKindSupport.REGISTRANT, null, null, null, null);
pd.getTaskDefinition().add(td);

// Create the process instance without responsible support
HashMap<String, Object> variable = new HashMap<String, Object>();
ProcessInstance pi = new ProcessInstanceSupport(pd, variable, null) {
  @Override
  public Responsible calcResponsible(TaskDefinition tarefa) {
    return null;
  }
};
   
// Create the engine without persistence or handling of any kind
Engine engine = new EngineImpl(null, null);

And can be run like this:

// Start the process instance
engine.start(pi, pd, variable);

// The form is the first and only task definition, engine should wait for an
// user event to continue
assertEquals(ProcessInstanceStatus.PAUSED, pi.getStatus());

// Resume after the user has filled the form
engine.resume(TaskForm.getEvent(td, pi), null, null);

// Workflow should be ended by now
assertEquals(ProcessInstanceStatus.FINISHED, pi.getStatus());

Graph

JFlow is also capable of generating a graph of the process instance in the GraphViz DOT language, you will need an GraphViz processor to convert it to a .SVG or .PNG:

String dot = GraphViz.getDot(pi, "Start", "Finish");

For the example above, the dot variable will contain something like this:

"start"[shape="oval"][color="black"][fontcolor="black"][label=<Start>];
"start"->"1";
"finish"[shape="oval"][color="black"][fontcolor="black"][label=<Finish>];
"1"[shape="rectangle"][color="blue"][fontcolor="blue"][label=<Form>];
"1"->"finish";

Enclose it between a Digraph G { and a }, submit to a GraphViz Engine and you will end up with a nice graph:

Graphviz_Online

Development

JFlow is very much in-development, and is in no way, shape, or form guaranteed to be stable or bug-free. Bugs, suggestions, or pull requests are all very welcome.

License

Copyright 2020 Renato Crivano

Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE, Version 3

http://www.gnu.org/licenses/agpl-3.0.html

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages