Click here to Skip to main content
14,303,730 members

Simple Viewer and Semantic Parser for BPMN Diagrams

Rate this:
4.88 (17 votes)
Please Sign up or sign in to vote.
4.88 (17 votes)
30 Mar 2017CPOL
BPMN Model Interchange on Microsoft .NET platform. View BPMN diagrams from all major vendors.

Introduction

Business Process Model and Notation (BPMN) is a graphical representation for specifying business processes in a business process model [1]. A standard Business Process Model and Notation (BPMN) will provide businesses with the capability of understanding their internal business procedures in a graphical notation and will give organizations the ability to communicate these procedures in a standard manner. Furthermore, the graphical notation will facilitate the understanding of the performance collaborations and business transactions between the organizations. This will ensure that businesses will understand themselves and participants in their business and will enable organizations to adjust to new internal and B2B business circumstances quickly [2]. Version 2.0 of BPMN was released in January 2011, at which point execution semantics were also introduced alongside the notational and diagramming elements [3]. BPMN standard introduces also normative machine consumable files represented, in particular, as standard XML schemas [4], which facilitate support for the format among software vendors.

To facilitate and demonstrate BPMN Model Interchange amongst different tools OMG established BPMN Model Interchange Working Group (BPMN MIWG) to support BPMN vendors, define various test cases that address both breadth and depth of BPMN, ensure model Interchange taking into consideration the various defined conformance classes of the BPMN standard, resolve vendors’ misinterpretation of the specification that inhibit BPMN interchange, guide and support vendor into their implementations of the standard [5]. The list of BPMN tools tested for model Interchange includes many leading software vendors and is constantly expanding [6]. This list includes both proprietary and free open source tools. However, until recently, all free tools supporting BPMN were written in Java and JavaScript.

Image 1

In this paper, we present BPMN View, a new open source tool written for Microsoft .NET platform in C# and offering easy adaptation of BPMN standard among developers writing software for Microsoft Windows. Below, we explain generic architecture and provide highlights to the most notable parts of the code, which should simplify its borrowing and reuse in other projects.

BPMN View

BPMN View is a simple free tool to view and print business process diagrams in a popular BPMN format. It appeared as a result of our experience with BPMN accumulated during my participation in meetings of BPMN Model Interchange Working Group since its establishing in 2013. Some highlights of BPMN View include:

  • Full conformance to the latest version of BPMN 2.0 specification by OMG
  • Import models from all major BPM vendors
  • Strict validation of the model according to BPMN specification
  • Arbitrary scaling and zooming view of most complex diagrams
  • Support of raster and vector image output
  • Batch processing of multiple BPMN files
  • 100% Microsoft .NET managed solution
  • Loyal open source license for private and commercial use

Image 2

You can use BPMN View as a quick diagram viewer. It includes ready setup for Microsoft Windows. You can also use code fragments to implement your own BPMN parsing, viewing and publishing solution with minimum effort and avoid diving into low level caveats of BPMN format.

Semantics of BPMN Model

Every BPMN file contains BPMN model. Model includes one or more BPMN diagrams and description of process semantics with elements appearing on diagrams. Diagram consists of visual elements: shapes and edges with assigned positions and display parameters. Shapes and edges have text labels. Text for labels and further attributes of shapes and edges are contained in their related elements from process semantics. Full BPMN semantic model includes dozens of element types and subtypes. To simplify our work with format, we represent all model elements as a simple universal class Element:

public class Element
{
  public string ParentID;
  public string TypeName;
  public Dictionary<string, string> Attributes;
  public Dictionary<string, List<string>> Properties;
  public Dictionary<string, List<Element>> Elements;
}

Each element has its specific TypeName, which exactly corresponds to respective type name defined in BPMN specification. Element also includes collections or attributes, properties and nested elements, as defined in BPMN specification for given element type. ParentID is a reference to parent element holding given element (if any).

The whole BPMN model is loaded from file into a hierarchy of its elements and diagrams with Read() function:

