Skip to content

Commit 4a2b1ea

Browse files
committed
Working at the documentation.
1 parent 711af08 commit 4a2b1ea

File tree

9 files changed

+148
-112
lines changed

9 files changed

+148
-112
lines changed

00-documentation/src/docs/bpmnDsl.md

Lines changed: 134 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,100 @@
22

33
This _DSL_ will bring your domain into your _BPMN-Process_.
44

5-
Its elements are more or less constructors with the same structure:
5+
As the pattern is always the same, we can setup each _BPMN Element_ in the same way.
66

77
```scala
8-
BPMN_ELEMENT(
9-
id: String,
10-
in: Input,
11-
out: Output,
12-
descr: Optable[String]
13-
)
14-
```
8+
object BpmnElement extends CompanyBpmn<Element>Dsl:
159

16-
So each BPMN Element has:
10+
val processName = "mycompany-myproject-myelement" // depending on the element this can be different
11+
lazy val descr = "my element..."
1712

18-
- _id_: a unique identifier, depending on the element it must be unique within its process, or within a Camunda Instance (_process, dmn_).
19-
- _in_: an input object that we descibed in the [_Domain Specification_](specification.md).
20-
- _out_: an output object that we descibed in the [_Domain Specification_](specification.md).
21-
- _descr_: an optional description of this element.
13+
case class In(...)
14+
object In:
15+
given ApiSchema[In] = deriveApiSchema
16+
given InOutCodec[In] = deriveInOutCodec
2217

23-
Here is an example:
24-
```scala
25-
process(
26-
id = InvoiceReceiptPIdent,
27-
descr = "This starts the Invoice Receipt Process.",
28-
in = InvoiceReceipt(),
29-
out = InvoiceReceiptCheck() // just for testing
30-
)
18+
case class Out(...)
19+
object Out:
20+
given ApiSchema[Out] = deriveApiSchema
21+
given InOutCodec[Out] = deriveInOutCodec
22+
23+
lazy val example = <bpmnElement>(
24+
In(),
25+
Out(),
26+
)
27+
end BpmnElement
3128
```
3229

33-
The element is a _process_ with its inputs and outputs. As we also want to test its execution,
34-
we defined also an output, also the process does not have one.
30+
So each BPMN Element has:
31+
32+
- _id_: a unique identifier, it must be unique within a Camunda Instance.
33+
Depending on the element this is named differently, e.g. `processName`, `messageName` etc.
34+
- _descr_: a description of this element.
35+
- _In_: an input class with the input process variables that we descibed in the [_Domain Specification_](specification.md).
36+
- _Out_: an output class with the output process variables that we descibed in the [_Domain Specification_](specification.md).
37+
- _example_: a method that creates an example of this element.
3538

36-
@:callout(info)
37-
If your element has no Input and/or Output, just leave it empty, as this is the default case.
39+
### Special Case Enums
40+
If you have an _Enum_ as an In or Out class, you need to define the example like this:
3841

3942
```scala
40-
process(
41-
id = MyDoItItselfProcess
42-
)
43+
44+
lazy val example = <bpmnElement>(
45+
In.CaseA(),
46+
Out.CaseA(),
47+
).withEnumInExamples(In.CaseB())
48+
.withEnumOutExamples(Out.CaseB())
4349
```
44-
@:@
50+
- This is needed to document both cases and also to handle them correctly in the _Workers_.
4551

46-
We only support elements you can interact with. The next subchapters describe them with an example.
52+
We support the following elements:
4753

4854
## Process
4955

50-
We already showed a process example above. Here the sub process _Review Invoice_:
56+
The Process is the main element of a BPMN.
57+
It is the most complex element and looks like this:
5158

