Skip to content

Commit

Permalink
Fixed Colorizing BPMNs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pme123 committed Jan 7, 2025
1 parent 071fe10 commit 2ba0206
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 50 deletions.
4 changes: 4 additions & 0 deletions 03-api/src/main/scala/camundala/api/ApiConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ case class ProjectsConfig(
lazy val colors: Seq[(String, String)] = projectConfigs.map { project =>
project.name -> project.color
}

def colorForId(refName:String, ownProjectName: String): Option[(String, String)] =
colors.find:
case (id, _) => refName.startsWith(id) && ! refName.startsWith(ownProjectName)

def hasProjectGroup(
projectName: String,
Expand Down
12 changes: 7 additions & 5 deletions 03-api/src/main/scala/camundala/api/ModelerTemplUpdater.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ case class ModelerTemplUpdater(apiConfig: ApiConfig, apiProjectConfig: ApiProjec
decisionRef.toString -> id

val xmlNew = (callActivities ++ businessRuleTasks ++ externalWorkers)
.filter:
case project -> _ =>
colorMap.contains(project) && docProjectConfig.projectName != project
.flatMap:
case refName -> elemId =>
apiConfig.projectsConfig
.colorForId(refName, docProjectConfig.projectName)
.map (_ -> elemId).toSeq
.foldLeft(xml):
case (xmlResult, project -> id) =>
println(s" -> $project > $id -- ${colorMap(project)}")
case (xmlResult, project -> color -> id) =>
println(s" -> $project > $id -- $color")
new RuleTransformer(changeColor(project, id)).apply(xmlResult)
os.write.over(bpmnPath, xmlNew.toString)
end extractUsesRefs
Expand Down
31 changes: 31 additions & 0 deletions 03-api/src/test/scala/camundala/api/ProjectsConfigTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package camundala.api

import munit.FunSuite

class ProjectsConfigTest extends FunSuite :

test("colorForId should return the correct color for a given refName and ownProjectName") :
val projectConfig1 = ProjectConfig("project1", ProjectGroup("group1"), "#ff0000")
val projectConfig2 = ProjectConfig("project2", ProjectGroup("group2"), "#00ff00")
val projectsConfig = ProjectsConfig(perGitRepoConfigs = Seq(
ProjectsPerGitRepoConfig("https://example.com", Seq(projectConfig1, projectConfig2))
))

val result = projectsConfig.colorForId("project1-task", "project2")
assertEquals(result, Some("project1" -> "#ff0000"))

test("colorForId should return None if no matching project is found") :
val projectConfig1 = ProjectConfig("project1", ProjectGroup("group1"), "#ff0000")
val projectsConfig = ProjectsConfig(perGitRepoConfigs = Seq(
ProjectsPerGitRepoConfig("https://example.com", Seq(projectConfig1))
))
val result = projectsConfig.colorForId("unknown-task", "project1")
assertEquals(result, None)

test("colorForId should return None if refName starts with ownProjectName") :
val projectConfig1 = ProjectConfig("project1", ProjectGroup("group1"), "#ff0000")
val projectsConfig = ProjectsConfig(perGitRepoConfigs = Seq(
ProjectsPerGitRepoConfig("https://example.com", Seq(projectConfig1))
))
val result = projectsConfig.colorForId("project1-task", "project1")
assertEquals(result, None)
46 changes: 23 additions & 23 deletions 05-examples/invoice/03-api/OpenApi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ openapi: 3.1.0
info:
title: Invoice Example Process API
version: '1.0'
summary: "\n\n\n\nCreated at 23.12.2024, 16:43\n\n**See the [Camundala Documentation](https://pme123.github.io/camundala/)**\n\
summary: "\n\n\n\nCreated at 07.01.2025, 16:41\n\n**See the [Camundala Documentation](https://pme123.github.io/camundala/)**\n\
\n# Package Configuration\n**Check all dependency trees here: [example-invoice](../../dependencies/example-invoice.html)**\n\
\n### Dependencies:\n\n\n\n\n<details>\n<summary>PROJECT.conf</summary>\n<p>\n\
\n```\n\norg = \"pme123\"\nname = \"example-invoice\"\nversion = \"0.1.0-SNAPSHOT\"\
\ndependencies: {\n //\"example-helper\": \"pme123:example-helper:1.3.*\"\n}\n\
\n```\n\n</p>\n</details>\n\n\nThere is no README.md in the Project.\n\n\n\n<p/>\n\
<details>\n<summary>\n<b><i>General Variables</i></b>\n</summary>\n\n<p>\n\n###\
\ Mocking\n\n**servicesMocked**:\n\nMock all the _ServiceWorkers_ in your process\
\ with their default Mock:\n\n- DSL:\n```scala\nprocess(..)\n .mockServices\n\
```\n\n- Json\n```json\n...\n\"servicesMocked\": true,\n...\n```\n\n\n**mockedWorkers**:\n\
\nMock any Process- and/or ExternalTask-Worker with their default Mocks.\nThis\
\ is a list of the _Worker topicNames or Process processNames_, you want to mock.\n\
It is also possible to use a _comma separated_ String,\nlike `\"mySubProcess,myOtherSubProcess,myService\"\
\n```\n\nprojectName = \"pme123-invoice\"\nprojectVersion = \"0.1.0-SNAPSHOT\"\
\nsubProjects = []\ndependencies: []\n\n```\n\n</p>\n</details>\n\n\nThere is\
\ no README.md in the Project.\n\n\n\n<p/>\n<details>\n<summary>\n<b><i>General\
\ Variables</i></b>\n</summary>\n\n<p>\n\n### Mocking\n\n**servicesMocked**:\n\
\nMock all the _ServiceWorkers_ in your process with their default Mock:\n\n-\
\ DSL:\n```scala\nprocess(..)\n .mockServices\n```\n\n- Json\n```json\n...\n\"\
servicesMocked\": true,\n...\n```\n\n\n**mockedWorkers**:\n\nMock any Process-\
\ and/or ExternalTask-Worker with their default Mocks.\nThis is a list of the\
\ _Worker topicNames or Process processNames_, you want to mock.\nIt is also possible\
\ to use a _comma separated_ String,\nlike `\"mySubProcess,myOtherSubProcess,myService\"\
`\n\n_Be aware_: For Sub-Processes, this expects an _InitWorker_ where the _topicName_\
\ is equal to the _processName_.\n\n\n- DSL:\n```scala\nprocess(..)\n .mockedWorkers(\"\
mySubProcess1\", \"mySubProcess2\") // creates a list with SubProcessess\n .mockedWorker(\"\
Expand Down Expand Up @@ -82,12 +82,12 @@ paths:
\ Element**: `example-invoice-c7` (to define in the Call Activity)\n\n\n\n\
---\n\n\n\n\n- Input: `camundala.examples.invoice.bpmn.InvoiceReceipt > In`\n\
- Output: `camundala.examples.invoice.bpmn.InvoiceReceipt > Out`\n\n\n<div\
\ class=\"diagramCanvas\">\n <div class=\"diagram\" id=\"example-invoice-c7-22238\"\
\ class=\"diagramCanvas\">\n <div class=\"diagram\" id=\"example-invoice-c7-59013\"\
>\n <img onLoad=\"openFromUrl('example-invoice-c7.bpmn', new BpmnJS({ container:\
\ $('#example-invoice-c7-22238'), height: '95%', width: '95%' }));\" src=\"\
\ $('#example-invoice-c7-59013'), height: '95%', width: '95%' }));\" src=\"\
data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\"\
\ />\n </div>\n</div>\n\nDownload: [example-invoice-c7.bpmn](diagrams/example-invoice-c7.bpmn)\n\
\n\n<div>\n <button onclick=\"downloadSVG('example-invoice-c7-22238')\">Download\
\n\n<div>\n <button onclick=\"downloadSVG('example-invoice-c7-59013')\">Download\
\ Diagram as SVG</button>\n</div>\n\n<p/>\n\n<details>\n<summary>\n<b><i>General\
\ Variable(s)</i></b>\n</summary>\n\n<p>\n\n**outputVariables**:\n\nJust take\
\ the variable you need in your process!\n```json\n...\n\"outputVariables\"\
Expand Down Expand Up @@ -169,16 +169,16 @@ paths:
- Output: `camundala.bpmn.CollectEntries`
<div class="diagramCanvas">
<div class="diagram" id="example-invoice-c7-assignApprover-15868">
<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==" />
<div class="diagram" id="example-invoice-c7-assignApprover-43100">
<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==" />
</div>
</div>
Download: [example-invoice-c7-assignApprover.dmn](diagrams/example-invoice-c7-assignApprover.dmn)
<div>
<button onclick="downloadSVG('example-invoice-c7-assignApprover-15868')">Download Diagram as SVG</button>
<button onclick="downloadSVG('example-invoice-c7-assignApprover-43100')">Download Diagram as SVG</button>
</div>
operationId: 'Dmn: c7-assignApprover'
requestBody:
Expand Down Expand Up @@ -329,12 +329,12 @@ paths:
\ Element**: `example-invoice-c7-review` (to define in the Call Activity)\n\
\n\n\n---\n\n\n\n\n- Input: `camundala.examples.invoice.bpmn.ReviewInvoice\
\ > In`\n- Output: `camundala.examples.invoice.bpmn.ReviewInvoice > Out`\n\
\n\n<div class=\"diagramCanvas\">\n <div class=\"diagram\" id=\"example-invoice-c7-review-83989\"\
\n\n<div class=\"diagramCanvas\">\n <div class=\"diagram\" id=\"example-invoice-c7-review-90159\"\
>\n <img onLoad=\"openFromUrl('example-invoice-c7-review.bpmn', new BpmnJS({\
\ container: $('#example-invoice-c7-review-83989'), height: '95%', width:\
\ container: $('#example-invoice-c7-review-90159'), height: '95%', width:\
\ '95%' }));\" src=\"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\"\
\ />\n </div>\n</div>\n\nDownload: [example-invoice-c7-review.bpmn](diagrams/example-invoice-c7-review.bpmn)\n\
\n\n<div>\n <button onclick=\"downloadSVG('example-invoice-c7-review-83989')\"\
\n\n<div>\n <button onclick=\"downloadSVG('example-invoice-c7-review-90159')\"\
>Download Diagram as SVG</button>\n</div>\n\n<p/>\n\n<details>\n<summary>\n\
<b><i>General Variable(s)</i></b>\n</summary>\n\n<p>\n\n**outputVariables**:\n\
\nJust take the variable you need in your process!\n```json\n...\n\"outputVariables\"\
Expand Down Expand Up @@ -749,16 +749,16 @@ paths:
- Output: `camundala.bpmn.CollectEntries`
<div class="diagramCanvas">
<div class="diagram" id="example-invoice-c7-assignApprover-21366">
<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==" />
<div class="diagram" id="example-invoice-c7-assignApprover-60774">
<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==" />
</div>
</div>
Download: [example-invoice-c7-assignApprover.dmn](diagrams/example-invoice-c7-assignApprover.dmn)
<div>
<button onclick="downloadSVG('example-invoice-c7-assignApprover-21366')">Download Diagram as SVG</button>
<button onclick="downloadSVG('example-invoice-c7-assignApprover-60774')">Download Diagram as SVG</button>
</div>
operationId: 'Dmn: c7-assignApprover'
requestBody:
Expand Down
24 changes: 12 additions & 12 deletions 05-examples/invoice/03-api/PostmanOpenApi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ info:
title: Invoice Example Process API
version: '1.0'
summary: "\n |**This is for Postman - to have example requests. Be aware\
\ the Output is not provided!**\n |\n |\n\n\n\nCreated at 23.12.2024,\
\ 16:43\n\n**See the [Camundala Documentation](https://pme123.github.io/camundala/)**\n\
\ the Output is not provided!**\n |\n |\n\n\n\nCreated at 07.01.2025,\
\ 16:41\n\n**See the [Camundala Documentation](https://pme123.github.io/camundala/)**\n\
\n# Package Configuration\n**Check all dependency trees here: [example-invoice](../../dependencies/example-invoice.html)**\n\
\n### Dependencies:\n\n\n\n\n<details>\n<summary>PROJECT.conf</summary>\n<p>\n\
\n```\n\norg = \"pme123\"\nname = \"example-invoice\"\nversion = \"0.1.0-SNAPSHOT\"\
\ndependencies: {\n //\"example-helper\": \"pme123:example-helper:1.3.*\"\n}\n\
\n```\n\n</p>\n</details>\n\n\nThere is no README.md in the Project.\n\n\n\n<p/>\n\
<details>\n<summary>\n<b><i>General Variables</i></b>\n</summary>\n\n<p>\n\n###\
\ Mocking\n\n**servicesMocked**:\n\nMock all the _ServiceWorkers_ in your process\
\ with their default Mock:\n\n- DSL:\n```scala\nprocess(..)\n .mockServices\n\
```\n\n- Json\n```json\n...\n\"servicesMocked\": true,\n...\n```\n\n\n**mockedWorkers**:\n\
\nMock any Process- and/or ExternalTask-Worker with their default Mocks.\nThis\
\ is a list of the _Worker topicNames or Process processNames_, you want to mock.\n\
It is also possible to use a _comma separated_ String,\nlike `\"mySubProcess,myOtherSubProcess,myService\"\
\n```\n\nprojectName = \"pme123-invoice\"\nprojectVersion = \"0.1.0-SNAPSHOT\"\
\nsubProjects = []\ndependencies: []\n\n```\n\n</p>\n</details>\n\n\nThere is\
\ no README.md in the Project.\n\n\n\n<p/>\n<details>\n<summary>\n<b><i>General\
\ Variables</i></b>\n</summary>\n\n<p>\n\n### Mocking\n\n**servicesMocked**:\n\
\nMock all the _ServiceWorkers_ in your process with their default Mock:\n\n-\
\ DSL:\n```scala\nprocess(..)\n .mockServices\n```\n\n- Json\n```json\n...\n\"\
servicesMocked\": true,\n...\n```\n\n\n**mockedWorkers**:\n\nMock any Process-\
\ and/or ExternalTask-Worker with their default Mocks.\nThis is a list of the\
\ _Worker topicNames or Process processNames_, you want to mock.\nIt is also possible\
\ to use a _comma separated_ String,\nlike `\"mySubProcess,myOtherSubProcess,myService\"\
`\n\n_Be aware_: For Sub-Processes, this expects an _InitWorker_ where the _topicName_\
\ is equal to the _processName_.\n\n\n- DSL:\n```scala\nprocess(..)\n .mockedWorkers(\"\
mySubProcess1\", \"mySubProcess2\") // creates a list with SubProcessess\n .mockedWorker(\"\
Expand Down
10 changes: 4 additions & 6 deletions 05-examples/invoice/PROJECT.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
org = "pme123"
name = "example-invoice"
version = "0.1.0-SNAPSHOT"
dependencies: {
//"example-helper": "pme123:example-helper:1.3.*"
}
projectName = "pme123-invoice"
projectVersion = "0.1.0-SNAPSHOT"
subProjects = []
dependencies: []



Expand Down
2 changes: 1 addition & 1 deletion helper.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S scala shebang

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

import camundala.helper.*

Expand Down
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object Dependencies {
val openapiCirceVersion = "0.11.5"
val tapirVersion = "1.11.11"
val ironCirceVersion = "2.6.0"
val mUnitVersion = "1.0.3"
val mUnitVersion = "1.0.4"
// 02-bpmn
// -> domain
// - osLib
Expand Down Expand Up @@ -53,7 +53,7 @@ object Dependencies {
// 04-c8-spring
// -> bpmn
val scalaJacksonVersion = "2.18.2"
val camunda8Version = "8.5.15"
val camunda8Version = "8.5.16"
val springBootVersion = "3.3.4"
val swaggerOpenAPIVersion = "2.1.24"
// examples
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.4")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.11.0")

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

0 comments on commit 2ba0206

Please sign in to comment.