public class Model
{
  public string ID;
  public string Name;
  public List<Diagram> Diagrams;
  public List<Element> Elements;
  public static Model Read(string file)
  public Image GetImage(int diagramIndex, float zoom)
}

Apart from process elements, model contains a collection of diagrams and their visual elements:

public class Label
{
  public string ID;
  public Font Font;
  public List<Rectangle> Bounds;
}

public class Edge
{
  public string ID;
  public string ElementRef;
  public string SourceElementRef;
  public string TargetElementRef;
  public string MessageVisibleKind;
  public List<Label> Labels;
  public List<Point> Points;
}

public class Shape
{
  public string ID;
  public string ElementRef;
  public bool IsExpanded;
  public bool IsHorizontal;
  public bool IsMarkerVisible;
  public bool IsMessageVisible;
  public string ParticipantBandKind;
  public string ChoreographyActivityShape;
  public List<Label> Labels;
  public List<Rectangle> Bounds;
}

public class Plane
{
  public string ID;
  public string ElementRef;
  public List<Shape> Shapes;
  public List<Edge> Edges;
}

public class Diagram
{
  public string ID;
  public string Name;
  public string Resolution;
  public List<Plane> Planes;
}

Visual elements refer to process elements in semantics through their ElementRef property. These types are available from BPMN.Sharp package available on NuGet [8].

This simple set of classes allows us to represent the whole BPMN model, including its visual structure and entire process semantics.

Rendering of BPMN Diagrams

Sample code to read BPMN file and save it as an image:

Model model = BPMN.Model.Read("B.2.0.bpmn");
Image img = model.GetImage(0, 2.0f);
img.Save("B.2.0.png", ImageFormat.Png);

The first parameter in this list is the index of diagram in loaded model. Second parameter is zoom factor.

Below is the result:

Image 3

Semantics of BPMN Process

We can build also a tabular view of BPMN process semantic.

Image 4

We use here standard gridview and assign to it dataset created from collection of all elements in the model.

private DataTable ElementsTable(IEnumerable<Element> elements, List<string> elementNames)
{
  DataTable table = new DataTable();
  if (elementNames != null)
    table.Columns.Add("ElementName", typeof(string));
  table.Columns.Add("Name", typeof(string));
  table.Columns.Add("TypeName", typeof(string));
  table.Columns.Add("ID", typeof(string));
  table.Columns.Add("ParentID", typeof(string));

  if (elements == null)
    return null;

  int i = 0;
  table.BeginLoadData();
  foreach (Element el in elements)
  {
    if (elementNames == null && el != null &&
      el.TypeName.Contains("BPMN")) continue;

    DataRow row = table.NewRow();
    if (elementNames != null)
      row["ElementName"] = elementNames[i++];
    if (el != null)
    {
      if (el.Attributes.ContainsKey("name"))
        row["Name"] = el.Attributes["name"];
      row["TypeName"] = el.TypeName;
      if (el.Attributes.ContainsKey("id"))
        row["ID"] = el.Attributes["id"];
      row["ParentID"] = el.ParentID;
    }
    table.Rows.Add(row);
  }
  table.EndLoadData();
  return table;
}

When user selects a row in the table, we find specific model element by its ID.

public Element ElementByID(string id)
{
  if (model != null && !string.IsNullOrEmpty(id))
  {
    foreach (Element element in model.Elements)
      if (element.Attributes.ContainsKey("id") &&
        id.Equals(element.Attributes["id"])) return element;
  }
  return null;
}

Then we show all nested elements, properties and attributes for selected element.

