private void displayWorkflow ( Workflow w ) { Graph graph = new Graph ( w . getWorkflowName ( ) , Graph . DIGRAPH ) ; nodes . clear ( ) ; //Create the nodes w . getWorkflowStepList ( ) . forEach ( step -> { addStep ( step , graph ) ; //Now add the links step . getSourceTransitions ( ) . forEach ( t -> { addStep ( t . getWorkflowStepSource ( ) , graph ) ; addStep ( t . getWorkflowStepTarget ( ) , graph ) ; Subgraph . Edge edge = graph . addEdge ( nodes . get ( t . getWorkflowStepSource ( ) . getWorkflowStepPK ( ) . getId ( ) ) , nodes . get ( t . getWorkflowStepTarget ( ) . getWorkflowStepPK ( ) . getId ( ) ) ) ; edge . setParam ( "label" , TRANSLATOR . translate ( t . getTransitionName ( ) ) ) ; //Workaround https://github.com/pontusbostrom/VaadinGraphvizComponent/issues/9 edge . setDest ( nodes . get ( t . getWorkflowStepTarget ( ) . getWorkflowStepPK ( ) . getId ( ) ) ) ; edges . put ( TRANSLATOR . translate ( t . getTransitionName ( ) ) , new AbstractMap . SimpleEntry <> ( nodes . get ( t . getWorkflowStepSource ( ) . getWorkflowStepPK ( ) . getId ( ) ) , edge ) ) ; } ) ; } ) ; diagram . drawGraph ( graph ) ; }
Create workflow from database