Skip to content

Commit cf45cd1

Browse files
Add support for using Camunda 8.8 without Kafka leveraging execution-listener #34
1 parent 6af9175 commit cf45cd1

29 files changed

+1124
-631
lines changed

adapters/camunda7/src/main/java/io/vanillabp/cockpit/adapter/camunda7/usertask/Camunda7UserTaskHandler.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import io.vanillabp.cockpit.adapter.common.usertask.events.UserTaskCancelledEvent;
1010
import io.vanillabp.cockpit.adapter.common.usertask.events.UserTaskCompletedEvent;
1111
import io.vanillabp.cockpit.adapter.common.usertask.events.UserTaskEventImpl;
12-
import io.vanillabp.cockpit.adapter.common.usertask.events.UserTaskLifecycleEvent;
1312
import io.vanillabp.cockpit.adapter.common.usertask.events.UserTaskUpdatedEvent;
1413
import io.vanillabp.cockpit.commons.utils.DateTimeUtil;
1514
import io.vanillabp.spi.cockpit.details.DetailsEvent;
@@ -404,25 +403,6 @@ private UserTaskEventImpl prefillUserTaskDetails(
404403

405404
}
406405

407-
private void fillLifecycleEvent(
408-
final String workflowModuleId,
409-
final DelegateTask delegateTask,
410-
final UserTaskLifecycleEvent event) {
411-
412-
event.setEventId(
413-
System.nanoTime()
414-
+ "@"
415-
+ delegateTask.getProcessInstanceId()
416-
+ "#"
417-
+ delegateTask.getId());
418-
event.setWorkflowModuleId(workflowModuleId);
419-
event.setComment(
420-
delegateTask.getDeleteReason());
421-
event.setTimestamp(OffsetDateTime.now());
422-
event.setUserTaskId(
423-
delegateTask.getId());
424-
}
425-
426406
@SuppressWarnings("unchecked")
427407
private UserTaskDetails callUserTaskDetailsProviderMethod(
428408
final DelegateTask delegateTask,

adapters/camunda7/src/main/java/io/vanillabp/cockpit/adapter/camunda7/workflow/Camunda7WorkflowEventHandler.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
import io.vanillabp.cockpit.adapter.camunda7.workflow.publishing.WorkflowEvent;
77
import io.vanillabp.cockpit.adapter.common.properties.VanillaBpCockpitProperties;
88
import io.vanillabp.cockpit.adapter.common.workflow.WorkflowPublishing;
9+
import java.util.HashMap;
10+
import java.util.HashSet;
11+
import java.util.LinkedList;
12+
import java.util.List;
13+
import java.util.Map;
14+
import java.util.Objects;
915
import org.camunda.bpm.engine.HistoryService;
1016
import org.camunda.bpm.engine.RepositoryService;
1117
import org.camunda.bpm.engine.history.HistoricProcessInstance;
@@ -18,13 +24,6 @@
1824
import org.springframework.transaction.event.TransactionalEventListener;
1925
import org.springframework.util.StringUtils;
2026

21-
import java.util.HashMap;
22-
import java.util.HashSet;
23-
import java.util.LinkedList;
24-
import java.util.List;
25-
import java.util.Map;
26-
import java.util.Objects;
27-
2827
public class Camunda7WorkflowEventHandler {
2928
private static final Logger logger = LoggerFactory
3029
.getLogger(Camunda7WorkflowEventHandler.class);
@@ -104,7 +103,7 @@ private io.vanillabp.cockpit.adapter.common.workflow.events.WorkflowEvent proces
104103
logger.trace("No workflow handler available for bpmnProcessId '{}'", processInstance.getProcessDefinitionId());
105104
return null;
106105
}
107-
final String bpmnProcessName = processInstance.getProcessDefinitionKey();
106+
108107
final var processDefinition = repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId());
109108
final String bpmnProcessVersion;
110109
if (StringUtils.hasText(processDefinition.getVersionTag())) {
@@ -115,8 +114,7 @@ private io.vanillabp.cockpit.adapter.common.workflow.events.WorkflowEvent proces
115114
bpmnProcessVersion = Integer.toString(processDefinition.getVersion());
116115
}
117116

