Business Process Graph Visualizer
Sometimes, it is convenient to visualize the composite flow (step relation) in a simple format. In this case, use the following approach:
- Gather data from a completed Business Process (BP) run using the SQL script.
- Visualize the data using GraphWiz.
SQL script
You can fetch data for a graph using the following script executed against the MySQL database.
note
The script works for completed BPs only. Replace the rootRun variable to proper a GUID. Open the run in the browser and get the GUID from the URL that looks as follows: /workfusion/secure/business-process/edit/5cbb26f0-05db-4ae8-9606-d33f21eec1e7.
set @rootRun = '3977c2d1-41b5-42a8-8eda-3bef2c5a6806';
SELECT "digraph finite_state_machine {" COLLATE utf8mb4_unicode_ci
UNION
SELECT 'size="32,20"' COLLATE utf8mb4_unicode_ci
UNION
SELECT CONCAT('node [shape = doublecircle]; \"', @rootRun, '\";') COLLATE utf8mb4_unicode_ci
UNION
SELECT "node [shape=box];" COLLATE utf8mb4_unicode_ci
UNION
SELECT CONCAT("\"", r.uuid, "\" [color=", IF(r.status in ('DELETED', 'DELETING'), 'red', 'green'),
", label=\"", r.title,"(",r.executingType,",",r.status,":",r.competedSubmissions, "/",r.submissionSize,")\n",
r.startDate, "-", COALESCE(r.endDate, NOW()), "(", TIMESTAMPDIFF(SECOND, r.startDate, COALESCE(r.endDate, NOW())),"s)\n",
"source: ", COALESCE(mc.source_id, 'no source'), ",threads:", COALESCE(mcs.threadCount, 'no source'), "\n",
"avg execution: ", (select 1 + avg(wal.spendTime) from WorkerActivityLog wal where wal.runUUID = r.uuid), "s\n",
"max execution: ", (select 1 + max(wal.spendTime) from WorkerActivityLog wal where wal.runUUID = r.uuid), "s\n",
"total effort: ", (select sum(1 + wal.spendTime) from WorkerActivityLog wal where wal.runUUID = r.uuid), "s\n",
"results size (MB): ", (select sum(length(ahq.jsonAnswers)) / 1024 / 1024 from AwsHitQuestion ahq where ahq.run_id = r.id), "\n",
"max hit life: ", (select max(TIMESTAMPDIFF(SECOND, creationTime, COALESCE(completionDate, NOW()))) from AwsHit where run_id = r.id),"s\n",
"avg hit life: ", (select avg(TIMESTAMPDIFF(SECOND, creationTime, COALESCE(completionDate, NOW()))) from AwsHit where run_id = r.id),"s\n[",r.uuid,"]\"];")
FROM Run r
LEFT JOIN CampaignMap cm ON cm.id = r.campaignMap_id
left join Campaign c on c.id = cm.campaign
left join MACHINE_CONFIG mc on mc.id = c.machineConfigId
left join MachineCampaignSource mcs on mcs.id = mc.source_id
WHERE r.rootRunUUID = @rootRun COLLATE utf8mb4_unicode_ci
UNION
SELECT CONCAT(
CONCAT("\"", r.uuid,"\"",' -> ', "\"", replace(substring(substring_index(r.childrenRunUUID, ',', 1), length(substring_index(r.childrenRunUUID, ',', 1 - 1)) + 1), ',', ''), "\"", '[color = black];'),
if (replace(substring(substring_index(r.childrenRunUUID, ',', 2), length(substring_index(r.childrenRunUUID, ',', 2 - 1)) + 1), ',', '') = '', '',
CONCAT("\"", r.uuid,"\"",' -> ', "\"", replace(substring(substring_index(r.childrenRunUUID, ',', 2), length(substring_index(r.childrenRunUUID, ',', 2 - 1)) + 1), ',', ''), "\"", ' [color = black];')),
if (replace(substring(substring_index(r.childrenRunUUID, ',', 3), length(substring_index(r.childrenRunUUID, ',', 3 - 1)) + 1), ',', '') = '', '',
CONCAT("\"", r.uuid,"\"",' -> ', "\"", replace(substring(substring_index(r.childrenRunUUID, ',', 3), length(substring_index(r.childrenRunUUID, ',', 3 - 1)) + 1), ',', ''), "\"", ' [color = black];')),
if (replace(substring(substring_index(r.childrenRunUUID, ',', 4), length(substring_index(r.childrenRunUUID, ',', 4 - 1)) + 1), ',', '') = '', '',
CONCAT("\"", r.uuid,"\"",' -> ', "\"", replace(substring(substring_index(r.childrenRunUUID, ',', 4), length(substring_index(r.childrenRunUUID, ',', 4 - 1)) + 1), ',', ''), "\"", ' [color = black];')),
if (replace(substring(substring_index(r.childrenRunUUID, ',', 5), length(substring_index(r.childrenRunUUID, ',', 5 - 1)) + 1), ',', '') = '', '',
CONCAT("\"", r.uuid,"\"",' -> ', "\"", replace(substring(substring_index(r.childrenRunUUID, ',', 5), length(substring_index(r.childrenRunUUID, ',', 5 - 1)) + 1), ',', ''), "\"", ' [color = black];')),
if (replace(substring(substring_index(r.childrenRunUUID, ',', 6), length(substring_index(r.childrenRunUUID, ',', 6 - 1)) + 1), ',', '') = '', '',
CONCAT("\"", r.uuid,"\"",' -> ', "\"", replace(substring(substring_index(r.childrenRunUUID, ',', 6), length(substring_index(r.childrenRunUUID, ',', 6 - 1)) + 1), ',', ''), "\"", ' [color = black];')),
if (replace(substring(substring_index(r.childrenRunUUID, ',', 7), length(substring_index(r.childrenRunUUID, ',', 7 - 1)) + 1), ',', '') = '', '',
CONCAT("\"", r.uuid,"\"",' -> ', "\"", replace(substring(substring_index(r.childrenRunUUID, ',', 7), length(substring_index(r.childrenRunUUID, ',', 7 - 1)) + 1), ',', ''), "\"", ' [color = black];')),
if (replace(substring(substring_index(r.childrenRunUUID, ',', 8), length(substring_index(r.childrenRunUUID, ',', 8 - 1)) + 1), ',', '') = '', '',
CONCAT("\"", r.uuid,"\"",' -> ', "\"", replace(substring(substring_index(r.childrenRunUUID, ',', 8), length(substring_index(r.childrenRunUUID, ',', 8 - 1)) + 1), ',', ''), "\"", ' [color = black];')),
if (replace(substring(substring_index(r.childrenRunUUID, ',', 9), length(substring_index(r.childrenRunUUID, ',', 9 - 1)) + 1), ',', '') = '', '',
CONCAT("\"", r.uuid,"\"",' -> ', "\"", replace(substring(substring_index(r.childrenRunUUID, ',', 9), length(substring_index(r.childrenRunUUID, ',', 9 - 1)) + 1), ',', ''), "\"", ' [color = black];'))
)
FROM Run r
WHERE r.childrenRunUUID IS NOT NULL
AND r.rootRunUUID = @rootRun COLLATE utf8mb4_unicode_ci
UNION
SELECT "}" COLLATE utf8mb4_unicode_ci;
Get the output of the SQL execution and save it.
Example output
digraph finite_state_machine {
size="32,20"
node [shape = doublecircle]; "1beb8be0-5de4-4cc3-8d2b-a75c6ae3bcb5";
node [shape=box];
"1beb8be0-5de4-4cc3-8d2b-a75c6ae3bcb5" [color=green, label="Settings(MACHINE,COMPLETED:1/1)
2018-02-28 15:23:16-2018-02-28 15:23:17(1s)
source: no source,threads:no source
avg execution: 1.0000s
max execution: 1s
total effort: 1s
results size (MB): 0.00138950
max hit life: 0s
avg hit life: 0.0000s
[1beb8be0-5de4-4cc3-8d2b-a75c6ae3bcb5]"];
"bc211314-b279-4ea5-902a-988c3b9d9077" [color=green, label="Export BP Run details(MACHINE,COMPLETED:1/1)
2018-02-28 15:23:16-2018-02-28 15:23:19(3s)
source: no source,threads:no source
avg execution: 1.0000s
max execution: 1s
total effort: 1s
results size (MB): 0.00173855
max hit life: 1s
avg hit life: 1.0000s
[bc211314-b279-4ea5-902a-988c3b9d9077]"];
"e16aad7c-3c81-46c9-b9cd-331e79de14d3" [color=green, label="Test Datastore(MACHINE,COMPLETED:1/1)
2018-02-28 15:23:17-2018-02-28 15:23:19(2s)
source: no source,threads:no source
avg execution: 1.0000s
max execution: 1s
total effort: 1s
results size (MB): 0.00196934
max hit life: 0s
avg hit life: 0.0000s
[e16aad7c-3c81-46c9-b9cd-331e79de14d3]"];
"2d44b37b-cdfe-45c1-9635-cdeb76367cff" [color=green, label="Test S3 (MACHINE,COMPLETED:1/1)
2018-02-28 15:23:17-2018-02-28 15:23:21(4s)
source: no source,threads:no source
avg execution: 3.0000s
max execution: 3s
total effort: 3s
results size (MB): 0.00282097
max hit life: 3s
avg hit life: 3.0000s
[2d44b37b-cdfe-45c1-9635-cdeb76367cff]"];
"d775a9ae-6584-43ca-8dd9-0e8e33b47c27" [color=green, label="Test Secure Storage(MACHINE,COMPLETED:1/1)
2018-02-28 15:23:20-2018-02-28 15:23:23(3s)
source: no source,threads:no source
avg execution: 1.0000s
max execution: 1s
total effort: 1s
results size (MB): 0.00305653
max hit life: 1s
avg hit life: 1.0000s
[d775a9ae-6584-43ca-8dd9-0e8e33b47c27]"];
"30db177f-e34e-4faa-bcca-b9d437f7aac5" [color=green, label="Test GhostScript(MACHINE,COMPLETED:1/1)
2018-02-28 15:23:21-2018-02-28 15:23:27(6s)
source: no source,threads:no source
avg execution: 5.0000s
max execution: 5s
total effort: 5s
results size (MB): 0.00361252
max hit life: 5s
avg hit life: 5.0000s
[30db177f-e34e-4faa-bcca-b9d437f7aac5]"];
"bab0b6e6-bfd1-4f1b-a670-fcf2857c0ea6" [color=green, label="Test OCR(MACHINE,COMPLETED:1/1)
2018-02-28 15:23:26-2018-02-28 15:23:47(21s)
source: no source,threads:no source
avg execution: 20.0000s
max execution: 20s
total effort: 20s
results size (MB): 0.00621605
max hit life: 20s
avg hit life: 20.0000s
[bab0b6e6-bfd1-4f1b-a670-fcf2857c0ea6]"];
"490c2a30-5c97-4c32-92de-a2f7bdb9080c" [color=green, label="Empty(MACHINE,COMPLETED:1/1)
2018-02-28 15:23:46-2018-02-28 15:23:47(1s)
source: no source,threads:no source
avg execution: 1.0000s
max execution: 1s
total effort: 1s
results size (MB): 0.00621605
max hit life: 0s
avg hit life: 0.0000s
[490c2a30-5c97-4c32-92de-a2f7bdb9080c]"];
"d8b58007-9392-4cc3-a014-afcdbdfb2bd2" [color=green, label="Export Result Data(MACHINE,COMPLETED:1/1)
2018-02-28 15:23:46-2018-02-28 15:23:47(1s)
source: no source,threads:no source
avg execution: 1.0000s
max execution: 1s
total effort: 1s
results size (MB): 0.00218964
max hit life: 1s
avg hit life: 1.0000s
[d8b58007-9392-4cc3-a014-afcdbdfb2bd2]"];
"6ebf92c3-ea35-419a-8ad9-689ab472ab62" [color=green, label="Final Results(MACHINE,COMPLETED:1/1)
2018-02-28 15:23:47-2018-02-28 15:23:47(0s)
source: no source,threads:no source
avg execution: 1.0000s
max execution: 1s
total effort: 1s
results size (MB): 0.00218964
max hit life: 0s
avg hit life: 0.0000s
[6ebf92c3-ea35-419a-8ad9-689ab472ab62]"];
"1beb8be0-5de4-4cc3-8d2b-a75c6ae3bcb5" -> "bc211314-b279-4ea5-902a-988c3b9d9077"[color = black];
"bc211314-b279-4ea5-902a-988c3b9d9077" -> "e16aad7c-3c81-46c9-b9cd-331e79de14d3"[color = black];
"e16aad7c-3c81-46c9-b9cd-331e79de14d3" -> "2d44b37b-cdfe-45c1-9635-cdeb76367cff"[color = black];
"2d44b37b-cdfe-45c1-9635-cdeb76367cff" -> "d775a9ae-6584-43ca-8dd9-0e8e33b47c27"[color = black];
"d775a9ae-6584-43ca-8dd9-0e8e33b47c27" -> "30db177f-e34e-4faa-bcca-b9d437f7aac5"[color = black];
"30db177f-e34e-4faa-bcca-b9d437f7aac5" -> "bab0b6e6-bfd1-4f1b-a670-fcf2857c0ea6"[color = black];
"bab0b6e6-bfd1-4f1b-a670-fcf2857c0ea6" -> "490c2a30-5c97-4c32-92de-a2f7bdb9080c"[color = black];
"490c2a30-5c97-4c32-92de-a2f7bdb9080c" -> "d8b58007-9392-4cc3-a014-afcdbdfb2bd2"[color = black];
"d8b58007-9392-4cc3-a014-afcdbdfb2bd2" -> "6ebf92c3-ea35-419a-8ad9-689ab472ab62"[color = black];
}
Definition script example:
set @bpDefinitionId = 90;
set @statsStartDate = '2018-09-24 00:00:00';
SELECT "digraph finite_state_machine {"
UNION
SELECT 'size="32,20"'
UNION
-- SELECT CONCAT('node \[shape = doublecircle\]; \\"', @rootRun,
'\\";')
-- UNION
SELECT "node \[shape=box\];"
UNION
SELECT CONCAT('"', [cm.id](http://cm.id), '" \[color=green, label="',
c.title, '\\n',
'records: ', (select count(\*)
from AwsHit ah
join Run r on [r.id](http://r.id) = ah.run_id
where r.campaignMap_id = [cm.id](http://cm.id) and ah.creationTime \>
@statsStartDate), '\\n',
'max execution: ', COALESCE((select 1 + max(wal.spendTime)
from WorkerActivityLog wal
join Run r on [r.id](http://r.id) = wal.run_id
where r.campaignMap_id = [cm.id](http://cm.id) and wal.CREATION_DATE \>
@statsStartDate), 'IDLE'),'\\n',
'avg execution: ', COALESCE((select 1 + avg(wal.spendTime)
from WorkerActivityLog wal
join Run r on [r.id](http://r.id) = wal.run_id
where r.campaignMap_id = [cm.id](http://cm.id) and wal.CREATION_DATE \>
@statsStartDate), 'IDLE'),'\\n',
'avg hit life: ', COALESCE((select avg(TIMESTAMPDIFF(SECOND,
creationTime, COALESCE(completionDate, NOW())))
from AwsHit ah
join Run r on [r.id](http://r.id) = ah.run_id
where r.campaignMap_id = [cm.id](http://cm.id) and ah.creationTime \>
@statsStartDate), 'IDLE'),'\\n',
'bot config: ', COALESCE([mc.id](http://mc.id), 'MANUAL'), '; bot
source: ', COALESCE([mcs.id](http://mcs.id), 'NONE'), '; threads : ',
COALESCE(mcs.threadCount, 'NONE'), '\\n',
'"\];')
from CampaignMap cm
join Campaign c on [c.id](http://c.id) = cm.campaign
left join MACHINE_CONFIG mc on [mc.id](http://mc.id) =
c.machineConfigId
left join MachineCampaignSource mcs on [mcs.id](http://mcs.id) =
mc.source_id
where cm.deleted = 0 and cm.parent = @bpDefinitionId
UNION
SELECT
CONCAT("\\"", [cm.id](http://cm.id),"\\"",' -> ', "\\"",
[target.id](http://target.id), "\\"", '\[color = black\];')
from CampaignMap cm
join Campaign c on [c.id](http://c.id) = cm.campaign
join CompositeStepLink outLink on outLink.fromStep =
[cm.id](http://cm.id)
join CampaignMap target on [target.id](http://target.id) =
outLink.toStep
join Campaign p on [p.id](http://p.id) = cm.parent
where cm.deleted = 0 and cm.parent = @bpDefinitionId
UNION
SELECT "}";
GvEdit visualization tool
There is a desktop program that draws a graph using provided info. To download it, follow the link.
Install it, run GvEdit, and open the file you saved in the previous step.
tip
You can save the graph via the Graph/Settings menu in GvEdit.