5259
```scala
53-
process(
54-
id = "example-invoice-c7-review",
55-
descr = "This starts the Review Invoice Process.",
56-
in = InvoiceReceipt(),
57-
out = InvoiceReviewed()
58-
)
60+
object MyProcess extends CompanyBpmnProcessDsl:
61+
62+
val processName = "mycompany-myproject-myprocess"
63+
lazy val descr = "my process..."
64+
65+
case class In(
66+
...
67+
inConfig: Option[InConfig] = None
68+
) extends WithConfig[InConfig]
69+
70+
object In:
71+
given ApiSchema[In] = deriveApiSchema
72+
given InOutCodec[In] = deriveInOutCodec
73+
74+
case class InConfig(
75+
// Process Configuration
76+
...
77+
// Mocks
78+
... )
79+
object InConfig:
80+
given ApiSchema[InConfig] = deriveApiSchema
81+
given InOutCodec[InConfig] = deriveInOutCodec
82+
83+
case class InitIn(...)
84+
object InitIn:
85+
given ApiSchema[InitIn] = deriveApiSchema
86+
given InOutCodec[InitIn] = deriveInOutCodec
87+
88+
case class Out(...)
89+
object Out:
90+
given ApiSchema[Out] = deriveApiSchema
91+
given InOutCodec[Out] = deriveInOutCodec
92+
93+
lazy val example = process(
94+
In(),
95+
Out(),
96+
InitIn()
97+
)
98+
end MyProcess
5999
```
60100

61101
## Business Rule Tasks (Decision DMNs)
@@ -134,13 +174,31 @@ resultList(
134174
A _User Task_ describes its form values that it offers and the values it must be completed with.
135175

136176
```scala
137-
userTask(
138-
id = "ApproveInvoiceUT",
139-
descr = "Approve the invoice (or not).",
140-
in = InvoiceReceipt(),
141-
out = ApproveInvoice()
177+
object MyUserTask extends CompanyBpmnUserTaskDsl:
178+
179+
val name = "mycompany-myproject-myusertask"
180+
val descr: String = "my user task..."
181+
182+
case class In(...)
183+
object In:
184+
given ApiSchema[In] = deriveApiSchema
185+
given InOutCodec[In] = deriveInOutCodec
186+
187+
case class Out(...)
188+
object Out:
189+
given ApiSchema[Out] = deriveApiSchema
190+
given InOutCodec[Out] = deriveInOutCodec
191+
192+
lazy val example = userTask(
193+
In(),
194+
Out()
142195
)
196+
end MyUserTask
143197
```
198+
- The `name` is the name of the user task, **be aware** at the moment this is only for documentation.
199+
- A _UserTask_ extends _CompanyBpmnUserTaskDsl_.
200+
- The `In` object are the input variables you expect for the UI-Form of the _UserTask_.
201+
- The `Out` object are the process variables, the UI-Form sends, when it completes the _UserTask_.
144202

145203
## Receive Message Event
146204
A _Receive Message Event_ represents a catching message event.
@@ -149,11 +207,24 @@ This works only as intermediate event.
149207
As we don't support _throwing Message events_ we can simplify this to _messageEvent_:
150208

151209
```scala
152-
lazy val messageExample = messageEvent(
153-
"message-for-example",
154-
in = MessageExampleIn(),
155-
)
210+
object MyMessageEvent extends CompanyBpmnMessageEventDsl:
211+
212+
val messageName = "mycompany-myproject-mymessage"
213+
val descr: String = "my message..."
214+
215+
case class In(...)
216+
object In:
217+
given ApiSchema[In] = deriveApiSchema
218+
given InOutCodec[In] = deriveInOutCodec
219+
220+
lazy val example = messageEvent(In())
221+
end MyMessageEvent
156222
```
223+
- The `messageName` is the name of the message you expect.
224+
The correlation can be the business key or the process instance id.
225+
In the _Simulation_ we will use the _processInstanceId_.
226+
- You can send process variables with the `In` object.
227+
- A _MessageEvent_ extends _CompanyBpmnMessageEventDsl_.
157228

158229
## Receive Signal Event
159230
A _Receive Signal Event_ represents a catching signal event.
@@ -162,21 +233,23 @@ This works only as intermediate event.
162233
As we don't support _Throwing Signal events_ we can simplify this to _signalEvent_:
163234

164235
```scala
165-
lazy val signalExample = signalEvent(
166-
"signal-for-example",
167-
in = SignalExampleIn(),
168-
)
236+
object MySignalEvent extends CompanyBpmnSignalEventDsl:
237+
238+
val messageName = "mycompany-myproject-mysignal-{processInstanceId}"
239+
val descr: String = "my signal..."
240+
241+
case class In(...)
242+
object In:
243+
given ApiSchema[In] = deriveApiSchema
244+
given InOutCodec[In] = deriveInOutCodec
245+
246+
lazy val example = signalEvent(In())
247+
end MySignalEvent
169248
```
249+
- The `messageName` is the name of the signal you expect.
250+
To correlate the signal to a certain process instance, you can use the `{processInstanceId}` as a part in the signal name.
251+
This will be replaced in the _Simulation_ with the actual _processInstanceId_.
252+
- You can send process variables with the `In` object.
253+
- A _SignalEvent_ extends _CompanyBpmnSignalEventDsl_.
170254

171255

172-
## Timer Event
173-
A _Timer Event_ represents a timer event.
174-
There is no input needed, you can use it to describe the timers in your API doc, or using them in the Simulations to execute the job of the timer immediately.
175-
This works only as intermediate event.
176-
177-
```scala
178-
lazy val timerExample = timerEvent(
179-
"timer-for-example",
180-
)
181-
```
182-

00-documentation/src/docs/generalConcerns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ If an error is handled, the worker will add the following variables to the proce
189189

190190
- `errorCode: String` - the error code (`CamundalaWorkerError.errorCode`)
191191
- `errorMsg: String` - the error message (`CamundalaWorkerError.errorMsg`)
192-
-
192+
193193
### Authorization
194194

195195
#### Impersonate User

02-bpmn/src/main/scala/camundala/bpmn/BpmnProcessDsl.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,6 @@ trait BpmnProcessDsl extends BpmnDsl:
206206
): SignalEvent[Msg] =
207207
signalEvent(messageName, in, id, descr)
208208

