Skip to content

Commit 548c6d3

Browse files
committed
Merge upstream/main and preserve excluded paths
2 parents 8c04032 + 164b5df commit 548c6d3

File tree

306 files changed

+8217
-1930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

306 files changed

+8217
-1930
lines changed

.rat-excludes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,9 @@ PMMLRegression.pmml
222222
.gitignore
223223
# springboot/integration-tests/integration-tests-springboot-processes-persistence-it/integration-tests-springboot-processes-persistence-common/src/main/resources/transactional_error.bpmn
224224
transactional_error.bpmn
225+
# quarkus/addons/process-migration/integration-tests/src/main/resources/signal.bpmn
226+
signal.bpmn
227+
# quarkus/addons/process-migration/integration-tests/src/main/resources/signal2.bpmn
228+
signal2.bpmn
229+
# quarkus/addons/process-migration/integration-tests/src/main/resources/META-INF/migration-plan/signal.mpf
230+
signal.mpf

addons/common/events/decisions/src/test/java/org/kie/kogito/eventdriven/decision/EventDrivenDecisionControllerTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
import java.io.IOException;
2222
import java.util.Map;
2323
import java.util.Optional;
24-
import java.util.concurrent.CompletionStage;
2524
import java.util.function.Consumer;
26-
import java.util.function.Function;
2725

