Skip to content

Commit 2ba0206

Browse files
committed
Fixed Colorizing BPMNs.
1 parent 071fe10 commit 2ba0206

File tree

9 files changed

+85
-50
lines changed

9 files changed

+85
-50
lines changed

03-api/src/main/scala/camundala/api/ApiConfig.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ case class ProjectsConfig(
126126
lazy val colors: Seq[(String, String)] = projectConfigs.map { project =>
127127
project.name -> project.color
128128
}
129+
130+
def colorForId(refName:String, ownProjectName: String): Option[(String, String)] =
131+
colors.find:
132+
case (id, _) => refName.startsWith(id) && ! refName.startsWith(ownProjectName)
129133

130134
def hasProjectGroup(
131135
projectName: String,

03-api/src/main/scala/camundala/api/ModelerTemplUpdater.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,14 @@ case class ModelerTemplUpdater(apiConfig: ApiConfig, apiProjectConfig: ApiProjec
9595
decisionRef.toString -> id
9696

9797
val xmlNew = (callActivities ++ businessRuleTasks ++ externalWorkers)
98-
.filter:
99-
case project -> _ =>
100-
colorMap.contains(project) && docProjectConfig.projectName != project
98+
.flatMap:
99+
case refName -> elemId =>
100+
apiConfig.projectsConfig
101+
.colorForId(refName, docProjectConfig.projectName)
102+
.map (_ -> elemId).toSeq
101103
.foldLeft(xml):
102-
case (xmlResult, project -> id) =>
103-
println(s" -> $project > $id -- ${colorMap(project)}")
104+
case (xmlResult, project -> color -> id) =>
105+
println(s" -> $project > $id -- $color")
104106
new RuleTransformer(changeColor(project, id)).apply(xmlResult)
105107
os.write.over(bpmnPath, xmlNew.toString)
106108
end extractUsesRefs
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package camundala.api
2+
3+
import munit.FunSuite
4+
5+
class ProjectsConfigTest extends FunSuite :
6+
7+
test("colorForId should return the correct color for a given refName and ownProjectName") :
8+
val projectConfig1 = ProjectConfig("project1", ProjectGroup("group1"), "#ff0000")
9+
val projectConfig2 = ProjectConfig("project2", ProjectGroup("group2"), "#00ff00")
10+
val projectsConfig = ProjectsConfig(perGitRepoConfigs = Seq(
11+
ProjectsPerGitRepoConfig("https://example.com", Seq(projectConfig1, projectConfig2))
12+
))
13+
14+
val result = projectsConfig.colorForId("project1-task", "project2")
15+
assertEquals(result, Some("project1" -> "#ff0000"))
16+
17+
test("colorForId should return None if no matching project is found") :
18+
val projectConfig1 = ProjectConfig("project1", ProjectGroup("group1"), "#ff0000")
19+
val projectsConfig = ProjectsConfig(perGitRepoConfigs = Seq(
20+
ProjectsPerGitRepoConfig("https://example.com", Seq(projectConfig1))
21+
))
22+
val result = projectsConfig.colorForId("unknown-task", "project1")
23+
assertEquals(result, None)
24+
25+
test("colorForId should return None if refName starts with ownProjectName") :
26+
val projectConfig1 = ProjectConfig("project1", ProjectGroup("group1"), "#ff0000")
27+
val projectsConfig = ProjectsConfig(perGitRepoConfigs = Seq(
28+
ProjectsPerGitRepoConfig("https://example.com", Seq(projectConfig1))
29+
))
30+
val result = projectsConfig.colorForId("project1-task", "project1")
31+
assertEquals(result, None)

05-examples/invoice/03-api/OpenApi.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ openapi: 3.1.0
22
info:
33
title: Invoice Example Process API
44
version: '1.0'
5-
summary: "\n\n\n\nCreated at 23.12.2024, 16:43\n\n**See the [Camundala Documentation](https://pme123.github.io/camundala/)**\n\
5+
summary: "\n\n\n\nCreated at 07.01.2025, 16:41\n\n**See the [Camundala Documentation](https://pme123.github.io/camundala/)**\n\
66
\n# Package Configuration\n**Check all dependency trees here: [example-invoice](../../dependencies/example-invoice.html)**\n\
77
\n### Dependencies:\n\n\n\n\n<details>\n<summary>PROJECT.conf</summary>\n<p>\n\
8-
\n```\n\norg = \"pme123\"\nname = \"example-invoice\"\nversion = \"0.1.0-SNAPSHOT\"\
9-
\ndependencies: {\n //\"example-helper\": \"pme123:example-helper:1.3.*\"\n}\n\
10-
\n```\n\n</p>\n</details>\n\n\nThere is no README.md in the Project.\n\n\n\n<p/>\n\
11-
<details>\n<summary>\n<b><i>General Variables</i></b>\n</summary>\n\n<p>\n\n###\
12-
\ Mocking\n\n**servicesMocked**:\n\nMock all the _ServiceWorkers_ in your process\
13-
\ with their default Mock:\n\n- DSL:\n```scala\nprocess(..)\n .mockServices\n\
14-
```\n\n- Json\n```json\n...\n\"servicesMocked\": true,\n...\n```\n\n\n**mockedWorkers**:\n\
15-
\nMock any Process- and/or ExternalTask-Worker with their default Mocks.\nThis\
16-
\ is a list of the _Worker topicNames or Process processNames_, you want to mock.\n\
17-
It is also possible to use a _comma separated_ String,\nlike `\"mySubProcess,myOtherSubProcess,myService\"\
8+
\n```\n\nprojectName = \"pme123-invoice\"\nprojectVersion = \"0.1.0-SNAPSHOT\"\
9+
\nsubProjects = []\ndependencies: []\n\n```\n\n</p>\n</details>\n\n\nThere is\
10+
\ no README.md in the Project.\n\n\n\n<p/>\n<details>\n<summary>\n<b><i>General\
11+
\ Variables</i></b>\n</summary>\n\n<p>\n\n### Mocking\n\n**servicesMocked**:\n\
12+
\nMock all the _ServiceWorkers_ in your process with their default Mock:\n\n-\
13+
\ DSL:\n```scala\nprocess(..)\n .mockServices\n```\n\n- Json\n```json\n...\n\"\
14+
servicesMocked\": true,\n...\n```\n\n\n**mockedWorkers**:\n\nMock any Process-\
15+
\ and/or ExternalTask-Worker with their default Mocks.\nThis is a list of the\
16+
\ _Worker topicNames or Process processNames_, you want to mock.\nIt is also possible\
17+
\ to use a _comma separated_ String,\nlike `\"mySubProcess,myOtherSubProcess,myService\"\
1818
`\n\n_Be aware_: For Sub-Processes, this expects an _InitWorker_ where the _topicName_\
1919
\ is equal to the _processName_.\n\n\n- DSL:\n```scala\nprocess(..)\n .mockedWorkers(\"\
2020
mySubProcess1\", \"mySubProcess2\") // creates a list with SubProcessess\n .mockedWorker(\"\
@@ -82,12 +82,12 @@ paths:
8282
\ Element**: `example-invoice-c7` (to define in the Call Activity)\n\n\n\n\
8383
---\n\n\n\n\n- Input: `camundala.examples.invoice.bpmn.InvoiceReceipt > In`\n\
8484
- Output: `camundala.examples.invoice.bpmn.InvoiceReceipt > Out`\n\n\n<div\
85-
\ class=\"diagramCanvas\">\n <div class=\"diagram\" id=\"example-invoice-c7-22238\"\
85+
\ class=\"diagramCanvas\">\n <div class=\"diagram\" id=\"example-invoice-c7-59013\"\
8686
>\n <img onLoad=\"openFromUrl('example-invoice-c7.bpmn', new BpmnJS({ container:\
87-
\ $('#example-invoice-c7-22238'), height: '95%', width: '95%' }));\" src=\"\
87+
\ $('#example-invoice-c7-59013'), height: '95%', width: '95%' }));\" src=\"\
8888
data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\"\
8989
\ />\n </div>\n</div>\n\nDownload: [example-invoice-c7.bpmn](diagrams/example-invoice-c7.bpmn)\n\
90-
\n\n<div>\n <button onclick=\"downloadSVG('example-invoice-c7-22238')\">Download\
90+
\n\n<div>\n <button onclick=\"downloadSVG('example-invoice-c7-59013')\">Download\
9191
\ Diagram as SVG</button>\n</div>\n\n<p/>\n\n<details>\n<summary>\n<b><i>General\
9292
\ Variable(s)</i></b>\n</summary>\n\n<p>\n\n**outputVariables**:\n\nJust take\
9393
\ the variable you need in your process!\n```json\n...\n\"outputVariables\"\
@@ -169,16 +169,16 @@ paths:
169169
- Output: `camundala.bpmn.CollectEntries`
170170
171171
<div class="diagramCanvas">
172-
<div class="diagram" id="example-invoice-c7-assignApprover-15868">
173-
<img onLoad="openFromUrl('example-invoice-c7-assignApprover.dmn', new DmnJS({ container: $('#example-invoice-c7-assignApprover-15868'), height: '95%', width: '95%' }));" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" />
172+
<div class="diagram" id="example-invoice-c7-assignApprover-43100">
173+
<img onLoad="openFromUrl('example-invoice-c7-assignApprover.dmn', new DmnJS({ container: $('#example-invoice-c7-assignApprover-43100'), height: '95%', width: '95%' }));" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" />
174174
</div>
175175
</div>
176176
177177
Download: [example-invoice-c7-assignApprover.dmn](diagrams/example-invoice-c7-assignApprover.dmn)
178178
179179
180180
<div>
181-
<button onclick="downloadSVG('example-invoice-c7-assignApprover-15868')">Download Diagram as SVG</button>
181+
<button onclick="downloadSVG('example-invoice-c7-assignApprover-43100')">Download Diagram as SVG</button>
182182
</div>
183183
operationId: 'Dmn: c7-assignApprover'
184184
requestBody:
@@ -329,12 +329,12 @@ paths:
329329
\ Element**: `example-invoice-c7-review` (to define in the Call Activity)\n\
330330
\n\n\n---\n\n\n\n\n- Input: `camundala.examples.invoice.bpmn.ReviewInvoice\
331331
\ > In`\n- Output: `camundala.examples.invoice.bpmn.ReviewInvoice > Out`\n\
332-
\n\n<div class=\"diagramCanvas\">\n <div class=\"diagram\" id=\"example-invoice-c7-review-83989\"\
332+
\n\n<div class=\"diagramCanvas\">\n <div class=\"diagram\" id=\"example-invoice-c7-review-90159\"\
333333
>\n <img onLoad=\"openFromUrl('example-invoice-c7-review.bpmn', new BpmnJS({\
334-
\ container: $('#example-invoice-c7-review-83989'), height: '95%', width:\
334+
\ container: $('#example-invoice-c7-review-90159'), height: '95%', width:\
335335
\ '95%' }));\" src=\"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\"\
336336
\ />\n </div>\n</div>\n\nDownload: [example-invoice-c7-review.bpmn](diagrams/example-invoice-c7-review.bpmn)\n\
337-
\n\n<div>\n <button onclick=\"downloadSVG('example-invoice-c7-review-83989')\"\
337+
\n\n<div>\n <button onclick=\"downloadSVG('example-invoice-c7-review-90159')\"\
338338
>Download Diagram as SVG</button>\n</div>\n\n<p/>\n\n<details>\n<summary>\n\
339339
<b><i>General Variable(s)</i></b>\n</summary>\n\n<p>\n\n**outputVariables**:\n\
340340
\nJust take the variable you need in your process!\n```json\n...\n\"outputVariables\"\
@@ -749,16 +749,16 @@ paths:
749749
- Output: `camundala.bpmn.CollectEntries`
750750
751751
<div class="diagramCanvas">
752-
<div class="diagram" id="example-invoice-c7-assignApprover-21366">
753-
<img onLoad="openFromUrl('example-invoice-c7-assignApprover.dmn', new DmnJS({ container: $('#example-invoice-c7-assignApprover-21366'), height: '95%', width: '95%' }));" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" />
752+
<div class="diagram" id="example-invoice-c7-assignApprover-60774">
753+
<img onLoad="openFromUrl('example-invoice-c7-assignApprover.dmn', new DmnJS({ container: $('#example-invoice-c7-assignApprover-60774'), height: '95%', width: '95%' }));" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" />
754754
</div>
755755
</div>
756756
757757
Download: [example-invoice-c7-assignApprover.dmn](diagrams/example-invoice-c7-assignApprover.dmn)
758758
759759
760760
<div>
761-
<button onclick="downloadSVG('example-invoice-c7-assignApprover-21366')">Download Diagram as SVG</button>
761+
<button onclick="downloadSVG('example-invoice-c7-assignApprover-60774')">Download Diagram as SVG</button>
762762
</div>
763763
operationId: 'Dmn: c7-assignApprover'
764764
requestBody:

05-examples/invoice/03-api/PostmanOpenApi.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ info:
33
title: Invoice Example Process API
44
version: '1.0'
55
summary: "\n |**This is for Postman - to have example requests. Be aware\
6-
\ the Output is not provided!**\n |\n |\n\n\n\nCreated at 23.12.2024,\
7-
\ 16:43\n\n**See the [Camundala Documentation](https://pme123.github.io/camundala/)**\n\
6+
\ the Output is not provided!**\n |\n |\n\n\n\nCreated at 07.01.2025,\
7+
\ 16:41\n\n**See the [Camundala Documentation](https://pme123.github.io/camundala/)**\n\
88
\n# Package Configuration\n**Check all dependency trees here: [example-invoice](../../dependencies/example-invoice.html)**\n\
99
\n### Dependencies:\n\n\n\n\n<details>\n<summary>PROJECT.conf</summary>\n<p>\n\
10-
\n```\n\norg = \"pme123\"\nname = \"example-invoice\"\nversion = \"0.1.0-SNAPSHOT\"\
11-
\ndependencies: {\n //\"example-helper\": \"pme123:example-helper:1.3.*\"\n}\n\
12-
\n```\n\n</p>\n</details>\n\n\nThere is no README.md in the Project.\n\n\n\n<p/>\n\
13-
<details>\n<summary>\n<b><i>General Variables</i></b>\n</summary>\n\n<p>\n\n###\
14-
\ Mocking\n\n**servicesMocked**:\n\nMock all the _ServiceWorkers_ in your process\
15-
\ with their default Mock:\n\n- DSL:\n```scala\nprocess(..)\n .mockServices\n\
16-
```\n\n- Json\n```json\n...\n\"servicesMocked\": true,\n...\n```\n\n\n**mockedWorkers**:\n\
17-
\nMock any Process- and/or ExternalTask-Worker with their default Mocks.\nThis\
18-
\ is a list of the _Worker topicNames or Process processNames_, you want to mock.\n\
19-
It is also possible to use a _comma separated_ String,\nlike `\"mySubProcess,myOtherSubProcess,myService\"\
10+
\n```\n\nprojectName = \"pme123-invoice\"\nprojectVersion = \"0.1.0-SNAPSHOT\"\
11+
\nsubProjects = []\ndependencies: []\n\n```\n\n</p>\n</details>\n\n\nThere is\
12+
\ no README.md in the Project.\n\n\n\n<p/>\n<details>\n<summary>\n<b><i>General\
13+
\ Variables</i></b>\n</summary>\n\n<p>\n\n### Mocking\n\n**servicesMocked**:\n\
14+
\nMock all the _ServiceWorkers_ in your process with their default Mock:\n\n-\
15+
\ DSL:\n```scala\nprocess(..)\n .mockServices\n```\n\n- Json\n```json\n...\n\"\
16+
servicesMocked\": true,\n...\n```\n\n\n**mockedWorkers**:\n\nMock any Process-\
17+
\ and/or ExternalTask-Worker with their default Mocks.\nThis is a list of the\
18+
\ _Worker topicNames or Process processNames_, you want to mock.\nIt is also possible\
19+
\ to use a _comma separated_ String,\nlike `\"mySubProcess,myOtherSubProcess,myService\"\
2020
`\n\n_Be aware_: For Sub-Processes, this expects an _InitWorker_ where the _topicName_\
2121
\ is equal to the _processName_.\n\n\n- DSL:\n```scala\nprocess(..)\n .mockedWorkers(\"\
2222
mySubProcess1\", \"mySubProcess2\") // creates a list with SubProcessess\n .mockedWorker(\"\

05-examples/invoice/PROJECT.conf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
org = "pme123"
2-
name = "example-invoice"
3-
version = "0.1.0-SNAPSHOT"
4-
dependencies: {
5-
//"example-helper": "pme123:example-helper:1.3.*"
6-
}
1+
projectName = "pme123-invoice"
2+
projectVersion = "0.1.0-SNAPSHOT"
3+
subProjects = []
4+
dependencies: []
75

86

97

helper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env -S scala shebang
22

33
//> using toolkit 0.5.0
4-
//> using dep io.github.pme123::camundala-helper:1.30.23
4+
//> using dep io.github.pme123::camundala-helper:1.30.29
55

66
import camundala.helper.*
77

project/Dependencies.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object Dependencies {
1212
val openapiCirceVersion = "0.11.5"
1313
val tapirVersion = "1.11.11"
1414
val ironCirceVersion = "2.6.0"
15-
val mUnitVersion = "1.0.3"
15+
val mUnitVersion = "1.0.4"
1616
// 02-bpmn
1717
// -> domain
1818
// - osLib
@@ -53,7 +53,7 @@ object Dependencies {
5353
// 04-c8-spring
5454
// -> bpmn
5555
val scalaJacksonVersion = "2.18.2"
56-
val camunda8Version = "8.5.15"
56+
val camunda8Version = "8.5.16"
5757
val springBootVersion = "3.3.4"
5858
val swaggerOpenAPIVersion = "2.1.24"
5959
// examples

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.4")
1+
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.11.0")
22

33
// https://github.com/djspiewak/sbt-github-actions
44
//addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0")

0 commit comments

Comments
 (0)