@@ -10,7 +10,10 @@ case class CompanyWrapperGenerator()(using config: DevConfig):
10
10
createIfNotExists(projectApiPath, apiWrapper)
11
11
createIfNotExists(projectDmnPath, dmnWrapper)
12
12
createIfNotExists(projectSimulationPath, simulationWrapper)
13
- createIfNotExists(projectWorkerPath, workerWrapper)
13
+ createIfNotExists(projectWorkerHandlerPath, workerHandlerWrapper)
14
+ createIfNotExists(projectWorkerContextPath, workerContextWrapper)
15
+ createIfNotExists(projectWorkerPasswordPath, workerPasswordWrapper)
16
+ createIfNotExists(projectWorkerRestApiPath, workerRestApiWrapper)
14
17
createIfNotExists(projectHelperPath, helperWrapper)
15
18
16
19
private lazy val companyName = config.companyName
@@ -19,7 +22,10 @@ case class CompanyWrapperGenerator()(using config: DevConfig):
19
22
private lazy val projectApiPath = ModuleConfig .apiModule.srcPath / " CompanyApiCreator.scala"
20
23
private lazy val projectDmnPath = ModuleConfig .dmnModule.srcPath / " CompanyDmnTester.scala"
21
24
private lazy val projectSimulationPath = ModuleConfig .simulationModule.srcPath / " CompanySimulation.scala"
22
- private lazy val projectWorkerPath = ModuleConfig .workerModule.srcPath / " CompanyWorkerHandler.scala"
25
+ private lazy val projectWorkerHandlerPath = ModuleConfig .workerModule.srcPath / " CompanyWorkerHandler.scala"
26
+ private lazy val projectWorkerContextPath = ModuleConfig .workerModule.srcPath / " CompanyEngineContext.scala"
27
+ private lazy val projectWorkerPasswordPath = ModuleConfig .workerModule.srcPath / " CompanyPasswordFlow.scala"
28
+ private lazy val projectWorkerRestApiPath = ModuleConfig .workerModule.srcPath / " CompanyRestApiClient.scala"
23
29
private lazy val projectHelperPath = ModuleConfig .helperModule.srcPath / " CompanyDevHelper.scala"
24
30
25
31
private lazy val bpmnWrapper =
@@ -87,12 +93,10 @@ case class CompanyWrapperGenerator()(using config: DevConfig):
87
93
|end CompanySimulation
88
94
| """ .stripMargin
89
95
90
- private lazy val workerWrapper =
96
+ private lazy val workerHandlerWrapper =
91
97
s """ package $companyName.camundala.worker
92
98
|
93
- |import camundala.camunda7.worker.C7WorkerHandler
94
- |import camundala.worker.*
95
- |
99
+ |import camundala.camunda7.worker.C7WorkerHandler |
96
100
|import scala.reflect.ClassTag
97
101
|
98
102
|/**
@@ -108,10 +112,6 @@ case class CompanyWrapperGenerator()(using config: DevConfig):
108
112
| InConfig <: Product: InOutCodec
109
113
|] extends CompanyWorkerHandler, InitWorkerDsl[In, Out, InitIn, InConfig]
110
114
|
111
- |trait CompanyValidationWorkerDsl[
112
- | In <: Product: InOutCodec
113
- |] extends CompanyWorkerHandler, ValidationWorkerDsl[In]
114
- |
115
115
|trait CompanyCustomWorkerDsl[
116
116
| In <: Product: InOutCodec,
117
117
| Out <: Product: InOutCodec
@@ -125,6 +125,70 @@ case class CompanyWrapperGenerator()(using config: DevConfig):
125
125
|] extends CompanyWorkerHandler, ServiceWorkerDsl[In, Out, ServiceIn, ServiceOut]
126
126
| """ .stripMargin
127
127
128
+ private lazy val workerContextWrapper =
129
+ s """ package $companyName.camundala.worker
130
+ |
131
+ |import camundala.camunda7.worker.Camunda7Context
132
+ |import scala.compiletime.uninitialized
133
+ |import scala.reflect.ClassTag
134
+ |
135
+ |@SpringConfiguration
136
+ |class CompanyEngineContext extends Camunda7Context:
137
+ |
138
+ | @Autowired()
139
+ | var restApiClient: CompanyRestApiClient = uninitialized
140
+ |
141
+ | override def sendRequest[ServiceIn: Encoder, ServiceOut: Decoder: ClassTag](
142
+ | request: RunnableRequest[ServiceIn]
143
+ | ): SendRequestType[ServiceOut] =
144
+ | restApiClient.sendRequest(request)
145
+ |
146
+ |end CompanyEngineContext
147
+ | """ .stripMargin
148
+
149
+ private lazy val workerPasswordWrapper =
150
+ s """ package $companyName.camundala.worker
151
+ |
152
+ |import camundala.camunda7.worker.oauth.OAuthPasswordFlow
153
+ |
154
+ |trait CompanyPasswordFlow extends OAuthPasswordFlow:
155
+ |
156
+ | lazy val fssoRealm: String = sys.env.getOrElse("FSSO_REALM", "myRealm")
157
+ | // default is a local keycloak server on colime docker environment
158
+ | lazy val fssoBaseUrl = sys.env.getOrElse("FSSO_BASE_URL", s"http://host.lima.internal:8090")
159
+ |
160
+ | override lazy val client_id = sys.env.getOrElse("FSSO_CLIENT_NAME", "myClientKey")
161
+ | override lazy val client_secret = sys.env.getOrElse("FSSO_CLIENT_SECRET", "myClientSecret")
162
+ | override lazy val scope = sys.env.getOrElse("FSSO_SCOPE", "myScope")
163
+ | override lazy val username = sys.env.getOrElse("FSSO_TECHUSER_NAME", "myTechUser")
164
+ | override lazy val password = sys.env.getOrElse("FSSO_TECHUSER_PASSWORD", "myTechUserPassword")
165
+ |
166
+ |end CompanyPasswordFlow
167
+ | """ .stripMargin
168
+
169
+ private lazy val workerRestApiWrapper =
170
+ s """ package $companyName.camundala.worker
171
+ |
172
+ |import camundala.camunda7.worker.RestApiClient
173
+ |import camundala.worker.CamundalaWorkerError.*
174
+ |import sttp.client3.*
175
+ |
176
+ |@SpringConfiguration
177
+ |class CompanyRestApiClient extends RestApiClient, CompanyPasswordFlow:
178
+ |
179
+ | override protected def auth(
180
+ | request: Request[Either[String, String], Any]
181
+ | )(using
182
+ | context: EngineRunContext
183
+ | ): Either[ServiceAuthError, Request[Either[String, String], Any]] =
184
+ | tokenService.adminToken()
185
+ | .map:
186
+ | request.addToken
187
+ | end auth
188
+ |
189
+ |end CompanyRestApiClient
190
+ | """ .stripMargin
191
+
128
192
private lazy val helperWrapper =
129
193
s """ package $companyName.camundala.helper
130
194
|
0 commit comments