118-
return workflowHandler.wrapProcessInstance(
119-
processInstance, bpmnProcessName, bpmnProcessVersion);
117+
return workflowHandler.wrapProcessInstance(processInstance, bpmnProcessVersion);
120118

121119
}
122120

adapters/camunda7/src/main/java/io/vanillabp/cockpit/adapter/camunda7/workflow/Camunda7WorkflowHandler.java

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.vanillabp.cockpit.adapter.common.workflow.events.WorkflowCompletedEvent;
88
import io.vanillabp.cockpit.adapter.common.workflow.events.WorkflowCreatedEvent;
99
import io.vanillabp.cockpit.adapter.common.workflow.events.WorkflowEvent;
10+
import io.vanillabp.cockpit.adapter.common.workflow.events.WorkflowEventImpl;
1011
import io.vanillabp.cockpit.adapter.common.workflow.events.WorkflowUpdatedEvent;
1112
import io.vanillabp.spi.cockpit.workflow.PrefilledWorkflowDetails;
1213
import io.vanillabp.spi.cockpit.workflow.WorkflowDetails;
@@ -68,21 +69,19 @@ protected Logger getLogger() {
6869

6970
public WorkflowEvent wrapProcessInstance(
7071
final HistoricProcessInstance processInstance,
71-
final String bpmnProcessName,
7272
final String bpmnProcessVersion) {
7373

74-
final String workflowModuleId = processService.getWorkflowModuleId();
75-
74+
final var workflowModuleId = processService.getWorkflowModuleId();
75+
final var i18nLanguages = properties.getI18nLanguages(workflowModuleId, bpmnProcessId);
76+
7677
WorkflowEvent workflowEvent = null;
7778
if (processInstance.getEndTime() != null) {
78-
WorkflowCompletedEvent workflowCompletedEvent = new WorkflowCompletedEvent();
79-
fillLifecycleEvent(workflowModuleId, bpmnProcessId, bpmnProcessVersion, processInstance, workflowCompletedEvent);
79+
WorkflowCompletedEvent workflowCompletedEvent = new WorkflowCompletedEvent(workflowModuleId, i18nLanguages);
80+
fillWorkflowEvent((HistoricProcessInstanceEventEntity) processInstance, bpmnProcessId, bpmnProcessVersion, workflowCompletedEvent);
8081
workflowEvent = workflowCompletedEvent;
8182
} else {
82-
WorkflowUpdatedEvent workflowUpdatedEvent = new WorkflowUpdatedEvent(
83-
workflowModuleId,
84-
properties.getI18nLanguages(workflowModuleId, bpmnProcessId));
85-
fillWorkflowCreatedEvent(processInstance, bpmnProcessName, bpmnProcessVersion, workflowUpdatedEvent);
83+
WorkflowUpdatedEvent workflowUpdatedEvent = new WorkflowUpdatedEvent(workflowModuleId, i18nLanguages);
84+
fillWorkflowEvent((HistoricProcessInstanceEventEntity) processInstance, bpmnProcessId, bpmnProcessVersion, workflowUpdatedEvent);
8685
workflowEvent = workflowUpdatedEvent;
8786
}
8887
return workflowEvent;
@@ -97,34 +96,35 @@ public WorkflowEvent wrapProcessInstanceEvent(
9796
) {
9897

9998
final String workflowModuleId = processService.getWorkflowModuleId();
99+
final var i18nLanguages = properties.getI18nLanguages(workflowModuleId, bpmnProcessId);
100100

101101
WorkflowEvent workflowEvent;
102102

103103
if (processInstanceEvent.isEventOfType(HistoryEventTypes.PROCESS_INSTANCE_START)) {
104104

105105
WorkflowCreatedEvent workflowCreatedEvent = new WorkflowCreatedEvent(
106106
workflowModuleId,
107-
properties.getI18nLanguages(workflowModuleId, bpmnProcessId)
107+
i18nLanguages
108108
);
109109

110-
fillWorkflowCreatedEvent(processInstanceEvent, bpmnProcessName, bpmnProcessVersion, workflowCreatedEvent);
110+
fillWorkflowEvent(processInstanceEvent, bpmnProcessName, bpmnProcessVersion, workflowCreatedEvent);
111111
workflowEvent = workflowCreatedEvent;
112112

113113
} else if (processInstanceEvent.isEventOfType(HistoryEventTypes.PROCESS_INSTANCE_END)) {
114114

115-
WorkflowCreatedEvent workflowLifecycleEvent = processInstanceEvent.getDeleteReason() != null ?
116-
new WorkflowCancelledEvent() :
117-
new WorkflowCompletedEvent();
115+
WorkflowEventImpl workflowLifecycleEvent = processInstanceEvent.getDeleteReason() != null
116+
? new WorkflowCancelledEvent(workflowModuleId, i18nLanguages)
117+
: new WorkflowCompletedEvent(workflowModuleId, i18nLanguages);
118118

119-
fillLifecycleEvent(workflowModuleId, bpmnProcessId, bpmnProcessVersion, processInstanceEvent, workflowLifecycleEvent);
119+
fillWorkflowEvent(processInstanceEvent, bpmnProcessId, bpmnProcessVersion, workflowLifecycleEvent);
120120
workflowEvent = workflowLifecycleEvent;
121121

122122
} else {
123123

124124
WorkflowUpdatedEvent workflowUpdatedEvent = new WorkflowUpdatedEvent(
125125
workflowModuleId,
126-
properties.getI18nLanguages(workflowModuleId, bpmnProcessId));
127-
fillWorkflowCreatedEvent(processInstanceEvent, bpmnProcessName, bpmnProcessVersion, workflowUpdatedEvent);
126+
i18nLanguages);
127+
fillWorkflowEvent(processInstanceEvent, bpmnProcessName, bpmnProcessVersion, workflowUpdatedEvent);
128128
workflowEvent = workflowUpdatedEvent;
129129
}
130130

@@ -133,7 +133,7 @@ public WorkflowEvent wrapProcessInstanceEvent(
133133
}
134134

135135

136-
private void fillWorkflowCreatedEvent(HistoricProcessInstance processInstance, String bpmnProcessName, String bpmnProcessVersion, WorkflowCreatedEvent workflowCreatedEvent) {
136+
private void fillCreatedEvent(HistoricProcessInstance processInstance, String bpmnProcessName, String bpmnProcessVersion, WorkflowCreatedEvent workflowCreatedEvent) {
137137
final var bpmnProcessId = processInstance.getProcessDefinitionKey();
138138

139139
final var prefilledWorkflowDetails = prefillWorkflowDetails(
@@ -159,20 +159,18 @@ private void fillWorkflowCreatedEvent(HistoricProcessInstance processInstance, S
159159
: details);
160160
}
161161

162-
private void fillWorkflowCreatedEvent(
162+
private void fillWorkflowEvent(
163163
HistoricProcessInstanceEventEntity processInstanceEvent,
164164
String bpmnProcessName,
165165
String bpmnProcessVersion,
166-
WorkflowCreatedEvent workflowCreatedEvent
166+
WorkflowEventImpl workflowCreatedEvent
167167
) {
168168

169-
170169
final var bpmnProcessId = processInstanceEvent.getProcessDefinitionKey();
171170

172171
final var prefilledWorkflowDetails = prefillWorkflowDetails(
173172
bpmnProcessId,
174173
bpmnProcessVersion,
175-
bpmnProcessName,
176174
processInstanceEvent,
177175
workflowCreatedEvent);
178176

@@ -196,7 +194,7 @@ private void fillWorkflowDetailsByCustomDetails(
196194
final String bpmnProcessId,
197195
final String bpmnProcessVersion,
198196
final String bpmnProcessName,
199-
WorkflowCreatedEvent event,
197+
WorkflowEventImpl event,
200198
WorkflowDetails details
201199
) {
202200
// a different object was returned then provided
@@ -287,12 +285,11 @@ private void fillWorkflowDetailsByCustomDetails(
287285

288286
}
289287

290-
private WorkflowCreatedEvent prefillWorkflowDetails(
288+
private WorkflowEventImpl prefillWorkflowDetails(
291289
final String bpmnProcessId,
292290
final String bpmnProcessVersion,
293-
final String bpmnProcessName,
294291
final HistoricProcessInstanceEventEntity processInstanceEvent,
295-
final WorkflowCreatedEvent event) {
292+
final WorkflowEventImpl event) {
296293

297294
final var prefilledWorkflowDetails = event;
298295

adapters/camunda8/src/main/java/io/vanillabp/cockpit/adapter/camunda8/Camunda8AdapterConfiguration.java

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.vanillabp.cockpit.adapter.camunda8.workflow.Camunda8WorkflowEventHandler;
1212
import io.vanillabp.cockpit.adapter.camunda8.workflow.Camunda8WorkflowHandler;
1313
import io.vanillabp.cockpit.adapter.camunda8.workflow.Camunda8WorkflowWiring;
14+
import io.vanillabp.cockpit.adapter.camunda8.workflow.publishing.Camunda8WorkflowEventPublisher;
1415
import io.vanillabp.cockpit.adapter.common.CockpitCommonAdapterConfiguration;
1516
import io.vanillabp.cockpit.adapter.common.properties.VanillaBpCockpitProperties;
1617
import io.vanillabp.cockpit.adapter.common.service.AdapterConfigurationBase;
@@ -77,7 +78,7 @@ public class Camunda8AdapterConfiguration extends AdapterConfigurationBase<Camun
7778
@Autowired
7879
private Camunda8VanillaBpProperties properties;
7980

80-
private final Map<Class<?>, Camunda8BusinessCockpitService> cockpitServices = new HashMap<>();
81+
private final Map<Class<?>, Camunda8BusinessCockpitService<?>> cockpitServices = new HashMap<>();
8182

8283
@Override
8384
public String getAdapterId() {
@@ -90,12 +91,17 @@ public Camunda8UserTaskEventHandler camunda8BusinessCockpitUserTaskEventHandler(
9091
}
9192

9293
@Bean
93-
public Camunda8WorkflowEventHandler ccamunda8BusinessCockpitWorkflowEventHandler(
94-
final ApplicationEventPublisher applicationEventPublisher,
95-
final WorkflowPublishing workflowPublishing) {
96-
return new Camunda8WorkflowEventHandler(applicationEventPublisher, workflowPublishing);
94+
public Camunda8WorkflowEventHandler ccamunda8BusinessCockpitWorkflowEventHandler() {
95+
return new Camunda8WorkflowEventHandler();
9796
}
9897

98+
@Bean
99+
public Camunda8WorkflowEventPublisher camunda8BusinessCockpitWorkflowEventPublisher(
100+
final WorkflowPublishing workflowPublishing) {
101+
102+
return new Camunda8WorkflowEventPublisher(
103+
workflowPublishing);
104+
}
99105

100106
@Bean
101107
public Camunda8UserTaskEventPublisher camunda8BusinessCockpitUserTaskEventPublisher(
@@ -138,25 +144,33 @@ public Camunda8UserTaskWiring camunda8BusinessCockpitUserTaskWiring(
138144
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
139145
public Camunda8WorkflowHandler camunda8WorkflowHandler(
140146
final VanillaBpCockpitProperties cockpitProperties,
147+
final ApplicationEventPublisher applicationEventPublisher,
141148
final AdapterAwareProcessService<?> processService,
142149
final String bpmnProcessId,
143-
final String bpmnProcessName,
150+
final String bpmnProcessVersionInfo,
151+
final String processTitle,
144152
final Optional<Configuration> templating,
153+
final String aggregateIdPropertyName,
145154
final CrudRepository<Object, Object> workflowAggregateRepository,
146155
final Object bean,
147156
final Method method,
148-
final List<MethodParameter> parameters) {
157+
final List<MethodParameter> parameters,
158+
final CamundaClient client) {
149159

150160
final var result = new Camunda8WorkflowHandler(
151161
cockpitProperties,
162+
applicationEventPublisher,
152163
processService,
153164
bpmnProcessId,
154-
bpmnProcessName,
165+
bpmnProcessVersionInfo,
166+
processTitle,
155167
templating,
168+
aggregateIdPropertyName,
156169
workflowAggregateRepository,
157170
bean,
158171
method,
159-
parameters);
172+
parameters,
173+
client);
160174
final var cockpitService = cockpitServices.get(processService.getWorkflowAggregateClass());
161175
if (cockpitService != null) {
162176
final var tenantId = properties.getTenantId(processService.getWorkflowModuleId());
@@ -208,9 +222,11 @@ public Camunda8UserTaskHandler camunda8UserTaskHandler(
208222
@Bean
209223
public Camunda8WorkflowWiring camunda8BusinessCockpitWorkflowWiring(
210224
final ApplicationContext applicationContext,
225+
final ApplicationEventPublisher applicationEventPublisher,
211226
final VanillaBpCockpitProperties cockpitProperties,
212227
final Camunda8VanillaBpProperties camunda8Properties,
213228
final SpringBeanUtil springBeanUtil,
229+
final SpringDataUtil springDataUtil,
214230
final Map<Class<?>, AdapterAwareProcessService<?>> connectableServices,
215231
@Qualifier(CockpitCommonAdapterConfiguration.TEMPLATING_QUALIFIER)
216232
final Optional<Configuration> templating,
@@ -219,9 +235,12 @@ public Camunda8WorkflowWiring camunda8BusinessCockpitWorkflowWiring(
219235
final ObjectProvider<Camunda8WorkflowHandler> workflowHandlers) {
220236
return new Camunda8WorkflowWiring(
221237
applicationContext,
238+
applicationEventPublisher,
239+
workerId,
222240
cockpitProperties,
223241
camunda8Properties,
224242
springBeanUtil,
243+
springDataUtil,
225244
new WorkflowMethodParameterFactory(),
226245
connectableServices,
227246
getConnectableServices(),
@@ -238,8 +257,6 @@ public Camunda8DeploymentAdapter camunda8BusinessCockpitDeploymentAdapter(
238257
final VanillaBpCockpitProperties cockpitProperties,
239258
final Camunda8UserTaskWiring camunda8UserTaskWiring,
240259
final Camunda8WorkflowWiring camunda8WorkflowWiring,
241-
final Camunda8UserTaskEventHandler userTaskEventHandler,
242-
final Camunda8WorkflowEventHandler workflowEventHandler,
243260
final ApplicationEventPublisher applicationEventPublisher) {
244261

245262
return new Camunda8DeploymentAdapter(
@@ -249,8 +266,6 @@ public Camunda8DeploymentAdapter camunda8BusinessCockpitDeploymentAdapter(
249266
cockpitProperties,
250267
camunda8UserTaskWiring,
251268
camunda8WorkflowWiring,
252-
userTaskEventHandler,
253-
workflowEventHandler,
254269
applicationEventPublisher);
255270
}
256271

@@ -296,7 +311,7 @@ public <WA> Camunda8BusinessCockpitService<?> newBusinessCockpitServiceImplement
296311
}
297312
}
298313

299-
final var result = new Camunda8BusinessCockpitService<WA>(
314+
final var result = new Camunda8BusinessCockpitService<>(
300315
workflowAggregateRepository,
301316
workflowAggregateClass,
302317
springDataUtil::getId,

0 commit comments

Comments
 (0)