private void ViewElement(Element el)
{
  if (el == null) return;

  if (el.Elements != null)
  {
    List<Element> elm = new List<Element>();
    List<string> elmNames = new List<string>();
    foreach (var elt in el.Elements)
    {
      string name = elt.Key;
      if (elt.Value != null)
      {
        foreach (Element ell in elt.Value)
        {
          elmNames.Add(name);
          elm.Add(ell);
        }
      }
      else
      {
        elmNames.Add(name);
        elm.Add(null);
      }
    }
    gridSubElements.DataSource = ElementsTable(elm, elmNames);
  }

  if (el.Properties != null)
  {
    Dictionary<string, string> props = new Dictionary<string, string>();
    foreach (var prop in el.Properties)
    {
      string propList = "";
      foreach (string pr in prop.Value)
      {
        if (!string.IsNullOrEmpty(propList))
          propList += ", ";
        propList += pr;
      }
      props.Add(prop.Key, propList);
    }
    gridProperties.DataSource = StringTable(props);
  }

  gridAttributes.DataSource = StringTable(el.Attributes);
}

Disclaimer

The product names used in this document are for identification purposes only. All trademarks and registered trademarks are the property of their respective owners.

Acknowledgments

I would like to express my gratitude to all members of BPMN Model Interchange Working Group (BPMN MIWG) for support and inspiration.

References

[1] Business Process Model and Notation, Wikipedia
https://en.wikipedia.org/wiki/Business_Process_Model_and_Notation

[2] Business Process Model and Notation, Object Management Group
http://www.bpmn.org/

[3] Business Process Model and Notation (BPMN) Version 2.0 Normative Documents
http://www.omg.org/spec/BPMN/2.0/PDF

[4] Business Process Model and Notation (BPMN) Version 2.0 XML Schema
http://www.omg.org/spec/BPMN/2.0/

[5] BPMN Model Interchange Working Group (BPMN MIWG)
http://www.omgwiki.org/bpmn-miwg/doku.php

[6] BPMN Tools tested for Model Interchange
http://bpmn-miwg.github.io/bpmn-miwg-tools/

[7] BPMN View project on GitHub
https://github.com/bzinchenko/bpmnview

[8] BPMN Sharp package on NuGet
https://www.nuget.org/packages/BPMN.Sharp/

[9] BPMN View project on CodePlex
https://bpmn.codeplex.com/

[10] BPMN View project on SourceForge
https://sourceforge.net/projects/bpmnview/

History

  • November 13, 2016 - Initial release
  • March 30, 2017 - Major update
    • Support of multiple diagrams per file
    • Association with *.bpmn files in file system
    • Rendering of diagrams with absent label boundaries
    • Fixed: Dashes on edges are too short
    • Fixed: Message markers absent on relevant edges of message flows
    • Fixed: Improper order of multiple markers

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Boris Zinchenko
Chief Technology Officer CaseAgile LLC
United States United States
A proven experience in business process migration among all major platforms and environments. Reengineering, Analysis and Redocumentation with SAP® Solution Manager, Oracle® BPA Suite, Software AG (IDS Scheer) ARIS® Platform, Fujitsu Interstage BPM Suite (i-Flow), TIBCO® Business Studio, Casewise® Corporate Modeler Suite, IBM Rational Method Composer and WebSphere® Business Modeler, Metastorm® ProVision, Microsoft® SharePoint® and Visio®, UDDI Webservice Repositories, Sparx® Enterprise Architect, HP Universal CMDB with XML, XPDL, XMI, eEPC, BPMN, UML.

Comments and Discussions

 
QuestionMenifest Error Pin
ashish.akm29-Aug-17 17:14
memberashish.akm29-Aug-17 17:14 
AnswerRe: Menifest Error Pin
Boris Zinchenko29-Oct-17 2:17
memberBoris Zinchenko29-Oct-17 2:17 
QuestionBPMN.Sharp Not Exists Pin
Meysam Gharanfoli15-Jul-17 19:58
memberMeysam Gharanfoli15-Jul-17 19:58 
SuggestionRe: BPMN.Sharp Not Exists Pin
Sathish Balaiah24-Jul-17 4:07
memberSathish Balaiah24-Jul-17 4:07 
AnswerRe: BPMN.Sharp Not Exists Pin
Boris Zinchenko29-Oct-17 2:19
memberBoris Zinchenko29-Oct-17 2:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Article
Posted 13 Nov 2016

Tagged as

Stats

25.6K views
1.9K downloads
23 bookmarked