209-
@deprecated("Use .. extends BpmnTimerDsl")
210-
def timerEvent(
211-
title: String,
212-
descr: Optable[String] = None
213-
): TimerEvent =
214-
TimerEvent(
215-
title,
216-
InOutDescr(title, descr = descr.value)
217-
)
218-
219209
private def msgNameDescr(messageName: String, descr: Optable[String]) =
220210
val msgNameDescr = s"- _messageName_: `$messageName`"
221211
Some(descr.value.map(_ + s"\n$msgNameDescr").getOrElse(msgNameDescr))

02-bpmn/src/main/scala/camundala/bpmn/BpmnTimerEventDsl.scala

Lines changed: 0 additions & 17 deletions
This file was deleted.

05-examples/demos/02-bpmn/src/main/scala/camundala/examples/demos/bpmn/TimerExample.scala

Lines changed: 0 additions & 16 deletions
This file was deleted.

build.sbt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,13 @@ lazy val documentation =
6767
// .renderMessages(MessageFilter.None)
6868
,
6969
laikaSite / target := baseDirectory.value / ".." / "docs",
70-
laikaExtensions := Seq(GitHubFlavor, SyntaxHighlighting)
70+
laikaExtensions := Seq(GitHubFlavor, SyntaxHighlighting),
71+
mdocIn := baseDirectory.value / "src" / "main" / "mdoc",
72+
mdocVariables := Map(
73+
"VERSION" -> version.value
74+
)
7175
)
72-
.enablePlugins(LaikaPlugin)
76+
.enablePlugins(LaikaPlugin, MdocPlugin)
7377

7478
// layer 01
7579
lazy val domain = project
@@ -105,9 +109,10 @@ lazy val bpmn = project
105109
.settings(
106110
autoImportSetting,
107111
libraryDependencies ++= Seq(
108-
osLibDependency,
112+
osLibDependency,
109113
chimneyDependency // mapping
110-
))
114+
)
115+
)
111116
.dependsOn(domain)
112117

113118
// layer 03
@@ -145,7 +150,7 @@ lazy val worker = project
145150
.settings(
146151
projectSettings("worker"),
147152
unitTestSettings,
148-
autoImportSetting,
153+
autoImportSetting
149154
)
150155
.dependsOn(bpmn)
151156

project/Settings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Settings {
99

1010
lazy val projectVersion =
1111
Using(scala.io.Source.fromFile("version"))(_.mkString.trim).get
12-
val scala3Version = "3.5.1"
12+
val scala3Version = "3.6.1"
1313
val org = "io.github.pme123"
1414

1515
def projectSettings(projName: String) = Seq(

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.10.1
1+
sbt.version=1.10.6

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.4")
44
//addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0")
55
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0")
66
addSbtPlugin("org.typelevel" % "laika-sbt" % "1.2.1")
7+
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.1" )
78

89
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1")
910

0 commit comments

Comments
 (0)