2826
import org.junit.jupiter.api.BeforeAll;
2927
import org.junit.jupiter.api.BeforeEach;
@@ -370,11 +368,11 @@ private static class TestEventReceiver implements EventReceiver {
370368
private CloudEventUnmarshallerFactory unmarshaller = new ObjectCloudEventUnmarshallerFactory(objectMapper);
371369

372370
public void accept(String message) throws IOException {
373-
subscription.getConsumer().apply(subscription.getConverter().convert(message));
371+
subscription.getConsumer().accept(subscription.getConverter().convert(message));
374372
}
375373

376374
@Override
377-
public <T> void subscribe(Function<DataEvent<T>, CompletionStage<?>> consumer, Class<T> clazz) {
375+
public <T> void subscribe(Consumer<DataEvent<T>> consumer, Class<T> clazz) {
378376
subscription = new Subscription(consumer, new CloudEventConverter<>(clazz, unmarshaller));
379377
}
380378
}

addons/common/events/rules/src/main/java/org/kie/kogito/eventdriven/rules/EventDrivenRulesController.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020

2121
import java.util.Objects;
2222
import java.util.Optional;
23-
import java.util.concurrent.CompletableFuture;
24-
import java.util.concurrent.CompletionStage;
25-
import java.util.function.Function;
23+
import java.util.function.Consumer;
2624

2725
import org.kie.kogito.config.ConfigBean;
2826
import org.kie.kogito.event.DataEvent;
@@ -68,7 +66,7 @@ public <D> void subscribe(EventDrivenQueryExecutor<D> queryExecutor, Class<D> ob
6866
eventReceiver.subscribe(new RequestHandler<>(queryExecutor), objectClass);
6967
}
7068

71-
private class RequestHandler<T> implements Function<DataEvent<T>, CompletionStage<?>> {
69+
private class RequestHandler<T> implements Consumer<DataEvent<T>> {
7270

7371
private EventDrivenQueryExecutor<T> queryExecutor;
7472

@@ -77,15 +75,14 @@ public RequestHandler(EventDrivenQueryExecutor<T> queryExecutor) {
7775
}
7876

7977
@Override
80-
public CompletionStage<?> apply(DataEvent<T> event) {
78+
public void accept(DataEvent<T> event) {
8179
KogitoRulesExtension extension = ExtensionProvider.getInstance().parseExtension(KogitoRulesExtension.class, event);
8280
if (CloudEventUtils.isValidRequest(event, REQUEST_EVENT_TYPE, extension)) {
8381
buildResponseCloudEvent(event, queryExecutor.executeQuery(event), extension).ifPresentOrElse(c -> eventEmitter.emit(c),
8482
() -> LOG.info("Extension {} does not match this query executor {}", extension, queryExecutor));
8583
} else {
8684
LOG.warn("Event {} does not have expected information, discarding it", event);
8785
}
88-
return CompletableFuture.completedStage(null);
8986
}
9087

9188
private Optional<DataEvent<?>> buildResponseCloudEvent(DataEvent<?> event, Object payload, KogitoRulesExtension extension) {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<parent>
26+
<groupId>org.kie</groupId>
27+
<artifactId>kogito-addons-common-parent</artifactId>
28+
<version>999-SNAPSHOT</version>
29+
</parent>
30+
31+
<artifactId>kie-addons-process-instance-migration</artifactId>
32+
33+
<properties>
34+
<maven.compiler.source>21</maven.compiler.source>
35+
<maven.compiler.target>21</maven.compiler.target>
36+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37+
</properties>
38+
39+
</project>

addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/GenericRepository.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,16 @@
2222
import java.sql.PreparedStatement;
2323
import java.sql.ResultSet;
2424
import java.sql.SQLException;
25-
import java.util.ArrayDeque;
26-
import java.util.ArrayList;
27-
import java.util.Deque;
28-
import java.util.List;
29-
import java.util.Optional;
30-
import java.util.Spliterator;
31-
import java.util.Spliterators;
32-
import java.util.UUID;
25+
import java.util.*;
3326
import java.util.function.Consumer;
27+
import java.util.stream.Collectors;
3428
import java.util.stream.Stream;
3529
import java.util.stream.StreamSupport;
3630

3731
import javax.sql.DataSource;
3832

33+
import static java.util.Arrays.stream;
34+
3935
public class GenericRepository extends Repository {
4036

4137
private static final String PAYLOAD = "payload";
@@ -323,15 +319,26 @@ long migrate(String processId, String processVersion, String targetProcessId, St
323319
}
324320

325321
@Override
326-
void migrate(String processId, String processVersion, String targetProcessId, String targetProcessVersion, String[] processIds) {
322+
void migrate(String processId, String processVersion, String targetProcessId, String targetProcessVersion, String[] processInstanceIds) {
323+
String sqlParamsPlaceHolders = stream(processInstanceIds).map(processInstanceId -> "?")
324+
.collect(Collectors.joining(", "));
325+
326+
String migrateProcessInstancesSQLStatement = MIGRATE_INSTANCES_SQL_TEMPLATE.formatted(sqlParamsPlaceHolders);
327+
327328
try (Connection connection = dataSource.getConnection();
328-
PreparedStatement statement = connection.prepareStatement(sqlIncludingVersion(Repository.MIGRATE_INSTANCE, processVersion))) {
329+
PreparedStatement statement = connection.prepareStatement(sqlIncludingVersion(migrateProcessInstancesSQLStatement, processVersion))) {
330+
329331
statement.setString(1, targetProcessId);
330332
statement.setString(2, targetProcessVersion);
331-
statement.setObject(3, connection.createArrayOf("VARCHAR", processIds));
332-
statement.setString(4, processId);
333+
statement.setString(3, processId);
334+
335+
int i = 4;
336+
for (String processInstanceId : processInstanceIds) {
337+
statement.setString(i++, processInstanceId);
338+
}
339+
333340
if (processVersion != null) {
334-
statement.setString(5, processVersion);
341+
statement.setString(i, processVersion);
335342
}
336343
statement.executeUpdate();
337344
} catch (Exception e) {

addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/Repository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ abstract class Repository {
3535
static final String PROCESS_VERSION_EQUALS_TO = "and process_version = ?";
3636
static final String PROCESS_VERSION_IS_NULL = "and process_version is null";
3737
static final String MIGRATE_BULK = "UPDATE process_instances SET process_id = ?, process_version = ? WHERE process_id = ? ";
38-
static final String MIGRATE_INSTANCE = "UPDATE process_instances SET process_id = ?, process_version = ? WHERE id = ANY (?) and process_id = ? ";
38+
static final String MIGRATE_INSTANCES_SQL_TEMPLATE = "UPDATE process_instances SET process_id = ?, process_version = ? WHERE process_id = ? and id IN ( %s ) ";
3939
static final String FIND_ALL_WAITING_FOR_EVENT_TYPE =
4040
"SELECT payload, version FROM event_types, process_instances WHERE process_instances.id = event_types.process_instance_id AND process_id = ? AND event_type = ?";
4141
static final String DELETE_ALL_WAITING_FOR_EVENT_TYPE = "DELETE FROM event_types WHERE process_instance_id = ?";
@@ -81,6 +81,6 @@ protected RuntimeException uncheckedException(Exception ex, String message, Obje
8181

8282
abstract long migrate(String id, String version, String targetProcessId, String targetProcessVersion);
8383

84-
abstract void migrate(String id, String version, String targetProcessId, String targetProcessVersion, String[] processIds);
84+
abstract void migrate(String id, String version, String targetProcessId, String targetProcessVersion, String[] processInstanceIds);
8585

8686
}

addons/common/persistence/mongodb/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
</dependency>
8383
<dependency>
8484
<groupId>org.testcontainers</groupId>
85-
<artifactId>junit-jupiter</artifactId>
85+
<artifactId>testcontainers-junit-jupiter</artifactId>
8686
<version>${version.org.testcontainers}</version>
8787
<scope>test</scope>
8888
</dependency>

addons/common/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<module>rest-exception-handler</module>
4242
<module>process-svg</module>
4343
<module>process-management</module>
44+
<module>process-instance-migration</module>
4445
<module>process-dynamic</module>
4546
<module>knative</module>
4647
<module>kubernetes</module>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# KIE Process Instance Migration Add-on
21+
22+
The KIE Process Instance Migration (PIM) Add-on adds functionality for migrating active processes.This functionality is exposed through management REST endpoints after adding the platform specific dependencies as specified below.
23+
24+
Following two endpoints can be used to migrate active process instances:
25+
26+
1. Endpoint to migrate all active process instances of a given processId to a new target process
27+
28+
Endpoint : POST /management/processes/{processId}/migrate:
29+
30+
Request body :
31+
32+
```json
33+
{
34+
"targetProcessId": "<>",
35+
"targetProcessVersion": "<>"
36+
}
37+
```
38+
39+
Input parameters:
40+
1. processId: source process identifier (path parameter)
41+
2. targetProcessId : target process identifier(query parameter)
42+
3. targetProcessVersion : target process version(query parameter)
43+
44+
Output:
45+
46+
The response JSON Schema includes details of processInstanceId migrated to new process:
47+
48+
```json
49+
{
50+
"message": <>,
51+
"numberOfProcessInstanceMigrated": <>
52+
}
53+
```
54+
Sample JSON Response :
55+
56+
```json
57+
{
58+
"message": "All instances migrated",
59+
"numberOfProcessInstanceMigrated": 1
60+
}
61+
```
62+
63+
2. Endpoint to migrate all active process instances of a given processId to a new target process
64+
65+
Endpoint. : POST /management/processes/{processId}/instances/{processInstanceId}/migrate:
66+
67+
Request body :
68+
```json
69+
{
70+
"targetProcessId": "<>",
71+
"targetProcessVersion": "<>"
72+
}
73+
```
74+
Input parameters:
75+
76+
1. processId: source process identifier (path parameter)
77+
2. processInstanceId: source process instance identifier (path parameter)
78+
3. targetProcessId : target process identifier(query parameter)
79+
4. targetProcessVersion : target process version(query parameter)
80+
81+
Output:
82+
83+
The response JSON Schema includes details of the processInstanceId migrated to new process
84+
```json
85+
{
86+
"processInstanceId": <>,
87+
"message": <>
88+
}
89+
```
90+
Sample JSON Response Example :
91+
92+
```json
93+
{
94+
"processInstanceId": "1c67ac14-e26a-4f5f-8d42-f4c3bdb691e5",
95+
"message": "1c67ac14-e26a-4f5f-8d42-f4c3bdb691e5 instance migrated"
96+
}
97+
```
98+
### Usage
99+
100+
Add this section to your `pom.xml` file:
101+
102+
1. Quarkus:
103+
```xml
104+
<dependency>
105+
<groupId>org.kie</groupId>
106+
<artifactId>kie-addons-quarkus-process-instance-migration</artifactId>
107+
</dependency>
108+
```
109+
2. Springboot:
110+
```xml
111+
<dependency>
112+
<groupId>org.kie</groupId>
113+
<artifactId>kie-addons-springboot-process-instance-migration</artifactId>
114+
</dependency>
115+
```
116+
117+
## Examples
118+
119+
See the following examples to explore more about this capability:
120+
[process-instance-migration-quarkus](https://github.com/kiegroup/kogito-examples/tree/main/kogito-quarkus-examples/process-instance-migration-quarkus)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
21+
-->
22+
<project xmlns="http://maven.apache.org/POM/4.0.0"
23+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
25+
<parent>
26+
<artifactId>kogito-addons-common-parent</artifactId>
27+
<groupId>org.kie</groupId>
28+
<version>999-SNAPSHOT</version>
29+
</parent>
30+
<modelVersion>4.0.0</modelVersion>
31+
32+
<artifactId>kie-addons-process-instance-migration</artifactId>
33+
<name>KIE :: Add-Ons :: Process Migration :: Common</name>
34+
35+
<properties>
36+
<java.module.name>org.kie.kogito.process.migration</java.module.name>
37+
</properties>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>org.kie.kogito</groupId>
42+
<artifactId>kogito-api</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.kie.kogito</groupId>
46+
<artifactId>jbpm-deps-group-engine</artifactId>
47+
<type>pom</type>
48+
</dependency>
49+
50+
<!-- test dependencies -->
51+
<dependency>
52+
<groupId>org.junit.jupiter</groupId>
53+
<artifactId>junit-jupiter-engine</artifactId>
54+
<scope>test</scope>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.assertj</groupId>
58+
<artifactId>assertj-core</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.mockito</groupId>
63+
<artifactId>mockito-junit-jupiter</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
</dependencies>
67+
68+
</project>

0 commit comments

Comments
 (0)