Skip to content

Commit

Permalink
Made the taskDefinitionKey of a UserTask required to be the same as i…
Browse files Browse the repository at this point in the history
…n the BPMN - new in API doc and Simulation.
  • Loading branch information
pme123 committed Jan 20, 2025
1 parent c85dd2b commit dfd801d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
17 changes: 7 additions & 10 deletions 02-bpmn/src/main/scala/camundala/bpmn/BpmnDsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ trait BpmnDsl:
def companyDescr: String = ""

private[bpmn] def msgNameDescr(messageName: String) =
Some(s"""
|$descr
|
|- _messageName_: `$messageName`
|
|---
|
|$companyDescr
|""".stripMargin)
bpmnDescr(s"- _messageName_: `$messageName`")

private[bpmn] lazy val defaultDescr =
private[bpmn] def userTaskDescr(messageName: String) =
bpmnDescr(s"- _taskDefinitionKey_: `$messageName`")

private def bpmnDescr(keyLabel: String) =
Some(s"""
|$descr
|
|$keyLabel
|
|---
|
|$companyDescr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait BpmnUserTaskDsl extends BpmnDsl:
out: Out = NoOutput()
): UserTask[In, Out] =
UserTask(
InOutDescr(name, in, out, defaultDescr)
InOutDescr(name, in, out, userTaskDescr(name))
)

end BpmnUserTaskDsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ trait SUserTaskExtensions extends SimulationHelper:

private def task()(using data: ScenarioData): ResultType =
def getTask(
processInstanceId: Any
processInstanceId: Any,
taskDefinitionKey: String
)(data: ScenarioData): ResultType =
val uri =
uri"${config.endpoint}/task?processInstanceId=$processInstanceId"
uri"${config.endpoint}/task?processInstanceId=$processInstanceId&taskDefinitionKey=$taskDefinitionKey"
val request = basicRequest
.auth()
.get(uri)
given ScenarioData = data
.info(
s"UserTask '${userTask.name}' get"
)
.debug(s"- URI: $uri")
.info(s"- URI: $uri")

request
.extractBody()
Expand All @@ -53,13 +54,13 @@ trait SUserTaskExtensions extends SimulationHelper:
}
.left
.flatMap { _ =>
userTask.tryOrFail(getTask(processInstanceId))
userTask.tryOrFail(getTask(processInstanceId, userTask.id))
}
)
end getTask

val processInstanceId = data.context.processInstanceId
getTask(processInstanceId)(data.withRequestCount(0))
getTask(processInstanceId, userTask.id)(data.withRequestCount(0))
end task

def checkForm()(using data: ScenarioData): ResultType =
Expand Down
4 changes: 2 additions & 2 deletions 03-worker/src/main/scala/camundala/worker/Handler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ trait WorkerHandler:
def worker: Worker[?, ?, ?]
def topic: String

def projectName: String
def applicationName: String
def registerHandler( register: => Unit): Unit =
val appPackageName = projectName.replace("-", ".")
val appPackageName = applicationName.replace("-", ".")
val testMode = sys.env.get("WORKER_TEST_MODE").contains("true") // did not work with lazy val
if testMode || getClass.getName.startsWith(appPackageName)
then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import scala.util.{Failure, Success}
trait C7WorkerHandler extends camunda.ExternalTaskHandler, WorkerHandler:

@Value("${spring.application.name}")
var projectName: String = scala.compiletime.uninitialized
var applicationName: String = scala.compiletime.uninitialized

@Autowired()
protected var engineContext: EngineContext = scala.compiletime.uninitialized
Expand Down

0 comments on commit dfd801d

Please sign in to comment.