From b445a262d6cb2aa063403fba4fa1f96161f2bc52 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 12 Jun 2024 21:08:12 +0200 Subject: [PATCH 01/13] Update for next development version --- bom/datapool-dependencies/pom.xml | 2 +- bom/parent/pom.xml | 2 +- bom/taskpool-dependencies/pom.xml | 2 +- core/bus-jackson/pom.xml | 2 +- core/datapool/datapool-api/pom.xml | 2 +- core/datapool/datapool-core/pom.xml | 2 +- core/datapool/datapool-event/pom.xml | 2 +- core/datapool/pom.xml | 2 +- core/spring-utils/pom.xml | 2 +- core/taskpool/pom.xml | 2 +- core/taskpool/taskpool-api/pom.xml | 2 +- core/taskpool/taskpool-core/pom.xml | 2 +- core/taskpool/taskpool-event/pom.xml | 2 +- integration/camunda-bpm/engine-client/pom.xml | 2 +- integration/camunda-bpm/pom.xml | 2 +- integration/camunda-bpm/springboot-autoconfigure/pom.xml | 2 +- integration/camunda-bpm/springboot-starter/pom.xml | 2 +- integration/camunda-bpm/taskpool-collector/pom.xml | 2 +- integration/camunda-bpm/taskpool-job-sender/pom.xml | 2 +- integration/common/datapool-sender/pom.xml | 2 +- integration/common/pom.xml | 2 +- integration/common/tasklist-url-resolver/pom.xml | 2 +- integration/common/taskpool-sender/pom.xml | 2 +- integration/common/variable-serializer/pom.xml | 2 +- pom.xml | 2 +- view/form-url-resolver/pom.xml | 2 +- view/jpa/pom.xml | 2 +- view/mongo/pom.xml | 2 +- view/pom.xml | 2 +- view/simple/pom.xml | 2 +- view/view-api-client/pom.xml | 2 +- view/view-api/pom.xml | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/bom/datapool-dependencies/pom.xml b/bom/datapool-dependencies/pom.xml index 2dfc93e2e..e8946c97e 100644 --- a/bom/datapool-dependencies/pom.xml +++ b/bom/datapool-dependencies/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.6 + 4.1.7-SNAPSHOT ../parent/pom.xml diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index b02f3bd4a..7b5c81fbf 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-root - 4.1.6 + 4.1.7-SNAPSHOT ../../pom.xml diff --git a/bom/taskpool-dependencies/pom.xml b/bom/taskpool-dependencies/pom.xml index 8938fa354..f31982d9d 100644 --- a/bom/taskpool-dependencies/pom.xml +++ b/bom/taskpool-dependencies/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.6 + 4.1.7-SNAPSHOT ../parent/pom.xml diff --git a/core/bus-jackson/pom.xml b/core/bus-jackson/pom.xml index 4de49c174..08b6b01f1 100755 --- a/core/bus-jackson/pom.xml +++ b/core/bus-jackson/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.6 + 4.1.7-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/datapool/datapool-api/pom.xml b/core/datapool/datapool-api/pom.xml index c79ccccbb..4af180a06 100755 --- a/core/datapool/datapool-api/pom.xml +++ b/core/datapool/datapool-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-datapool-api diff --git a/core/datapool/datapool-core/pom.xml b/core/datapool/datapool-core/pom.xml index fe35dc613..cc97f1432 100644 --- a/core/datapool/datapool-core/pom.xml +++ b/core/datapool/datapool-core/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-datapool-core diff --git a/core/datapool/datapool-event/pom.xml b/core/datapool/datapool-event/pom.xml index b64d8a95f..3f78846b1 100755 --- a/core/datapool/datapool-event/pom.xml +++ b/core/datapool/datapool-event/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-datapool-event diff --git a/core/datapool/pom.xml b/core/datapool/pom.xml index c03aac852..75eb0e22e 100755 --- a/core/datapool/pom.xml +++ b/core/datapool/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.6 + 4.1.7-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/spring-utils/pom.xml b/core/spring-utils/pom.xml index 8e19de3f0..3ef776bf2 100755 --- a/core/spring-utils/pom.xml +++ b/core/spring-utils/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.6 + 4.1.7-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/taskpool/pom.xml b/core/taskpool/pom.xml index 50f6b30ea..b26afe91c 100755 --- a/core/taskpool/pom.xml +++ b/core/taskpool/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.6 + 4.1.7-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/taskpool/taskpool-api/pom.xml b/core/taskpool/taskpool-api/pom.xml index c60eb7c66..4129ddfc0 100755 --- a/core/taskpool/taskpool-api/pom.xml +++ b/core/taskpool/taskpool-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-taskpool-api diff --git a/core/taskpool/taskpool-core/pom.xml b/core/taskpool/taskpool-core/pom.xml index 389f1d8db..99bea3ff5 100755 --- a/core/taskpool/taskpool-core/pom.xml +++ b/core/taskpool/taskpool-core/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-taskpool-core diff --git a/core/taskpool/taskpool-event/pom.xml b/core/taskpool/taskpool-event/pom.xml index 653f43eaf..1b9a3becc 100644 --- a/core/taskpool/taskpool-event/pom.xml +++ b/core/taskpool/taskpool-event/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-taskpool-event diff --git a/integration/camunda-bpm/engine-client/pom.xml b/integration/camunda-bpm/engine-client/pom.xml index eb982171e..c69678b6a 100644 --- a/integration/camunda-bpm/engine-client/pom.xml +++ b/integration/camunda-bpm/engine-client/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-camunda-bpm-engine-client diff --git a/integration/camunda-bpm/pom.xml b/integration/camunda-bpm/pom.xml index 8385d81e7..02276e234 100644 --- a/integration/camunda-bpm/pom.xml +++ b/integration/camunda-bpm/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.6 + 4.1.7-SNAPSHOT ../../bom/parent/pom.xml diff --git a/integration/camunda-bpm/springboot-autoconfigure/pom.xml b/integration/camunda-bpm/springboot-autoconfigure/pom.xml index 220adbdc1..f08f402fc 100755 --- a/integration/camunda-bpm/springboot-autoconfigure/pom.xml +++ b/integration/camunda-bpm/springboot-autoconfigure/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-camunda-bpm-springboot-autoconfigure diff --git a/integration/camunda-bpm/springboot-starter/pom.xml b/integration/camunda-bpm/springboot-starter/pom.xml index 0a9b2937b..5b308775d 100755 --- a/integration/camunda-bpm/springboot-starter/pom.xml +++ b/integration/camunda-bpm/springboot-starter/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-camunda-bpm-springboot-starter diff --git a/integration/camunda-bpm/taskpool-collector/pom.xml b/integration/camunda-bpm/taskpool-collector/pom.xml index 1b6b4565f..378367594 100755 --- a/integration/camunda-bpm/taskpool-collector/pom.xml +++ b/integration/camunda-bpm/taskpool-collector/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-camunda-bpm-taskpool-collector diff --git a/integration/camunda-bpm/taskpool-job-sender/pom.xml b/integration/camunda-bpm/taskpool-job-sender/pom.xml index 1a548d69e..b6604e2f1 100755 --- a/integration/camunda-bpm/taskpool-job-sender/pom.xml +++ b/integration/camunda-bpm/taskpool-job-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-camunda-bpm-taskpool-job-sender diff --git a/integration/common/datapool-sender/pom.xml b/integration/common/datapool-sender/pom.xml index 86fcc95a0..abd68ba0e 100755 --- a/integration/common/datapool-sender/pom.xml +++ b/integration/common/datapool-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-datapool-sender diff --git a/integration/common/pom.xml b/integration/common/pom.xml index 98d290a77..95f72d1c8 100755 --- a/integration/common/pom.xml +++ b/integration/common/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.6 + 4.1.7-SNAPSHOT ../../bom/parent/pom.xml diff --git a/integration/common/tasklist-url-resolver/pom.xml b/integration/common/tasklist-url-resolver/pom.xml index 864a09df0..e3cbd5a3f 100644 --- a/integration/common/tasklist-url-resolver/pom.xml +++ b/integration/common/tasklist-url-resolver/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-tasklist-url-resolver diff --git a/integration/common/taskpool-sender/pom.xml b/integration/common/taskpool-sender/pom.xml index 912f1cc30..6f8ecf39e 100755 --- a/integration/common/taskpool-sender/pom.xml +++ b/integration/common/taskpool-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-taskpool-sender diff --git a/integration/common/variable-serializer/pom.xml b/integration/common/variable-serializer/pom.xml index 1a798cfd9..28b2d1476 100755 --- a/integration/common/variable-serializer/pom.xml +++ b/integration/common/variable-serializer/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-variable-serializer diff --git a/pom.xml b/pom.xml index 2e654eddf..a17101a21 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-root - 4.1.6 + 4.1.7-SNAPSHOT pom POM: ${project.artifactId} diff --git a/view/form-url-resolver/pom.xml b/view/form-url-resolver/pom.xml index d0ffeed22..d8c897e6e 100644 --- a/view/form-url-resolver/pom.xml +++ b/view/form-url-resolver/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-form-url-resolver diff --git a/view/jpa/pom.xml b/view/jpa/pom.xml index d75623c36..c142683a8 100644 --- a/view/jpa/pom.xml +++ b/view/jpa/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-view-jpa diff --git a/view/mongo/pom.xml b/view/mongo/pom.xml index 764bc53e5..7c632893e 100644 --- a/view/mongo/pom.xml +++ b/view/mongo/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-view-mongo diff --git a/view/pom.xml b/view/pom.xml index f8c71c976..fe5423c2d 100644 --- a/view/pom.xml +++ b/view/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.6 + 4.1.7-SNAPSHOT ../bom/parent/pom.xml diff --git a/view/simple/pom.xml b/view/simple/pom.xml index 7168f27b8..af10601f0 100755 --- a/view/simple/pom.xml +++ b/view/simple/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-view-simple diff --git a/view/view-api-client/pom.xml b/view/view-api-client/pom.xml index fe9a0b589..d3c085825 100755 --- a/view/view-api-client/pom.xml +++ b/view/view-api-client/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-view-api-client diff --git a/view/view-api/pom.xml b/view/view-api/pom.xml index 9269d2f07..ce1180e20 100755 --- a/view/view-api/pom.xml +++ b/view/view-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.6 + 4.1.7-SNAPSHOT polyflow-view-api From aa0f7ab6470355424a3419684ca57ad667984937 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:45:02 +0000 Subject: [PATCH 02/13] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.5 to 3.3.0 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.3.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- bom/parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index 7b5c81fbf..c2f398afb 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -519,7 +519,7 @@ maven-surefire-plugin - 3.2.5 + 3.3.0 false random From 35e22ddf15d5a758800662a18d918722db7bf2a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:45:22 +0000 Subject: [PATCH 03/13] Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.2.5 to 3.3.0 Bumps [org.apache.maven.plugins:maven-failsafe-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.3.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- bom/parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index 7b5c81fbf..062a00bef 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -540,7 +540,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.2.5 + 3.3.0 From 66ac00ee443ff8f887fb92f025d5c35f3b68c4d1 Mon Sep 17 00:00:00 2001 From: Patrick Schalk Date: Tue, 18 Jun 2024 08:48:38 +0200 Subject: [PATCH 04/13] Use flyway provisioned db for all ITests where database is needed. (Disable of ddl-auto) #1000 (#1004) --- .../camunda-bpm/taskpool-collector/pom.xml | 5 + .../application-collector-tx-itest.yml | 27 +- .../application-txjob-sender-itest.yml | 25 +- .../V0_0_1__postgres_engine_7.21.0.sql | 1413 +++++++++++++++++ .../V0_0_2__postgres_identity_7.21.0.sql | 109 ++ 5 files changed, 1566 insertions(+), 13 deletions(-) create mode 100644 integration/camunda-bpm/taskpool-collector/src/test/resources/db/migrations/h2-postgresql/V0_0_1__postgres_engine_7.21.0.sql create mode 100644 integration/camunda-bpm/taskpool-collector/src/test/resources/db/migrations/h2-postgresql/V0_0_2__postgres_identity_7.21.0.sql diff --git a/integration/camunda-bpm/taskpool-collector/pom.xml b/integration/camunda-bpm/taskpool-collector/pom.xml index 378367594..46525f4cf 100755 --- a/integration/camunda-bpm/taskpool-collector/pom.xml +++ b/integration/camunda-bpm/taskpool-collector/pom.xml @@ -61,6 +61,11 @@ spring-boot-starter-test test + + org.flywaydb + flyway-core + test + org.camunda.community.mockito camunda-platform-7-mockito diff --git a/integration/camunda-bpm/taskpool-collector/src/test/resources/application-collector-tx-itest.yml b/integration/camunda-bpm/taskpool-collector/src/test/resources/application-collector-tx-itest.yml index f45aca788..ef7a57437 100644 --- a/integration/camunda-bpm/taskpool-collector/src/test/resources/application-collector-tx-itest.yml +++ b/integration/camunda-bpm/taskpool-collector/src/test/resources/application-collector-tx-itest.yml @@ -4,21 +4,32 @@ spring: open-in-view: true # disable JPA warning show-sql: true database-platform: org.hibernate.dialect.H2Dialect - generate-ddl: true - defer-datasource-initialization: true + generate-ddl: false hibernate: - ddl-auto: create-drop -# datasource: -# driver-class-name: org.h2.Driver -# url: jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 -# username: sa -# password: sa + ddl-auto: none + datasource: + # Explanation for the `random.uuid`: Spring caches application contexts for tests (see https://docs.spring.io/spring-framework/reference/testing/testcontext-framework/ctx-management/caching.html). + # If each context uses the same database, we can get a situation where context A is initialized, then context B is initialized and shut down, then context A is reused. But the + # shutdown of context B has destroyed (dropped the schema of) the shared database, so the second test using context A will find the database in an unexpected state and fails. + # Adding a random identifier to the database name ensures that each context gets its own database that it can initialize and tear down according to its own lifecycle. + url: jdbc:h2:mem:testdb-${random.uuid};MODE=PostgreSQL;INIT=create schema if not exists PUBLIC;DB_CLOSE_DELAY=-1;NON_KEYWORDS=VALUE;DB_CLOSE_ON_EXIT=FALSE + username: sa + password: sa + hikari: + connection-test-query: select 1 from dual; + schema: PUBLIC + driver-class-name: org.h2.Driver + flyway: + enabled: true + locations: "classpath:db/migrations/h2-postgresql" camunda: bpm: default-serialization-format: application/json history-level: full eventing: task: false + database: + schema-update: false polyflow: integration: diff --git a/integration/camunda-bpm/taskpool-collector/src/test/resources/application-txjob-sender-itest.yml b/integration/camunda-bpm/taskpool-collector/src/test/resources/application-txjob-sender-itest.yml index 2b0e97a03..a186ee8e1 100644 --- a/integration/camunda-bpm/taskpool-collector/src/test/resources/application-txjob-sender-itest.yml +++ b/integration/camunda-bpm/taskpool-collector/src/test/resources/application-txjob-sender-itest.yml @@ -3,17 +3,32 @@ spring: jpa: open-in-view: true # disable JPA warning show-sql: true - database-platform: org.hibernate.dialect.H2Dialect - generate-ddl: true - defer-datasource-initialization: true - hibernate: - ddl-auto: create-drop + database-platform: io.holunda.polyflow.view.jpa.itest.FixedH2Dialect + generate-ddl: false + hibernate.ddl-auto: none + datasource: + # Explanation for the `random.uuid`: Spring caches application contexts for tests (see https://docs.spring.io/spring-framework/reference/testing/testcontext-framework/ctx-management/caching.html). + # If each context uses the same database, we can get a situation where context A is initialized, then context B is initialized and shut down, then context A is reused. But the + # shutdown of context B has destroyed (dropped the schema of) the shared database, so the second test using context A will find the database in an unexpected state and fails. + # Adding a random identifier to the database name ensures that each context gets its own database that it can initialize and tear down according to its own lifecycle. + url: jdbc:h2:mem:testdb-${random.uuid};MODE=PostgreSQL;INIT=create schema if not exists PUBLIC;DB_CLOSE_DELAY=-1;NON_KEYWORDS=VALUE;DB_CLOSE_ON_EXIT=FALSE + username: sa + password: sa + hikari: + connection-test-query: select 1 from dual; + schema: PUBLIC + driver-class-name: org.h2.Driver + flyway: + enabled: true + locations: "classpath:db/migrations/h2-postgresql" camunda: bpm: default-serialization-format: application/json history-level: full eventing: task: false + database: + schema-update: false polyflow: integration: diff --git a/integration/camunda-bpm/taskpool-collector/src/test/resources/db/migrations/h2-postgresql/V0_0_1__postgres_engine_7.21.0.sql b/integration/camunda-bpm/taskpool-collector/src/test/resources/db/migrations/h2-postgresql/V0_0_1__postgres_engine_7.21.0.sql new file mode 100644 index 000000000..bed33d64e --- /dev/null +++ b/integration/camunda-bpm/taskpool-collector/src/test/resources/db/migrations/h2-postgresql/V0_0_1__postgres_engine_7.21.0.sql @@ -0,0 +1,1413 @@ +-- +-- Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH +-- under one or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information regarding copyright +-- ownership. Camunda licenses this file to you under the Apache License, +-- Version 2.0; you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +create table ACT_GE_PROPERTY ( + NAME_ varchar(64), + VALUE_ varchar(300), + REV_ integer, + primary key (NAME_) +); + +insert into ACT_GE_PROPERTY +values ('schema.version', 'fox', 1); + +insert into ACT_GE_PROPERTY +values ('schema.history', 'create(fox)', 1); + +insert into ACT_GE_PROPERTY +values ('next.dbid', '1', 1); + +insert into ACT_GE_PROPERTY +values ('deployment.lock', '0', 1); + +insert into ACT_GE_PROPERTY +values ('history.cleanup.job.lock', '0', 1); + +insert into ACT_GE_PROPERTY +values ('startup.lock', '0', 1); + +insert into ACT_GE_PROPERTY +values ('telemetry.lock', '0', 1); + +insert into ACT_GE_PROPERTY +values ('installationId.lock', '0', 1); + +create table ACT_GE_BYTEARRAY ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + BYTES_ bytea, + GENERATED_ boolean, + TENANT_ID_ varchar(64), + TYPE_ integer, + CREATE_TIME_ timestamp, + ROOT_PROC_INST_ID_ varchar(64), + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +create table ACT_GE_SCHEMA_LOG ( + ID_ varchar(64), + TIMESTAMP_ timestamp, + VERSION_ varchar(255), + primary key (ID_) +); + +insert into ACT_GE_SCHEMA_LOG +values ('0', CURRENT_TIMESTAMP, '7.21.0'); + +create table ACT_RE_DEPLOYMENT ( + ID_ varchar(64), + NAME_ varchar(255), + DEPLOY_TIME_ timestamp, + SOURCE_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RU_EXECUTION ( + ID_ varchar(64), + REV_ integer, + ROOT_PROC_INST_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + SUPER_EXEC_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + IS_ACTIVE_ boolean, + IS_CONCURRENT_ boolean, + IS_SCOPE_ boolean, + IS_EVENT_SCOPE_ boolean, + SUSPENSION_STATE_ integer, + CACHED_ENT_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RU_JOB ( + ID_ varchar(64) NOT NULL, + REV_ integer, + TYPE_ varchar(255) NOT NULL, + LOCK_EXP_TIME_ timestamp, + LOCK_OWNER_ varchar(255), + EXCLUSIVE_ boolean, + EXECUTION_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + RETRIES_ integer, + EXCEPTION_STACK_ID_ varchar(64), + EXCEPTION_MSG_ varchar(4000), + FAILED_ACT_ID_ varchar(255), + DUEDATE_ timestamp, + REPEAT_ varchar(255), + REPEAT_OFFSET_ bigint DEFAULT 0, + HANDLER_TYPE_ varchar(255), + HANDLER_CFG_ varchar(4000), + DEPLOYMENT_ID_ varchar(64), + SUSPENSION_STATE_ integer NOT NULL DEFAULT 1, + JOB_DEF_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + CREATE_TIME_ timestamp, + LAST_FAILURE_LOG_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RU_JOBDEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + JOB_TYPE_ varchar(255) NOT NULL, + JOB_CONFIGURATION_ varchar(255), + SUSPENSION_STATE_ integer, + JOB_PRIORITY_ bigint, + TENANT_ID_ varchar(64), + DEPLOYMENT_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RE_PROCDEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) NOT NULL, + VERSION_ integer NOT NULL, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + HAS_START_FORM_KEY_ boolean, + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + VERSION_TAG_ varchar(64), + HISTORY_TTL_ integer, + STARTABLE_ boolean NOT NULL default TRUE, + primary key (ID_) +); + +create table ACT_RE_CAMFORMDEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + KEY_ varchar(255) NOT NULL, + VERSION_ integer NOT NULL, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RU_TASK ( + ID_ varchar(64), + REV_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + TASK_DEF_KEY_ varchar(255), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + DELEGATION_ varchar(64), + PRIORITY_ integer, + CREATE_TIME_ timestamp, + LAST_UPDATED_ timestamp, + DUE_DATE_ timestamp, + FOLLOW_UP_DATE_ timestamp, + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RU_IDENTITYLINK ( + ID_ varchar(64), + REV_ integer, + GROUP_ID_ varchar(255), + TYPE_ varchar(255), + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar (64), + TENANT_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RU_VARIABLE ( + ID_ varchar(64) not null, + REV_ integer, + TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + TASK_ID_ varchar(64), + BATCH_ID_ varchar(64), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double precision, + LONG_ bigint, + TEXT_ varchar(4000), + TEXT2_ varchar(4000), + VAR_SCOPE_ varchar(64), + SEQUENCE_COUNTER_ bigint, + IS_CONCURRENT_LOCAL_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RU_EVENT_SUBSCR ( + ID_ varchar(64) not null, + REV_ integer, + EVENT_TYPE_ varchar(255) not null, + EVENT_NAME_ varchar(255), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + CONFIGURATION_ varchar(255), + CREATED_ timestamp not null, + TENANT_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RU_INCIDENT ( + ID_ varchar(64) not null, + REV_ integer not null, + INCIDENT_TIMESTAMP_ timestamp not null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + FAILED_ACTIVITY_ID_ varchar(255), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + ANNOTATION_ varchar(4000), + primary key (ID_) +); + +create table ACT_RU_AUTHORIZATION ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ integer not null, + GROUP_ID_ varchar(255), + USER_ID_ varchar(255), + RESOURCE_TYPE_ integer not null, + RESOURCE_ID_ varchar(255), + PERMS_ integer, + REMOVAL_TIME_ timestamp, + ROOT_PROC_INST_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RU_FILTER ( + ID_ varchar(64) not null, + REV_ integer not null, + RESOURCE_TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + OWNER_ varchar(255), + QUERY_ TEXT not null, + PROPERTIES_ TEXT, + primary key (ID_) +); + +create table ACT_RU_METER_LOG ( + ID_ varchar(64) not null, + NAME_ varchar(64) not null, + REPORTER_ varchar(255), + VALUE_ bigint, + TIMESTAMP_ timestamp, + MILLISECONDS_ bigint DEFAULT 0, + primary key (ID_) +); + +create table ACT_RU_TASK_METER_LOG ( + ID_ varchar(64) not null, + ASSIGNEE_HASH_ bigint, + TIMESTAMP_ timestamp, + primary key (ID_) +); + +create table ACT_RU_EXT_TASK ( + ID_ varchar(64) not null, + REV_ integer not null, + WORKER_ID_ varchar(255), + TOPIC_NAME_ varchar(255), + RETRIES_ integer, + ERROR_MSG_ varchar(4000), + ERROR_DETAILS_ID_ varchar(64), + LOCK_EXP_TIME_ timestamp, + CREATE_TIME_ timestamp, + SUSPENSION_STATE_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + TENANT_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + LAST_FAILURE_LOG_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_RU_BATCH ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_CREATED_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + SUSPENSION_STATE_ integer, + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + CREATE_USER_ID_ varchar(255), + START_TIME_ timestamp, + EXEC_START_TIME_ timestamp, + primary key (ID_) +); + +create index ACT_IDX_EXE_ROOT_PI on ACT_RU_EXECUTION(ROOT_PROC_INST_ID_); +create index ACT_IDX_EXEC_BUSKEY on ACT_RU_EXECUTION(BUSINESS_KEY_); +create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_); +create index ACT_IDX_TASK_CREATE on ACT_RU_TASK(CREATE_TIME_); +create index ACT_IDX_TASK_LAST_UPDATED on ACT_RU_TASK(LAST_UPDATED_); +create index ACT_IDX_TASK_ASSIGNEE on ACT_RU_TASK(ASSIGNEE_); +create index ACT_IDX_TASK_OWNER on ACT_RU_TASK(OWNER_); +create index ACT_IDX_TASK_TENANT_ID on ACT_RU_TASK(TENANT_ID_); +create index ACT_IDX_IDENT_LNK_USER on ACT_RU_IDENTITYLINK(USER_ID_); +create index ACT_IDX_IDENT_LNK_GROUP on ACT_RU_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_EVENT_SUBSCR_CONFIG_ on ACT_RU_EVENT_SUBSCR(CONFIGURATION_); +create index ACT_IDX_EVENT_SUBSCR_TENANT_ID on ACT_RU_EVENT_SUBSCR(TENANT_ID_); + +create index ACT_IDX_VARIABLE_TASK_ID on ACT_RU_VARIABLE(TASK_ID_); +create index ACT_IDX_VARIABLE_TENANT_ID on ACT_RU_VARIABLE(TENANT_ID_); +create index ACT_IDX_VARIABLE_TASK_NAME_TYPE on ACT_RU_VARIABLE(TASK_ID_, NAME_, TYPE_); + +create index ACT_IDX_INC_CONFIGURATION on ACT_RU_INCIDENT(CONFIGURATION_); +create index ACT_IDX_INC_TENANT_ID on ACT_RU_INCIDENT(TENANT_ID_); +-- CAM-5914 +create index ACT_IDX_JOB_EXECUTION_ID on ACT_RU_JOB(EXECUTION_ID_); +create index ACT_IDX_JOB_HANDLER on ACT_RU_JOB(HANDLER_TYPE_,HANDLER_CFG_); +create index ACT_IDX_JOB_PROCINST on ACT_RU_JOB(PROCESS_INSTANCE_ID_); +create index ACT_IDX_JOB_ROOT_PROCINST on ACT_RU_JOB(ROOT_PROC_INST_ID_); +create index ACT_IDX_JOB_TENANT_ID on ACT_RU_JOB(TENANT_ID_); +create index ACT_IDX_JOBDEF_TENANT_ID on ACT_RU_JOBDEF(TENANT_ID_); + +-- new metric milliseconds column +CREATE INDEX ACT_IDX_METER_LOG_MS ON ACT_RU_METER_LOG(MILLISECONDS_); +CREATE INDEX ACT_IDX_METER_LOG_NAME_MS ON ACT_RU_METER_LOG(NAME_, MILLISECONDS_); +CREATE INDEX ACT_IDX_METER_LOG_REPORT ON ACT_RU_METER_LOG(NAME_, REPORTER_, MILLISECONDS_); + +-- old metric timestamp column +CREATE INDEX ACT_IDX_METER_LOG_TIME ON ACT_RU_METER_LOG(TIMESTAMP_); +CREATE INDEX ACT_IDX_METER_LOG ON ACT_RU_METER_LOG(NAME_, TIMESTAMP_); + +-- task metric timestamp column +CREATE INDEX ACT_IDX_TASK_METER_LOG_TIME ON ACT_RU_TASK_METER_LOG(TIMESTAMP_); + +create index ACT_IDX_EXT_TASK_TOPIC on ACT_RU_EXT_TASK(TOPIC_NAME_); +create index ACT_IDX_EXT_TASK_TENANT_ID on ACT_RU_EXT_TASK(TENANT_ID_); +create index ACT_IDX_EXT_TASK_PRIORITY ON ACT_RU_EXT_TASK(PRIORITY_); +create index ACT_IDX_EXT_TASK_ERR_DETAILS ON ACT_RU_EXT_TASK(ERROR_DETAILS_ID_); +create index ACT_IDX_AUTH_GROUP_ID on ACT_RU_AUTHORIZATION(GROUP_ID_); +create index ACT_IDX_JOB_JOB_DEF_ID on ACT_RU_JOB(JOB_DEF_ID_); + +create index ACT_IDX_BYTEAR_DEPL on ACT_GE_BYTEARRAY(DEPLOYMENT_ID_); +alter table ACT_GE_BYTEARRAY + add constraint ACT_FK_BYTEARR_DEPL + foreign key (DEPLOYMENT_ID_) + references ACT_RE_DEPLOYMENT (ID_); + +create index ACT_IDX_EXE_PROCINST on ACT_RU_EXECUTION(PROC_INST_ID_); +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_EXE_PARENT on ACT_RU_EXECUTION(PARENT_ID_); +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_EXE_SUPER on ACT_RU_EXECUTION(SUPER_EXEC_); +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_SUPER + foreign key (SUPER_EXEC_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_EXE_PROCDEF on ACT_RU_EXECUTION(PROC_DEF_ID_); +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + + +create index ACT_IDX_TSKASS_TASK on ACT_RU_IDENTITYLINK(TASK_ID_); +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_TSKASS_TASK + foreign key (TASK_ID_) + references ACT_RU_TASK (ID_); + +create index ACT_IDX_ATHRZ_PROCEDEF on ACT_RU_IDENTITYLINK(PROC_DEF_ID_); +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_ATHRZ_PROCEDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +create index ACT_IDX_TASK_EXEC on ACT_RU_TASK(EXECUTION_ID_); +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_TASK_PROCINST on ACT_RU_TASK(PROC_INST_ID_); +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_TASK_PROCDEF on ACT_RU_TASK(PROC_DEF_ID_); +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +create index ACT_IDX_VAR_EXE on ACT_RU_VARIABLE(EXECUTION_ID_); +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_VAR_PROCINST on ACT_RU_VARIABLE(PROC_INST_ID_); +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION(ID_); + +create index ACT_IDX_VAR_BYTEARRAY on ACT_RU_VARIABLE(BYTEARRAY_ID_); +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_BYTEARRAY + foreign key (BYTEARRAY_ID_) + references ACT_GE_BYTEARRAY (ID_); + +create index ACT_IDX_JOB_EXCEPTION on ACT_RU_JOB(EXCEPTION_STACK_ID_); +alter table ACT_RU_JOB + add constraint ACT_FK_JOB_EXCEPTION + foreign key (EXCEPTION_STACK_ID_) + references ACT_GE_BYTEARRAY (ID_); + +create index ACT_IDX_EVENT_SUBSCR on ACT_RU_EVENT_SUBSCR(EXECUTION_ID_); +alter table ACT_RU_EVENT_SUBSCR + add constraint ACT_FK_EVENT_EXEC + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_CAUSE + foreign key (CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_RCAUSE + foreign key (ROOT_CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_); + +create index ACT_IDX_INC_JOB_DEF on ACT_RU_INCIDENT(JOB_DEF_ID_); +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_JOB_DEF + foreign key (JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_USER + unique (TYPE_,USER_ID_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_GROUP + unique (TYPE_,GROUP_ID_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_UNIQ_VARIABLE + unique (VAR_SCOPE_, NAME_); + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_BATCH_SEED_JOB_DEF ON ACT_RU_BATCH(SEED_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_SEED_JOB_DEF + foreign key (SEED_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_MONITOR_JOB_DEF ON ACT_RU_BATCH(MONITOR_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_MONITOR_JOB_DEF + foreign key (MONITOR_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_JOB_DEF ON ACT_RU_BATCH(BATCH_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_JOB_DEF + foreign key (BATCH_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_ERROR_DETAILS + foreign key (ERROR_DETAILS_ID_) + references ACT_GE_BYTEARRAY (ID_); + +create index ACT_IDX_BATCH_ID ON ACT_RU_VARIABLE(BATCH_ID_); +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_BATCH + foreign key (BATCH_ID_) + references ACT_RU_BATCH (ID_); + +-- indexes for deadlock problems - https://app.camunda.com/jira/browse/CAM-2567 -- +create index ACT_IDX_INC_CAUSEINCID on ACT_RU_INCIDENT(CAUSE_INCIDENT_ID_); +create index ACT_IDX_INC_EXID on ACT_RU_INCIDENT(EXECUTION_ID_); +create index ACT_IDX_INC_PROCDEFID on ACT_RU_INCIDENT(PROC_DEF_ID_); +create index ACT_IDX_INC_PROCINSTID on ACT_RU_INCIDENT(PROC_INST_ID_); +create index ACT_IDX_INC_ROOTCAUSEINCID on ACT_RU_INCIDENT(ROOT_CAUSE_INCIDENT_ID_); +-- index for deadlock problem - https://app.camunda.com/jira/browse/CAM-4440 -- +create index ACT_IDX_AUTH_RESOURCE_ID on ACT_RU_AUTHORIZATION(RESOURCE_ID_); +-- index to prevent deadlock on fk constraint - https://app.camunda.com/jira/browse/CAM-5440 -- +create index ACT_IDX_EXT_TASK_EXEC on ACT_RU_EXT_TASK(EXECUTION_ID_); + +-- indexes to improve deployment +create index ACT_IDX_BYTEARRAY_ROOT_PI on ACT_GE_BYTEARRAY(ROOT_PROC_INST_ID_); +create index ACT_IDX_BYTEARRAY_RM_TIME on ACT_GE_BYTEARRAY(REMOVAL_TIME_); +create index ACT_IDX_BYTEARRAY_NAME on ACT_GE_BYTEARRAY(NAME_); +create index ACT_IDX_DEPLOYMENT_NAME on ACT_RE_DEPLOYMENT(NAME_); +create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_); +create index ACT_IDX_JOBDEF_PROC_DEF_ID ON ACT_RU_JOBDEF(PROC_DEF_ID_); +create index ACT_IDX_JOB_HANDLER_TYPE ON ACT_RU_JOB(HANDLER_TYPE_); +create index ACT_IDX_EVENT_SUBSCR_EVT_NAME ON ACT_RU_EVENT_SUBSCR(EVENT_NAME_); +create index ACT_IDX_PROCDEF_DEPLOYMENT_ID ON ACT_RE_PROCDEF(DEPLOYMENT_ID_); +create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_); +create index ACT_IDX_PROCDEF_VER_TAG ON ACT_RE_PROCDEF(VERSION_TAG_); + +-- indices for history cleanup: https://jira.camunda.com/browse/CAM-11616 +create index ACT_IDX_AUTH_ROOT_PI on ACT_RU_AUTHORIZATION(ROOT_PROC_INST_ID_); +create index ACT_IDX_AUTH_RM_TIME on ACT_RU_AUTHORIZATION(REMOVAL_TIME_); +-- +-- Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH +-- under one or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information regarding copyright +-- ownership. Camunda licenses this file to you under the Apache License, +-- Version 2.0; you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +-- create case definition table -- + +create table ACT_RE_CASE_DEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) NOT NULL, + VERSION_ integer NOT NULL, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + HISTORY_TTL_ integer, + primary key (ID_) +); + +-- create case execution table -- + +create table ACT_RU_CASE_EXECUTION ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + SUPER_EXEC_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + ACT_ID_ varchar(255), + PREV_STATE_ integer, + CURRENT_STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +); + +-- create case sentry part table -- + +create table ACT_RU_CASE_SENTRY_PART ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + CASE_EXEC_ID_ varchar(64), + SENTRY_ID_ varchar(255), + TYPE_ varchar(255), + SOURCE_CASE_EXEC_ID_ varchar(64), + STANDARD_EVENT_ varchar(255), + SOURCE_ varchar(255), + VARIABLE_EVENT_ varchar(255), + VARIABLE_NAME_ varchar(255), + SATISFIED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +); + +-- create index on business key -- +create index ACT_IDX_CASE_EXEC_BUSKEY on ACT_RU_CASE_EXECUTION(BUSINESS_KEY_); + +-- create foreign key constraints on ACT_RU_CASE_EXECUTION -- +create index ACT_IDX_CASE_EXE_CASE_INST on ACT_RU_CASE_EXECUTION(CASE_INST_ID_); +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_CASE_EXE_PARENT on ACT_RU_CASE_EXECUTION(PARENT_ID_); +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_CASE_EXE_CASE_DEF on ACT_RU_CASE_EXECUTION(CASE_DEF_ID_); +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_VARIABLE -- +create index ACT_IDX_VAR_CASE_EXE on ACT_RU_VARIABLE(CASE_EXECUTION_ID_); +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_VAR_CASE_INST_ID on ACT_RU_VARIABLE(CASE_INST_ID_); +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +-- create foreign key constraints on ACT_RU_TASK -- +create index ACT_IDX_TASK_CASE_EXEC on ACT_RU_TASK(CASE_EXECUTION_ID_); +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_TASK_CASE_DEF_ID on ACT_RU_TASK(CASE_DEF_ID_); +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_CASE_SENTRY_PART -- +create index ACT_IDX_CASE_SENTRY_CASE_INST on ACT_RU_CASE_SENTRY_PART(CASE_INST_ID_); +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_CASE_SENTRY_CASE_EXEC on ACT_RU_CASE_SENTRY_PART(CASE_EXEC_ID_); +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_EXEC + foreign key (CASE_EXEC_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_CASE_DEF_TENANT_ID on ACT_RE_CASE_DEF(TENANT_ID_); +create index ACT_IDX_CASE_EXEC_TENANT_ID on ACT_RU_CASE_EXECUTION(TENANT_ID_); +-- +-- Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH +-- under one or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information regarding copyright +-- ownership. Camunda licenses this file to you under the Apache License, +-- Version 2.0; you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +-- create decision definition table -- +create table ACT_RE_DECISION_DEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) NOT NULL, + VERSION_ integer NOT NULL, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + DEC_REQ_ID_ varchar(64), + DEC_REQ_KEY_ varchar(255), + TENANT_ID_ varchar(64), + HISTORY_TTL_ integer, + VERSION_TAG_ varchar(64), + primary key (ID_) +); + +-- create decision requirements definition table -- +create table ACT_RE_DECISION_REQ_DEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) NOT NULL, + VERSION_ integer NOT NULL, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +); + +alter table ACT_RE_DECISION_DEF + add constraint ACT_FK_DEC_REQ + foreign key (DEC_REQ_ID_) + references ACT_RE_DECISION_REQ_DEF(ID_); + +create index ACT_IDX_DEC_DEF_TENANT_ID on ACT_RE_DECISION_DEF(TENANT_ID_); +create index ACT_IDX_DEC_DEF_REQ_ID on ACT_RE_DECISION_DEF(DEC_REQ_ID_); +create index ACT_IDX_DEC_REQ_DEF_TENANT_ID on ACT_RE_DECISION_REQ_DEF(TENANT_ID_); +-- +-- Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH +-- under one or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information regarding copyright +-- ownership. Camunda licenses this file to you under the Apache License, +-- Version 2.0; you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +create table ACT_HI_PROCINST ( + ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + START_TIME_ timestamp not null, + END_TIME_ timestamp, + REMOVAL_TIME_ timestamp, + DURATION_ bigint, + START_USER_ID_ varchar(255), + START_ACT_ID_ varchar(255), + END_ACT_ID_ varchar(255), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + SUPER_CASE_INSTANCE_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + DELETE_REASON_ varchar(4000), + TENANT_ID_ varchar(64), + STATE_ varchar(255), + primary key (ID_), + unique (PROC_INST_ID_) +); + +create table ACT_HI_ACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + ROOT_PROC_INST_ID_ varchar(64), + PROC_INST_ID_ varchar(64) not null, + EXECUTION_ID_ varchar(64) not null, + ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + ACT_NAME_ varchar(255), + ACT_TYPE_ varchar(255) not null, + ASSIGNEE_ varchar(255), + START_TIME_ timestamp not null, + END_TIME_ timestamp, + DURATION_ bigint, + ACT_INST_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +create table ACT_HI_TASKINST ( + ID_ varchar(64) not null, + TASK_DEF_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + START_TIME_ timestamp not null, + END_TIME_ timestamp, + DURATION_ bigint, + DELETE_REASON_ varchar(4000), + PRIORITY_ integer, + DUE_DATE_ timestamp, + FOLLOW_UP_DATE_ timestamp, + TENANT_ID_ varchar(64), + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +create table ACT_HI_VARINST ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(100), + CREATE_TIME_ timestamp, + REV_ integer, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double precision, + LONG_ bigint, + TEXT_ varchar(4000), + TEXT2_ varchar(4000), + TENANT_ID_ varchar(64), + STATE_ varchar(20), + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +create table ACT_HI_DETAIL ( + ID_ varchar(64) not null, + TYPE_ varchar(255) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + VAR_INST_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(64), + REV_ integer, + TIME_ timestamp not null, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double precision, + LONG_ bigint, + TEXT_ varchar(4000), + TEXT2_ varchar(4000), + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + OPERATION_ID_ varchar(64), + REMOVAL_TIME_ timestamp, + INITIAL_ boolean, + primary key (ID_) +); + +create table ACT_HI_IDENTITYLINK ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp not null, + TYPE_ varchar(255), + USER_ID_ varchar(255), + GROUP_ID_ varchar(255), + TASK_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + OPERATION_TYPE_ varchar(64), + ASSIGNER_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +create table ACT_HI_COMMENT ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TIME_ timestamp not null, + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTION_ varchar(255), + MESSAGE_ varchar(4000), + FULL_MSG_ bytea, + TENANT_ID_ varchar(64), + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +create table ACT_HI_ATTACHMENT ( + ID_ varchar(64) not null, + REV_ integer, + USER_ID_ varchar(255), + NAME_ varchar(255), + DESCRIPTION_ varchar(4000), + TYPE_ varchar(255), + TASK_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + URL_ varchar(4000), + CONTENT_ID_ varchar(64), + TENANT_ID_ varchar(64), + CREATE_TIME_ timestamp, + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +create table ACT_HI_OP_LOG ( + ID_ varchar(64) not null, + DEPLOYMENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ROOT_PROC_INST_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + JOB_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + BATCH_ID_ varchar(64), + USER_ID_ varchar(255), + TIMESTAMP_ timestamp not null, + OPERATION_TYPE_ varchar(64), + OPERATION_ID_ varchar(64), + ENTITY_TYPE_ varchar(30), + PROPERTY_ varchar(64), + ORG_VALUE_ varchar(4000), + NEW_VALUE_ varchar(4000), + TENANT_ID_ varchar(64), + REMOVAL_TIME_ timestamp, + CATEGORY_ varchar(64), + EXTERNAL_TASK_ID_ varchar(64), + ANNOTATION_ varchar(4000), + primary key (ID_) +); + +create table ACT_HI_INCIDENT ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CREATE_TIME_ timestamp not null, + END_TIME_ timestamp, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + ACTIVITY_ID_ varchar(255), + FAILED_ACTIVITY_ID_ varchar(255), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + HISTORY_CONFIGURATION_ varchar(255), + INCIDENT_STATE_ integer, + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + ANNOTATION_ varchar(4000), + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +create table ACT_HI_JOB_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp not null, + JOB_ID_ varchar(64) not null, + JOB_DUEDATE_ timestamp, + JOB_RETRIES_ integer, + JOB_PRIORITY_ bigint NOT NULL DEFAULT 0, + JOB_EXCEPTION_MSG_ varchar(4000), + JOB_EXCEPTION_STACK_ID_ varchar(64), + JOB_STATE_ integer, + JOB_DEF_ID_ varchar(64), + JOB_DEF_TYPE_ varchar(255), + JOB_DEF_CONFIGURATION_ varchar(255), + ACT_ID_ varchar(255), + FAILED_ACT_ID_ varchar(255), + EXECUTION_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + HOSTNAME_ varchar(255), + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +create table ACT_HI_BATCH ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + CREATE_USER_ID_ varchar(255), + START_TIME_ timestamp not null, + END_TIME_ timestamp, + REMOVAL_TIME_ timestamp, + EXEC_START_TIME_ timestamp, + primary key (ID_) +); + +create table ACT_HI_EXT_TASK_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp not null, + EXT_TASK_ID_ varchar(64) not null, + RETRIES_ integer, + TOPIC_NAME_ varchar(255), + WORKER_ID_ varchar(255), + PRIORITY_ bigint not null default 0, + ERROR_MSG_ varchar(4000), + ERROR_DETAILS_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + STATE_ integer, + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +create index ACT_IDX_HI_PRO_INST_END on ACT_HI_PROCINST(END_TIME_); +create index ACT_IDX_HI_PRO_I_BUSKEY on ACT_HI_PROCINST(BUSINESS_KEY_); +create index ACT_IDX_HI_PRO_INST_TENANT_ID on ACT_HI_PROCINST(TENANT_ID_); +create index ACT_IDX_HI_PRO_INST_PROC_DEF_KEY on ACT_HI_PROCINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_PRO_INST_PROC_TIME on ACT_HI_PROCINST(START_TIME_, END_TIME_); +create index ACT_IDX_HI_PI_PDEFID_END_TIME on ACT_HI_PROCINST(PROC_DEF_ID_, END_TIME_); +create index ACT_IDX_HI_PRO_INST_ROOT_PI on ACT_HI_PROCINST(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_PRO_INST_RM_TIME on ACT_HI_PROCINST(REMOVAL_TIME_); + +create index ACT_IDX_HI_ACTINST_ROOT_PI on ACT_HI_ACTINST(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_ACT_INST_START_END on ACT_HI_ACTINST(START_TIME_, END_TIME_); +create index ACT_IDX_HI_ACT_INST_END on ACT_HI_ACTINST(END_TIME_); +create index ACT_IDX_HI_ACT_INST_PROCINST on ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_); +create index ACT_IDX_HI_ACT_INST_COMP on ACT_HI_ACTINST(EXECUTION_ID_, ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_ACT_INST_STATS on ACT_HI_ACTINST(PROC_DEF_ID_, PROC_INST_ID_, ACT_ID_, END_TIME_, ACT_INST_STATE_); +create index ACT_IDX_HI_ACT_INST_TENANT_ID on ACT_HI_ACTINST(TENANT_ID_); +create index ACT_IDX_HI_ACT_INST_PROC_DEF_KEY on ACT_HI_ACTINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_AI_PDEFID_END_TIME on ACT_HI_ACTINST(PROC_DEF_ID_, END_TIME_); +create index ACT_IDX_HI_ACT_INST_RM_TIME on ACT_HI_ACTINST(REMOVAL_TIME_); + +create index ACT_IDX_HI_TASKINST_ROOT_PI on ACT_HI_TASKINST(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_TASK_INST_TENANT_ID on ACT_HI_TASKINST(TENANT_ID_); +create index ACT_IDX_HI_TASK_INST_PROC_DEF_KEY on ACT_HI_TASKINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_TASKINST_PROCINST on ACT_HI_TASKINST(PROC_INST_ID_); +create index ACT_IDX_HI_TASKINSTID_PROCINST on ACT_HI_TASKINST(ID_,PROC_INST_ID_); +create index ACT_IDX_HI_TASK_INST_RM_TIME on ACT_HI_TASKINST(REMOVAL_TIME_); +create index ACT_IDX_HI_TASK_INST_START on ACT_HI_TASKINST(START_TIME_); +create index ACT_IDX_HI_TASK_INST_END on ACT_HI_TASKINST(END_TIME_); + +create index ACT_IDX_HI_DETAIL_ROOT_PI on ACT_HI_DETAIL(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_DETAIL_PROC_INST on ACT_HI_DETAIL(PROC_INST_ID_); +create index ACT_IDX_HI_DETAIL_ACT_INST on ACT_HI_DETAIL(ACT_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_INST on ACT_HI_DETAIL(CASE_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_EXEC on ACT_HI_DETAIL(CASE_EXECUTION_ID_); +create index ACT_IDX_HI_DETAIL_TIME on ACT_HI_DETAIL(TIME_); +create index ACT_IDX_HI_DETAIL_NAME on ACT_HI_DETAIL(NAME_); +create index ACT_IDX_HI_DETAIL_TASK_ID on ACT_HI_DETAIL(TASK_ID_); +create index ACT_IDX_HI_DETAIL_TENANT_ID on ACT_HI_DETAIL(TENANT_ID_); +create index ACT_IDX_HI_DETAIL_PROC_DEF_KEY on ACT_HI_DETAIL(PROC_DEF_KEY_); +create index ACT_IDX_HI_DETAIL_BYTEAR on ACT_HI_DETAIL(BYTEARRAY_ID_); +create index ACT_IDX_HI_DETAIL_RM_TIME on ACT_HI_DETAIL(REMOVAL_TIME_); +create index ACT_IDX_HI_DETAIL_TASK_BYTEAR on ACT_HI_DETAIL(BYTEARRAY_ID_, TASK_ID_); +create index ACT_IDX_HI_DETAIL_VAR_INST_ID on ACT_HI_DETAIL(VAR_INST_ID_); + +create index ACT_IDX_HI_IDENT_LNK_ROOT_PI on ACT_HI_IDENTITYLINK(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_IDENT_LNK_USER on ACT_HI_IDENTITYLINK(USER_ID_); +create index ACT_IDX_HI_IDENT_LNK_GROUP on ACT_HI_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_HI_IDENT_LNK_TENANT_ID on ACT_HI_IDENTITYLINK(TENANT_ID_); +create index ACT_IDX_HI_IDENT_LNK_PROC_DEF_KEY on ACT_HI_IDENTITYLINK(PROC_DEF_KEY_); +create index ACT_IDX_HI_IDENT_LINK_TASK on ACT_HI_IDENTITYLINK(TASK_ID_); +create index ACT_IDX_HI_IDENT_LINK_RM_TIME on ACT_HI_IDENTITYLINK(REMOVAL_TIME_); +create index ACT_IDX_HI_IDENT_LNK_TIMESTAMP on ACT_HI_IDENTITYLINK(TIMESTAMP_); + +create index ACT_IDX_HI_VARINST_ROOT_PI on ACT_HI_VARINST(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_PROCVAR_PROC_INST on ACT_HI_VARINST(PROC_INST_ID_); +create index ACT_IDX_HI_PROCVAR_NAME_TYPE on ACT_HI_VARINST(NAME_, VAR_TYPE_); +create index ACT_IDX_HI_CASEVAR_CASE_INST on ACT_HI_VARINST(CASE_INST_ID_); +create index ACT_IDX_HI_VAR_INST_TENANT_ID on ACT_HI_VARINST(TENANT_ID_); +create index ACT_IDX_HI_VAR_INST_PROC_DEF_KEY on ACT_HI_VARINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_VARINST_BYTEAR on ACT_HI_VARINST(BYTEARRAY_ID_); +create index ACT_IDX_HI_VARINST_RM_TIME on ACT_HI_VARINST(REMOVAL_TIME_); +create index ACT_IDX_HI_VAR_PI_NAME_TYPE on ACT_HI_VARINST(PROC_INST_ID_, NAME_, VAR_TYPE_); +create index ACT_IDX_HI_VARINST_NAME on ACT_HI_VARINST(NAME_); +create index ACT_IDX_HI_VARINST_ACT_INST_ID on ACT_HI_VARINST(ACT_INST_ID_); + +create index ACT_IDX_HI_INCIDENT_TENANT_ID on ACT_HI_INCIDENT(TENANT_ID_); +create index ACT_IDX_HI_INCIDENT_PROC_DEF_KEY on ACT_HI_INCIDENT(PROC_DEF_KEY_); +create index ACT_IDX_HI_INCIDENT_ROOT_PI on ACT_HI_INCIDENT(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_INCIDENT_PROCINST on ACT_HI_INCIDENT(PROC_INST_ID_); +create index ACT_IDX_HI_INCIDENT_RM_TIME on ACT_HI_INCIDENT(REMOVAL_TIME_); +create index ACT_IDX_HI_INCIDENT_CREATE_TIME on ACT_HI_INCIDENT(CREATE_TIME_); +create index ACT_IDX_HI_INCIDENT_END_TIME on ACT_HI_INCIDENT(END_TIME_); + +create index ACT_IDX_HI_JOB_LOG_ROOT_PI on ACT_HI_JOB_LOG(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_JOB_LOG_PROCINST on ACT_HI_JOB_LOG(PROCESS_INSTANCE_ID_); +create index ACT_IDX_HI_JOB_LOG_PROCDEF on ACT_HI_JOB_LOG(PROCESS_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_TENANT_ID on ACT_HI_JOB_LOG(TENANT_ID_); +create index ACT_IDX_HI_JOB_LOG_JOB_DEF_ID on ACT_HI_JOB_LOG(JOB_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_PROC_DEF_KEY on ACT_HI_JOB_LOG(PROCESS_DEF_KEY_); +create index ACT_IDX_HI_JOB_LOG_EX_STACK on ACT_HI_JOB_LOG(JOB_EXCEPTION_STACK_ID_); +create index ACT_IDX_HI_JOB_LOG_RM_TIME on ACT_HI_JOB_LOG(REMOVAL_TIME_); +create index ACT_IDX_HI_JOB_LOG_JOB_CONF on ACT_HI_JOB_LOG(JOB_DEF_CONFIGURATION_); + +create index ACT_HI_BAT_RM_TIME on ACT_HI_BATCH(REMOVAL_TIME_); + +create index ACT_HI_EXT_TASK_LOG_ROOT_PI on ACT_HI_EXT_TASK_LOG(ROOT_PROC_INST_ID_); +create index ACT_HI_EXT_TASK_LOG_PROCINST on ACT_HI_EXT_TASK_LOG(PROC_INST_ID_); +create index ACT_HI_EXT_TASK_LOG_PROCDEF on ACT_HI_EXT_TASK_LOG(PROC_DEF_ID_); +create index ACT_HI_EXT_TASK_LOG_PROC_DEF_KEY on ACT_HI_EXT_TASK_LOG(PROC_DEF_KEY_); +create index ACT_HI_EXT_TASK_LOG_TENANT_ID on ACT_HI_EXT_TASK_LOG(TENANT_ID_); +create index ACT_IDX_HI_EXTTASKLOG_ERRORDET on ACT_HI_EXT_TASK_LOG(ERROR_DETAILS_ID_); +create index ACT_HI_EXT_TASK_LOG_RM_TIME on ACT_HI_EXT_TASK_LOG(REMOVAL_TIME_); + +create index ACT_IDX_HI_OP_LOG_ROOT_PI on ACT_HI_OP_LOG(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_OP_LOG_PROCINST on ACT_HI_OP_LOG(PROC_INST_ID_); +create index ACT_IDX_HI_OP_LOG_PROCDEF on ACT_HI_OP_LOG(PROC_DEF_ID_); +create index ACT_IDX_HI_OP_LOG_TASK on ACT_HI_OP_LOG(TASK_ID_); +create index ACT_IDX_HI_OP_LOG_RM_TIME on ACT_HI_OP_LOG(REMOVAL_TIME_); +create index ACT_IDX_HI_OP_LOG_TIMESTAMP on ACT_HI_OP_LOG(TIMESTAMP_); +create index ACT_IDX_HI_OP_LOG_USER_ID on ACT_HI_OP_LOG(USER_ID_); +create index ACT_IDX_HI_OP_LOG_OP_TYPE on ACT_HI_OP_LOG(OPERATION_TYPE_); +create index ACT_IDX_HI_OP_LOG_ENTITY_TYPE on ACT_HI_OP_LOG(ENTITY_TYPE_); + +create index ACT_IDX_HI_ATTACHMENT_CONTENT on ACT_HI_ATTACHMENT(CONTENT_ID_); +create index ACT_IDX_HI_ATTACHMENT_ROOT_PI on ACT_HI_ATTACHMENT(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_ATTACHMENT_PROCINST on ACT_HI_ATTACHMENT(PROC_INST_ID_); +create index ACT_IDX_HI_ATTACHMENT_TASK on ACT_HI_ATTACHMENT(TASK_ID_); +create index ACT_IDX_HI_ATTACHMENT_RM_TIME on ACT_HI_ATTACHMENT(REMOVAL_TIME_); + +create index ACT_IDX_HI_COMMENT_TASK on ACT_HI_COMMENT(TASK_ID_); +create index ACT_IDX_HI_COMMENT_ROOT_PI on ACT_HI_COMMENT(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_COMMENT_PROCINST on ACT_HI_COMMENT(PROC_INST_ID_); +create index ACT_IDX_HI_COMMENT_RM_TIME on ACT_HI_COMMENT(REMOVAL_TIME_); +-- +-- Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH +-- under one or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information regarding copyright +-- ownership. Camunda licenses this file to you under the Apache License, +-- Version 2.0; you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +create table ACT_HI_CASEINST ( + ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64) not null, + CREATE_TIME_ timestamp not null, + CLOSE_TIME_ timestamp, + DURATION_ bigint, + STATE_ integer, + CREATE_USER_ID_ varchar(255), + SUPER_CASE_INSTANCE_ID_ varchar(64), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_), + unique (CASE_INST_ID_) +); + +create table ACT_HI_CASEACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + CASE_ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + CASE_ACT_NAME_ varchar(255), + CASE_ACT_TYPE_ varchar(255), + CREATE_TIME_ timestamp not null, + END_TIME_ timestamp, + DURATION_ bigint, + STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +); + +create index ACT_IDX_HI_CAS_I_CLOSE on ACT_HI_CASEINST(CLOSE_TIME_); +create index ACT_IDX_HI_CAS_I_BUSKEY on ACT_HI_CASEINST(BUSINESS_KEY_); +create index ACT_IDX_HI_CAS_I_TENANT_ID on ACT_HI_CASEINST(TENANT_ID_); +create index ACT_IDX_HI_CAS_A_I_CREATE on ACT_HI_CASEACTINST(CREATE_TIME_); +create index ACT_IDX_HI_CAS_A_I_END on ACT_HI_CASEACTINST(END_TIME_); +create index ACT_IDX_HI_CAS_A_I_COMP on ACT_HI_CASEACTINST(CASE_ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_CAS_A_I_TENANT_ID on ACT_HI_CASEACTINST(TENANT_ID_); +-- +-- Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH +-- under one or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information regarding copyright +-- ownership. Camunda licenses this file to you under the Apache License, +-- Version 2.0; you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +-- create history decision instance table -- +create table ACT_HI_DECINST ( + ID_ varchar(64) NOT NULL, + DEC_DEF_ID_ varchar(64) NOT NULL, + DEC_DEF_KEY_ varchar(255) NOT NULL, + DEC_DEF_NAME_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + EVAL_TIME_ timestamp not null, + REMOVAL_TIME_ timestamp, + COLLECT_VALUE_ double precision, + USER_ID_ varchar(255), + ROOT_DEC_INST_ID_ varchar(64), + ROOT_PROC_INST_ID_ varchar(64), + DEC_REQ_ID_ varchar(64), + DEC_REQ_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +); + +-- create history decision input table -- +create table ACT_HI_DEC_IN ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64), + CLAUSE_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double precision, + LONG_ bigint, + TEXT_ varchar(4000), + TEXT2_ varchar(4000), + TENANT_ID_ varchar(64), + CREATE_TIME_ timestamp, + ROOT_PROC_INST_ID_ varchar(64), + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + +-- create history decision output table -- +create table ACT_HI_DEC_OUT ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64), + CLAUSE_NAME_ varchar(255), + RULE_ID_ varchar(64), + RULE_ORDER_ integer, + VAR_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double precision, + LONG_ bigint, + TEXT_ varchar(4000), + TEXT2_ varchar(4000), + TENANT_ID_ varchar(64), + CREATE_TIME_ timestamp, + ROOT_PROC_INST_ID_ varchar(64), + REMOVAL_TIME_ timestamp, + primary key (ID_) +); + + +create index ACT_IDX_HI_DEC_INST_ID on ACT_HI_DECINST(DEC_DEF_ID_); +create index ACT_IDX_HI_DEC_INST_KEY on ACT_HI_DECINST(DEC_DEF_KEY_); +create index ACT_IDX_HI_DEC_INST_PI on ACT_HI_DECINST(PROC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_CI on ACT_HI_DECINST(CASE_INST_ID_); +create index ACT_IDX_HI_DEC_INST_ACT on ACT_HI_DECINST(ACT_ID_); +create index ACT_IDX_HI_DEC_INST_ACT_INST on ACT_HI_DECINST(ACT_INST_ID_); +create index ACT_IDX_HI_DEC_INST_TIME on ACT_HI_DECINST(EVAL_TIME_); +create index ACT_IDX_HI_DEC_INST_TENANT_ID on ACT_HI_DECINST(TENANT_ID_); +create index ACT_IDX_HI_DEC_INST_ROOT_ID on ACT_HI_DECINST(ROOT_DEC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_REQ_ID on ACT_HI_DECINST(DEC_REQ_ID_); +create index ACT_IDX_HI_DEC_INST_REQ_KEY on ACT_HI_DECINST(DEC_REQ_KEY_); +create index ACT_IDX_HI_DEC_INST_ROOT_PI on ACT_HI_DECINST(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_RM_TIME on ACT_HI_DECINST(REMOVAL_TIME_); + +create index ACT_IDX_HI_DEC_IN_INST on ACT_HI_DEC_IN(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_IN_CLAUSE on ACT_HI_DEC_IN(DEC_INST_ID_, CLAUSE_ID_); +create index ACT_IDX_HI_DEC_IN_ROOT_PI on ACT_HI_DEC_IN(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_DEC_IN_RM_TIME on ACT_HI_DEC_IN(REMOVAL_TIME_); + +create index ACT_IDX_HI_DEC_OUT_INST on ACT_HI_DEC_OUT(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_OUT_RULE on ACT_HI_DEC_OUT(RULE_ORDER_, CLAUSE_ID_); +create index ACT_IDX_HI_DEC_OUT_ROOT_PI on ACT_HI_DEC_OUT(ROOT_PROC_INST_ID_); +create index ACT_IDX_HI_DEC_OUT_RM_TIME on ACT_HI_DEC_OUT(REMOVAL_TIME_); diff --git a/integration/camunda-bpm/taskpool-collector/src/test/resources/db/migrations/h2-postgresql/V0_0_2__postgres_identity_7.21.0.sql b/integration/camunda-bpm/taskpool-collector/src/test/resources/db/migrations/h2-postgresql/V0_0_2__postgres_identity_7.21.0.sql new file mode 100644 index 000000000..5b63794fc --- /dev/null +++ b/integration/camunda-bpm/taskpool-collector/src/test/resources/db/migrations/h2-postgresql/V0_0_2__postgres_identity_7.21.0.sql @@ -0,0 +1,109 @@ +-- +-- Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH +-- under one or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information regarding copyright +-- ownership. Camunda licenses this file to you under the Apache License, +-- Version 2.0; you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +create table ACT_ID_GROUP ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + TYPE_ varchar(255), + primary key (ID_) +); + +create table ACT_ID_MEMBERSHIP ( + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (USER_ID_, GROUP_ID_) +); + +create table ACT_ID_USER ( + ID_ varchar(64), + REV_ integer, + FIRST_ varchar(255), + LAST_ varchar(255), + EMAIL_ varchar(255), + PWD_ varchar(255), + SALT_ varchar(255), + LOCK_EXP_TIME_ timestamp, + ATTEMPTS_ integer, + PICTURE_ID_ varchar(64), + primary key (ID_) +); + +create table ACT_ID_INFO ( + ID_ varchar(64), + REV_ integer, + USER_ID_ varchar(64), + TYPE_ varchar(64), + KEY_ varchar(255), + VALUE_ varchar(255), + PASSWORD_ bytea, + PARENT_ID_ varchar(255), + primary key (ID_) +); + +create table ACT_ID_TENANT ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + primary key (ID_) +); + +create table ACT_ID_TENANT_MEMBER ( + ID_ varchar(64) not null, + TENANT_ID_ varchar(64) not null, + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (ID_) +); + +create index ACT_IDX_MEMB_GROUP on ACT_ID_MEMBERSHIP(GROUP_ID_); +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +create index ACT_IDX_MEMB_USER on ACT_ID_MEMBERSHIP(USER_ID_); +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_USER + unique (TENANT_ID_, USER_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_GROUP + unique (TENANT_ID_, GROUP_ID_); + +create index ACT_IDX_TENANT_MEMB on ACT_ID_TENANT_MEMBER(TENANT_ID_); +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB + foreign key (TENANT_ID_) + references ACT_ID_TENANT (ID_); + +create index ACT_IDX_TENANT_MEMB_USER on ACT_ID_TENANT_MEMBER(USER_ID_); +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +create index ACT_IDX_TENANT_MEMB_GROUP on ACT_ID_TENANT_MEMBER(GROUP_ID_); +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); From f007e8e9233d61f4c3014c007dc46262efb3f980 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 18 Jun 2024 14:48:23 +0200 Subject: [PATCH 05/13] chore: remove snapshot publication from develop branch --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a623e5dfc..de0bd0ae7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,6 +49,7 @@ jobs: env: OSS_CENTRAL_USERNAME: "${{ secrets.SONATYPE_USERNAME }}" OSS_CENTRAL_PASSWORD: "${{ secrets.SONATYPE_PASSWORD }}" + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/snapshot-producer' - name: Upload coverage information to CodeCov uses: codecov/codecov-action@v4 From 9769d03dc0b015bfa8b8d1af95ecccbba7fde620 Mon Sep 17 00:00:00 2001 From: Michael von Bargen <37417767+MichaelVonB@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:56:39 +0200 Subject: [PATCH 06/13] Support correlations for data entries in JPA view (#1006) * feat(#1001): add correlations to jpa and build base for dataentry with correlation queries * feat(1001): support flag for including correlations * feat(1001): document new view * feat(#1001): add tests and documentation for data entry correlation - closes #1001 * chore: make view great again in test migration * fix(#1001): Fixed test after converting table to view * open java modules for urefire and failsafe * made fields immutable, combined SQL scripts --------- Co-authored-by: Michael von Bargen Co-authored-by: Tim Holzke Co-authored-by: Simon Zambrovski --- bom/parent/pom.xml | 4 +- docs/reference-guide/components/view-jpa.md | 25 +++- .../jpa/JpaPolyflowViewDataEntryService.kt | 4 +- .../view/jpa/PolyflowJpaViewProperties.kt | 7 +- .../polyflow/view/jpa/SpecificationExt.kt | 19 ++- .../polyflow/view/jpa/data/ConverterExt.kt | 5 +- .../polyflow/view/jpa/data/DataEntryEntity.kt | 17 +++ .../data/DataEntryPayloadAttributeEntity.kt | 29 ++++ .../data/DataEntryPayloadAttributeEntityId.kt | 49 +++++++ .../view/jpa/data/DataEntryRepository.kt | 25 ++++ ...lowViewServiceDataEntryCorrelationITest.kt | 128 ++++++++++++++++++ .../JpaPolyflowViewServiceDataEntryITest.kt | 22 ++- .../polyflow/view/jpa/SpecificationTest.kt | 5 +- .../view/jpa/data/DataEntryRepositoryITest.kt | 1 - .../view/jpa/task/TaskRepositoryITest.kt | 13 +- .../V0_0_15__jpa_view_correlation_payload.sql | 17 +-- ..._0_16__jpa_plf_data_entry_correlations.sql | 23 ++++ 17 files changed, 346 insertions(+), 47 deletions(-) create mode 100644 view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntity.kt create mode 100644 view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntityId.kt create mode 100644 view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryCorrelationITest.kt create mode 100644 view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_16__jpa_plf_data_entry_correlations.sql diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index e5b046760..7b0e46cf3 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -530,7 +530,7 @@ - -Djava.awt.headless=true @{surefireArgLine} -XX:+StartAttachListener + -Djava.awt.headless=true @{surefireArgLine} -XX:+StartAttachListener --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED ${project.build.directory}/jgiven-reports @@ -557,7 +557,7 @@ - -Djava.awt.headless=true @{failsafeArgLine} -XX:+StartAttachListener --add-opens java.base/java.util=ALL-UNNAMED + -Djava.awt.headless=true @{failsafeArgLine} -XX:+StartAttachListener --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED diff --git a/docs/reference-guide/components/view-jpa.md b/docs/reference-guide/components/view-jpa.md index b14e2e6d5..26c7e4acb 100644 --- a/docs/reference-guide/components/view-jpa.md +++ b/docs/reference-guide/components/view-jpa.md @@ -61,6 +61,7 @@ configuration of this indexing process by the following configuration options: polyflow.view.jpa: stored-items: task, data-entry, process-instance, process-definition payload-attribute-level-limit: 2 + include-correlated-data-entries-in-data-entry-queries: false data-entry-filters: include: myProperty2.myOtherEmbeddedProperty3, myProperty2.myOtherEmbeddedProperty2 # exclude: myProperty @@ -74,9 +75,14 @@ In addition, the `stored-items` property is holding a set of items to be persist stored items are: `task`, `data-entry`, `process-instance` and `process-definition`. By setting this property, you can disable storage of items not required by your application and save space consumption of your database. The property defaults to `data-entry`. +The `include-correlated-data-entries-in-data-entry-queries` flag controls whether a data entry query (`DataEntriesForUserQuery` or `DataEntriesQuery`) considers +the payload of correlated data entries. The data entry attributes (such as `entry_type`, `state.state`, ...) of correlated data entries are not considered. +*Note:* Only one level of correlation depth is considered here and there is no option yet to change the depth. + The attributes `data-entry-filters` and `task-filters` hold `include` / `exclude` lists of property paths which will be taken in consideration during the search index creation. + !!! note Please make sure you understand that the **payload enrichment** performed during collection and **indexing for search** are two different operations. It is perfectly fine to have a large JSON payload attached to the task, but it makes no sense to make the entire payload searchable, @@ -116,11 +122,12 @@ The JPA View uses several tables to store the results. These are: * `PLF_TASK_CORRELATIONS`: table for user task correlation information * `PLF_TASK_PAYLOAD_ATTRIBUTES`: table for user task attribute search index * `PLF_VIEW_TASK_AND_DATA_ENTRY_PAYLOAD`: view for convenient taskWithDataEntry queries execution +* `PLF_DATA_ENTRY_PAYLOAD_ATTRIBUTES`: view for convenient data entry queries with correlations * `TRACKING_TOKEN`: table for Axon Tracking Tokens If you are interested in DDLs for the view, feel free to generate one using the following call of Apache Maven `mvn -Pgenerate-sql -f view/jpa`. Currently, DDLs for the databases H2, MSSQL and PostgreSQL are generated into `target/` directory. -The DDL for the `PLF_VIEW_TASK_AND_DATA_ENTRY_PAYLOAD` cannot be auto-generated, therefore you need to use the following statement to create it: +The DDL for the `PLF_VIEW_TASK_AND_DATA_ENTRY_PAYLOAD` and `PLF_DATA_ENTRY_PAYLOAD_ATTRIBUTES` cannot be auto-generated, therefore you need to use the following statements to create them: ``` create view PLF_VIEW_TASK_AND_DATA_ENTRY_PAYLOAD as ((select pc.TASK_ID, dea.PATH, dea.VALUE @@ -129,3 +136,19 @@ create view PLF_VIEW_TASK_AND_DATA_ENTRY_PAYLOAD as union select * from PLF_TASK_PAYLOAD_ATTRIBUTES); ``` + +``` +create view PLF_VIEW_DATA_ENTRY_PAYLOAD as ( +select * +from PLF_DATA_ENTRY_PAYLOAD_ATTRIBUTES +union +(select ec.OWNING_ENTRY_ID as ENTRY_ID, + ec.OWNING_ENTRY_TYPE as ENTRY_TYPE, + ep.path as PATH, + ep.value as VALUE + from PLF_DATA_ENTRY_CORRELATIONS ec + join PLF_DATA_ENTRY_PAYLOAD_ATTRIBUTES ep + on + ec.ENTRY_ID = ep.ENTRY_ID and ec.ENTRY_TYPE = ep.ENTRY_TYPE) +) +``` diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt index ac05f917b..c853b5628 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt @@ -76,7 +76,7 @@ class JpaPolyflowViewDataEntryService( val authorizedPrincipals: Set = setOf(user(query.user.username)).plus(query.user.groups.map { group(it) }) val criteria: List = toCriteria(query.filters) - val specification = criteria.toDataEntrySpecification() + val specification = criteria.toDataEntrySpecification(polyflowJpaViewProperties.includeCorrelatedDataEntriesInDataEntryQueries) val pageRequest = pageRequest(query.page, query.size, query.sort) val page = dataEntryRepository.findAll(specification.and(isAuthorizedFor(authorizedPrincipals)), pageRequest) @@ -87,7 +87,7 @@ class JpaPolyflowViewDataEntryService( override fun query(query: DataEntriesQuery, metaData: MetaData): QueryResponseMessage { val criteria: List = toCriteria(query.filters) - val specification = criteria.toDataEntrySpecification() + val specification = criteria.toDataEntrySpecification(polyflowJpaViewProperties.includeCorrelatedDataEntriesInDataEntryQueries) val pageRequest = pageRequest(query.page, query.size, query.sort) val page = dataEntryRepository.findAll(specification, pageRequest) diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/PolyflowJpaViewProperties.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/PolyflowJpaViewProperties.kt index 92581ab23..c735de875 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/PolyflowJpaViewProperties.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/PolyflowJpaViewProperties.kt @@ -30,7 +30,12 @@ data class PolyflowJpaViewProperties( * Filters for the path for indexing. */ @NestedConfigurationProperty - private val taskFilters: PayloadAttributeFilterPaths = PayloadAttributeFilterPaths() + private val taskFilters: PayloadAttributeFilterPaths = PayloadAttributeFilterPaths(), + + /** + * Controls if DataEntryQueries should consider the payload attributes of correlated data entries. Defaults to "false". + */ + val includeCorrelatedDataEntriesInDataEntryQueries: Boolean = false ) { /** diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/SpecificationExt.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/SpecificationExt.kt index 24a1dcdb5..56e369a04 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/SpecificationExt.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/SpecificationExt.kt @@ -7,6 +7,7 @@ import io.holunda.polyflow.view.Task import io.holunda.polyflow.view.filter.* import io.holunda.polyflow.view.jpa.data.DataEntryEntity import io.holunda.polyflow.view.jpa.data.DataEntryRepository.Companion.hasDataEntryPayloadAttribute +import io.holunda.polyflow.view.jpa.data.DataEntryRepository.Companion.hasDataEntryPayloadAttributeIncludingCorrelations import io.holunda.polyflow.view.jpa.data.DataEntryRepository.Companion.hasEntryId import io.holunda.polyflow.view.jpa.data.DataEntryRepository.Companion.hasEntryType import io.holunda.polyflow.view.jpa.data.DataEntryRepository.Companion.hasProcessingType @@ -24,8 +25,8 @@ import io.holunda.polyflow.view.jpa.task.TaskRepository.Companion.hasFollowUpDat import io.holunda.polyflow.view.jpa.task.TaskRepository.Companion.hasFollowUpDateBefore import io.holunda.polyflow.view.jpa.task.TaskRepository.Companion.hasPriority import io.holunda.polyflow.view.jpa.task.TaskRepository.Companion.hasProcessName -import io.holunda.polyflow.view.jpa.task.TaskRepository.Companion.hasTaskPayloadAttribute import io.holunda.polyflow.view.jpa.task.TaskRepository.Companion.hasTaskOrDataEntryPayloadAttribute +import io.holunda.polyflow.view.jpa.task.TaskRepository.Companion.hasTaskPayloadAttribute import io.holunda.polyflow.view.jpa.task.TaskRepository.Companion.likeBusinessKey import io.holunda.polyflow.view.jpa.task.TaskRepository.Companion.likeDescription import io.holunda.polyflow.view.jpa.task.TaskRepository.Companion.likeName @@ -43,10 +44,10 @@ import java.time.Instant /** * Creates a JPQL specification out of predicate wrapper. */ -fun List.toDataEntrySpecification(): Specification { +fun List.toDataEntrySpecification(includeCorrelatedDataEntries: Boolean): Specification { val attributeSpec = toDataEntryAttributeSpecification() - val payloadSpec = toDataEntryPayloadSpecification() + val payloadSpec = toDataEntryPayloadSpecification(includeCorrelatedDataEntries) return where(attributeSpec).and(payloadSpec) } @@ -187,11 +188,11 @@ internal fun List.toDataEntryAttributeSpecification(): Specification< /** * Specification on payload. */ -internal fun List.toDataEntryPayloadSpecification(): Specification { +internal fun List.toDataEntryPayloadSpecification(includeCorrelatedDataEntries: Boolean): Specification { val relevant = this.filterIsInstance() // compose criteria with same name with OR and criteria with different names with AND val relevantByName = relevant.groupBy { it.name } - val orComposedByName = relevantByName.map { (_, criteria) -> criteria.toOrDataEntrySpecification() } + val orComposedByName = relevantByName.map { (_, criteria) -> criteria.toOrDataEntrySpecification(includeCorrelatedDataEntries) } return composeAnd(orComposedByName) } @@ -325,12 +326,16 @@ internal fun Criterion.DataEntryCriterion.toTaskCorrelatedDataEntrySpecification * Creates JPA Specification for query of payload attributes based on JSON paths. All criteria must have the same path * and will be composed by the logical OR operator. */ -internal fun List.toOrDataEntrySpecification(): Specification { +internal fun List.toOrDataEntrySpecification(includeCorrelatedDataEntries: Boolean): Specification { require(this.isNotEmpty()) { "List of criteria must not be empty." } require(this.all { it.operator == EQUALS }) { "JPA View currently supports only equals as operator for filtering of payload attributes." } require(this.distinctBy { it.name }.size == 1) { "All criteria must have the same path." } - return hasDataEntryPayloadAttribute(this.first().name, this.map { it.value }) + return if (includeCorrelatedDataEntries) { + hasDataEntryPayloadAttributeIncludingCorrelations(this.first().name, this.map { it.value }) + } else { + hasDataEntryPayloadAttribute(this.first().name, this.map { it.value }) + } } diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt index 03adf6bb4..a26383181 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt @@ -12,6 +12,7 @@ import io.holunda.polyflow.view.jpa.auth.AuthorizationPrincipal.Companion.user import io.holunda.polyflow.view.jpa.auth.AuthorizationPrincipalType.GROUP import io.holunda.polyflow.view.jpa.auth.AuthorizationPrincipalType.USER import io.holunda.polyflow.view.jpa.payload.PayloadAttribute +import org.camunda.bpm.engine.variable.Variables /** * Converts the entity into API type. @@ -30,6 +31,7 @@ fun DataEntryEntity.toDataEntry(objectMapper: ObjectMapper) = authorizedUsers = this.authorizedPrincipals.asUsernames(), authorizedGroups = this.authorizedPrincipals.asGroupnames(), payload = this.payload.toPayloadVariableMap(objectMapper), + correlations = Variables.fromMap(this.correlations.associate { it.entryType to it.entryId }) ) /** @@ -86,6 +88,7 @@ fun DataEntryCreatedEvent.toEntity(objectMapper: ObjectMapper, revisionValue: Re }, authorizedPrincipals = AuthorizationChange.applyUserAuthorization(mutableSetOf(), this.authorizations).map { user(it).toString() } .plus(AuthorizationChange.applyGroupAuthorization(mutableSetOf(), this.authorizations).map { group(it).toString() }).toMutableSet(), + correlations = this.correlations.toMutableMap().map { entry -> DataEntryId(entryType = entry.key, entryId = entry.value.toString()) }.toMutableSet() ).apply { this.protocol = this.protocol.addModification(this, this@toEntity.createModification, this@toEntity.state) } @@ -188,4 +191,4 @@ fun DataEntryDeletedEvent.toEntity( } }.apply { this.protocol = this.protocol.addModification(this, this@toEntity.deleteModification, this@toEntity.state) -} \ No newline at end of file +} diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEntity.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEntity.kt index 50b1942e8..c220aeaf6 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEntity.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEntity.kt @@ -5,6 +5,7 @@ import io.holunda.polyflow.view.jpa.payload.PayloadAttribute import jakarta.persistence.* import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode +import org.hibernate.annotations.Immutable import java.time.Instant /** @@ -62,6 +63,22 @@ class DataEntryEntity( @OneToMany(mappedBy = "dataEntry", orphanRemoval = true, cascade = [CascadeType.ALL], fetch = FetchType.EAGER) @Fetch(FetchMode.SELECT) var protocol: MutableList = mutableListOf(), + @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable( + name = "PLF_DATA_ENTRY_CORRELATIONS", + joinColumns = [ + JoinColumn(name = "OWNING_ENTRY_TYPE", referencedColumnName = "ENTRY_TYPE"), + JoinColumn(name= "OWNING_ENTRY_ID", referencedColumnName = "ENTRY_ID"), + ] + ) + var correlations: MutableSet = mutableSetOf(), + @Immutable + @OneToMany(fetch = FetchType.LAZY) + @JoinColumns( + JoinColumn(name = "ENTRY_TYPE", referencedColumnName = "ENTRY_TYPE", insertable = false, updatable = false), + JoinColumn(name = "ENTRY_ID", referencedColumnName = "ENTRY_ID", insertable = false, updatable = false) + ) + var payloadAndCorrelatedPayloadAttributes: MutableSet = mutableSetOf(), @Column(name = "PAYLOAD") @Lob diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntity.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntity.kt new file mode 100644 index 000000000..8e29eaf7d --- /dev/null +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntity.kt @@ -0,0 +1,29 @@ +package io.holunda.polyflow.view.jpa.data + +import jakarta.persistence.EmbeddedId +import jakarta.persistence.Entity +import jakarta.persistence.Table +import org.hibernate.annotations.Immutable + +/** + * Entity that holds the combined payload attributes of the correlated DataEntries. + */ +@Entity +@Immutable +@Table(name = "PLF_VIEW_DATA_ENTRY_PAYLOAD") +class DataEntryPayloadAttributeEntity( + @EmbeddedId + var id: DataEntryPayloadAttributeEntityId, +) { + constructor(entryType: String, entryId: String, path: String, value: String) : this( + DataEntryPayloadAttributeEntityId( + entryType = entryType, + entryId = entryId, + path = path, + value = value + ) + ) + + override fun toString(): String = "DataEntryPayloadAttributeEntity(id=$id)" +} + diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntityId.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntityId.kt new file mode 100644 index 000000000..3524c3a03 --- /dev/null +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntityId.kt @@ -0,0 +1,49 @@ +package io.holunda.polyflow.view.jpa.data + +import jakarta.persistence.Column +import jakarta.persistence.Embeddable +import org.hibernate.annotations.Immutable +import java.io.Serializable + +/** + * Id class that holds the combined payload attributes of the correlated DataEntries. + */ +@Embeddable +@Immutable +class DataEntryPayloadAttributeEntityId( + @Column(name = "ENTRY_TYPE", length = 64, nullable = false, updatable = false, insertable = false) + var entryType: String, + @Column(name = "ENTRY_ID", length = 64, nullable = false, updatable = false, insertable = false) + var entryId: String, + @Column(name = "PATH", nullable = false, updatable = false, insertable = false) + var path: String, + @Column(name = "VALUE", nullable = false, updatable = false, insertable = false) + var value: String +) : Serializable { + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as DataEntryPayloadAttributeEntityId + + if (entryType != other.entryType) return false + if (entryId != other.entryId) return false + if (path != other.path) return false + if (value != other.value) return false + + return true + } + + override fun hashCode(): Int { + var result = entryType.hashCode() + result = 31 * result + entryId.hashCode() + result = 31 * result + path.hashCode() + result = 31 * result + value.hashCode() + return result + } + + override fun toString(): String { + return "DataEntryPayloadAttributeEntityId(entryType='$entryType', entryId='$entryId', path='$path', value='$value')" + } +} diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepository.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepository.kt index 2d7354686..f78d9fb52 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepository.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepository.kt @@ -106,6 +106,31 @@ interface DataEntryRepository : CrudRepository, Jp builder.and(pathEquals, valueAnyOf) } + /** + * Specification for checking the payload attributes of a data entry (including payload attributes from correlated data entries). + * If multiple values are given, one of them must match. payload.name = ? AND (payload.value = ? OR payload.value = ? OR ...) + */ + fun hasDataEntryPayloadAttributeIncludingCorrelations(name: String, values: List): Specification = + Specification { dataEntry, query, builder -> + query.distinct(true) + val join = dataEntry.join>(DataEntryEntity::payloadAndCorrelatedPayloadAttributes.name) + val pathEquals = builder.equal( + join.get(DataEntryPayloadAttributeEntity::id.name) + .get(DataEntryPayloadAttributeEntityId::path.name), + name + ) + + val valueAnyOf = values.map { + builder.equal( + join.get(DataEntryPayloadAttributeEntity::id.name) + .get(DataEntryPayloadAttributeEntityId::value.name), + it + ) + }.let { builder.or(*it.toTypedArray()) } + + builder.and(pathEquals, valueAnyOf) + } + /** * Specification for checking authorization of multiple principals. */ diff --git a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryCorrelationITest.kt b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryCorrelationITest.kt new file mode 100644 index 000000000..3318dd1f2 --- /dev/null +++ b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryCorrelationITest.kt @@ -0,0 +1,128 @@ +package io.holunda.polyflow.view.jpa + +import com.fasterxml.jackson.databind.ObjectMapper +import io.holunda.camunda.taskpool.api.business.AuthorizationChange.Companion.addGroup +import io.holunda.camunda.taskpool.api.business.AuthorizationChange.Companion.addUser +import io.holunda.camunda.taskpool.api.business.DataEntryCreatedEvent +import io.holunda.camunda.taskpool.api.business.Modification +import io.holunda.camunda.taskpool.api.business.ProcessingType +import io.holunda.camunda.taskpool.api.business.addCorrelation +import io.holunda.camunda.variable.serializer.serialize +import io.holunda.polyflow.view.jpa.itest.TestApplication +import io.holunda.polyflow.view.query.data.DataEntriesQuery +import org.assertj.core.api.Assertions.assertThat +import org.axonframework.messaging.MetaData +import org.camunda.bpm.engine.variable.Variables +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.annotation.DirtiesContext +import org.springframework.test.context.ActiveProfiles +import org.springframework.transaction.annotation.Transactional +import java.time.Instant +import java.time.OffsetDateTime +import java.time.ZoneOffset +import java.util.* +import java.util.function.Predicate + +@SpringBootTest( + classes = [TestApplication::class], + properties = [ + "polyflow.view.jpa.stored-items=data-entry", + "polyflow.view.jpa.include-correlated-data-entries-in-data-entry-queries=true" + ] +) +@ActiveProfiles("itest", "mock-query-emitter") +@Transactional +@DirtiesContext +internal class JpaPolyflowViewServiceDataEntryCorrelationITest { + + private val emittedQueryUpdates: MutableList> = mutableListOf() + + @Autowired + lateinit var jpaPolyflowViewService: JpaPolyflowViewDataEntryService + + @Autowired + lateinit var dbCleaner: DbCleaner + + @Autowired + lateinit var objectMapper: ObjectMapper + + private val id1 = UUID.randomUUID().toString() + private val id2 = UUID.randomUUID().toString() + private val now = Instant.now() + + @BeforeEach + fun `ingest events`() { + + + jpaPolyflowViewService.on( + event = DataEntryCreatedEvent( + entryType = "io.polyflow.test", + entryId = id1, + type = "Test", + applicationName = "test-application", + name = "Test Entry 2", + state = ProcessingType.IN_PROGRESS.of("In review"), + payload = serialize(payload = mapOf("key-int" to 1, "key" to "value"), mapper = objectMapper), + authorizations = listOf( + addUser("piggy"), + addGroup("muppets") + ), + createModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC), + username = "piggy", + log = "Created", + logNotes = "Created the entry" + ) + ), + metaData = MetaData.emptyInstance() + ) + + + jpaPolyflowViewService.on( + event = DataEntryCreatedEvent( + entryType = "io.polyflow.test", + entryId = id2, + type = "Test sort", + applicationName = "test-application", + name = "Test Entry 4", + state = ProcessingType.IN_PROGRESS.of("In review"), + payload = serialize(payload = mapOf("key-int" to 2, "key" to "other-value"), mapper = objectMapper), + authorizations = listOf( + addUser("hulk"), + addGroup("avenger") + ), + createModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC), + username = "piggy", + log = "Created", + logNotes = "Created the entry" + ), + correlations = Variables.createVariables().addCorrelation("io.polyflow.test", id1) + ), + metaData = MetaData.emptyInstance() + ) + } + + @AfterEach + fun `cleanup projection`() { + dbCleaner.cleanup() + // clear updates + emittedQueryUpdates.clear() + } + + @Test + fun `should find data entry with correlations`() { + val result = jpaPolyflowViewService.query( + DataEntriesQuery(filters = listOf("key-int=1")) // key-int 1 is an attribute of data entry 1 + ) + + assertThat(result.payload.elements.map { it.entryId }).containsExactlyInAnyOrder(id2, id1) // id2 is found by correlation to id1, due to property + } + + data class QueryUpdate(val queryType: Class, val predicate: Predicate, val update: Any) + +} diff --git a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt index 5b9ef5f3b..6d451afd3 100644 --- a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt +++ b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt @@ -19,10 +19,10 @@ import org.axonframework.queryhandling.GenericSubscriptionQueryUpdateMessage import org.axonframework.queryhandling.QueryResponseMessage import org.axonframework.queryhandling.QueryUpdateEmitter import org.axonframework.queryhandling.SubscriptionQueryUpdateMessage +import org.camunda.bpm.engine.variable.Variables import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith import org.mockito.kotlin.argumentCaptor import org.mockito.kotlin.atLeast import org.mockito.kotlin.clearInvocations @@ -31,7 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.ActiveProfiles -import org.springframework.test.context.junit.jupiter.SpringExtension import org.springframework.transaction.annotation.Transactional import java.time.Instant import java.time.OffsetDateTime @@ -43,7 +42,8 @@ import java.util.function.Predicate @SpringBootTest( classes = [TestApplication::class], properties = [ - "polyflow.view.jpa.stored-items=data-entry" + "polyflow.view.jpa.stored-items=data-entry", + "polyflow.view.jpa.include-correlated-data-entries-in-data-entry-queries=false" ] ) @ActiveProfiles("itest", "mock-query-emitter") @@ -158,7 +158,7 @@ internal class JpaPolyflowViewServiceDataEntryITest { applicationName = "test-application", name = "Test Entry 3", state = ProcessingType.IN_PROGRESS.of("In review"), - payload = serialize(payload = mapOf("key-int" to 2, "key" to "value"), mapper = objectMapper), + payload = serialize(payload = mapOf("key-int" to 3, "key" to "value"), mapper = objectMapper), authorizations = listOf( addUser("piggy"), addGroup("muppets") @@ -195,7 +195,7 @@ internal class JpaPolyflowViewServiceDataEntryITest { applicationName = "test-application", name = "Test Entry 4", state = ProcessingType.IN_PROGRESS.of("In review"), - payload = serialize(payload = mapOf("key-int" to 2, "key" to "other-value"), mapper = objectMapper), + payload = serialize(payload = mapOf("key-int" to 4, "key" to "other-value"), mapper = objectMapper), authorizations = listOf( addUser("hulk"), addGroup("avenger") @@ -205,7 +205,8 @@ internal class JpaPolyflowViewServiceDataEntryITest { username = "piggy", log = "Created", logNotes = "Created the entry" - ) + ), + correlations = Variables.createVariables().addCorrelation("io.polyflow.test", id2) ), metaData = MetaData.emptyInstance() ) @@ -323,6 +324,15 @@ internal class JpaPolyflowViewServiceDataEntryITest { assertThat(result.payload.elements.map { it.entryId }).containsExactly(id, id2, id4) } + @Test + fun `should not find data entry with correlations`() { + val result = jpaPolyflowViewService.query( + DataEntriesQuery(filters = listOf("key-int=2")) // key-int 2 is an attribute of data entry 2 + ) + + assertThat(result.payload.elements.map { it.entryId }).containsExactly(id2) // id4 is not found by correlation to id2, due to property + } + private fun query_updates_have_been_emitted(query: T, id: String, revision: Long) { captureEmittedQueryUpdates() diff --git a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/SpecificationTest.kt b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/SpecificationTest.kt index bb81e5bf9..35bff2f23 100644 --- a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/SpecificationTest.kt +++ b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/SpecificationTest.kt @@ -8,7 +8,6 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.springframework.data.domain.Sort.Direction -import java.lang.NumberFormatException /** * Tests conversion of criteria into JPA Specifications. @@ -20,7 +19,7 @@ internal class SpecificationTest { val filters = listOf("data.state.state=In Progress") val criteria = toCriteria(filters) - val specification = criteria.toDataEntrySpecification() + val specification = criteria.toDataEntrySpecification(false) assertThat(specification).isNotNull } @@ -35,7 +34,7 @@ internal class SpecificationTest { ) val criteria = toCriteria(filters) - val specification = criteria.toDataEntrySpecification() + val specification = criteria.toDataEntrySpecification(false) assertThat(specification).isNotNull } diff --git a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepositoryITest.kt b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepositoryITest.kt index 11ab7ec46..30001d323 100644 --- a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepositoryITest.kt +++ b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepositoryITest.kt @@ -151,7 +151,6 @@ internal class DataEntryRepositoryITest { @Test fun `loads each protocol entry only once`() { - entityManager.clear() val dataEntry = dataEntryRepository.findByIdOrNull(dataEntry.dataEntryId)!! assertThat(dataEntry.protocol.size).isEqualTo(1) } diff --git a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/task/TaskRepositoryITest.kt b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/task/TaskRepositoryITest.kt index 3a27dbe6a..00f167cc8 100644 --- a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/task/TaskRepositoryITest.kt +++ b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/task/TaskRepositoryITest.kt @@ -112,14 +112,8 @@ class TaskRepositoryITest { state = DataEntryStateEmbeddable(ProcessingType.PRELIMINARY.name, "IN_PREPARATION") ) - val task1Id = UUID.randomUUID().toString() - val taskAndDataEntryPayloadAttribute1 = TaskAndDataEntryPayloadAttributeEntity(task1Id, "key", "value") - val taskAndDataEntryPayloadAttribute2 = TaskAndDataEntryPayloadAttributeEntity(task1Id, "complex.child1", "1") - val taskAndDataEntryPayloadAttribute3 = TaskAndDataEntryPayloadAttributeEntity(task1Id, "complex.child1", "small") - val taskAndDataEntryPayloadAttribute4 = TaskAndDataEntryPayloadAttributeEntity(task1Id, "foo", "bar") - task1 = TaskEntity( - taskId = task1Id, + taskId = UUID.randomUUID().toString(), name = "task 1", businessKey = "ZZZ-1-YYY-2", description = "some random description", @@ -149,11 +143,6 @@ class TaskRepositoryITest { entityManager.persist(task1) entityManager.persist(task2) - entityManager.persist(taskAndDataEntryPayloadAttribute1) - entityManager.persist(taskAndDataEntryPayloadAttribute2) - entityManager.persist(taskAndDataEntryPayloadAttribute3) - entityManager.persist(taskAndDataEntryPayloadAttribute4) - entityManager.flush() } diff --git a/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_15__jpa_view_correlation_payload.sql b/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_15__jpa_view_correlation_payload.sql index 4cad3cc53..6c5de79c2 100644 --- a/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_15__jpa_view_correlation_payload.sql +++ b/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_15__jpa_view_correlation_payload.sql @@ -1,11 +1,6 @@ -CREATE TABLE plf_view_task_and_data_entry_payload ( - task_id VARCHAR(64) NOT NULL, - path VARCHAR(255) NOT NULL, - value VARCHAR(255) NOT NULL, - PRIMARY KEY (task_id, path, value) -); - -ALTER TABLE plf_view_task_and_data_entry_payload - ADD CONSTRAINT FK_view_task_and_data_entry_payload_have_task - FOREIGN KEY (task_id) - REFERENCES plf_task; +create view PLF_VIEW_TASK_AND_DATA_ENTRY_PAYLOAD as +((select pc.TASK_ID, dea.PATH, dea.VALUE + from PLF_TASK_CORRELATIONS pc + join PLF_DATA_ENTRY_PAYLOAD_ATTRIBUTES dea on pc.ENTRY_ID = dea.ENTRY_ID and pc.ENTRY_TYPE = dea.ENTRY_TYPE) +union +select * from PLF_TASK_PAYLOAD_ATTRIBUTES); diff --git a/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_16__jpa_plf_data_entry_correlations.sql b/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_16__jpa_plf_data_entry_correlations.sql new file mode 100644 index 000000000..d70396fd7 --- /dev/null +++ b/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_16__jpa_plf_data_entry_correlations.sql @@ -0,0 +1,23 @@ +create table PLF_DATA_ENTRY_CORRELATIONS +( + OWNING_ENTRY_TYPE varchar(255) not null, + OWNING_ENTRY_ID varchar(64) not null, + ENTRY_TYPE varchar(255) not null, + ENTRY_ID varchar(64) not null, + primary key (OWNING_ENTRY_TYPE, OWNING_ENTRY_ID, ENTRY_TYPE, ENTRY_ID) +); + +create view PLF_VIEW_DATA_ENTRY_PAYLOAD as +( +select * +from PLF_DATA_ENTRY_PAYLOAD_ATTRIBUTES +union +(select ec.OWNING_ENTRY_ID as ENTRY_ID, + ec.OWNING_ENTRY_TYPE as ENTRY_TYPE, + ep.path as PATH, + ep.value as VALUE + from PLF_DATA_ENTRY_CORRELATIONS ec + join PLF_DATA_ENTRY_PAYLOAD_ATTRIBUTES ep + on + ec.ENTRY_ID = ep.ENTRY_ID and ec.ENTRY_TYPE = ep.ENTRY_TYPE) +); From 98f8f0d6e75357318735f0e57ffba5abcfc0a26a Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 18 Jun 2024 15:05:05 +0200 Subject: [PATCH 07/13] set next release version --- bom/datapool-dependencies/pom.xml | 2 +- bom/parent/pom.xml | 2 +- bom/taskpool-dependencies/pom.xml | 2 +- core/bus-jackson/pom.xml | 2 +- core/datapool/datapool-api/pom.xml | 2 +- core/datapool/datapool-core/pom.xml | 2 +- core/datapool/datapool-event/pom.xml | 2 +- core/datapool/pom.xml | 2 +- core/spring-utils/pom.xml | 2 +- core/taskpool/pom.xml | 2 +- core/taskpool/taskpool-api/pom.xml | 2 +- core/taskpool/taskpool-core/pom.xml | 2 +- core/taskpool/taskpool-event/pom.xml | 2 +- integration/camunda-bpm/engine-client/pom.xml | 2 +- integration/camunda-bpm/pom.xml | 2 +- integration/camunda-bpm/springboot-autoconfigure/pom.xml | 2 +- integration/camunda-bpm/springboot-starter/pom.xml | 2 +- integration/camunda-bpm/taskpool-collector/pom.xml | 2 +- integration/camunda-bpm/taskpool-job-sender/pom.xml | 2 +- integration/common/datapool-sender/pom.xml | 2 +- integration/common/pom.xml | 2 +- integration/common/tasklist-url-resolver/pom.xml | 2 +- integration/common/taskpool-sender/pom.xml | 2 +- integration/common/variable-serializer/pom.xml | 2 +- pom.xml | 2 +- view/form-url-resolver/pom.xml | 2 +- view/jpa/pom.xml | 2 +- view/mongo/pom.xml | 2 +- view/pom.xml | 2 +- view/simple/pom.xml | 2 +- view/view-api-client/pom.xml | 2 +- view/view-api/pom.xml | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/bom/datapool-dependencies/pom.xml b/bom/datapool-dependencies/pom.xml index e8946c97e..24961c0dc 100644 --- a/bom/datapool-dependencies/pom.xml +++ b/bom/datapool-dependencies/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT ../parent/pom.xml diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index 7b0e46cf3..6fe206516 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-root - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT ../../pom.xml diff --git a/bom/taskpool-dependencies/pom.xml b/bom/taskpool-dependencies/pom.xml index f31982d9d..b36e8f2e7 100644 --- a/bom/taskpool-dependencies/pom.xml +++ b/bom/taskpool-dependencies/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT ../parent/pom.xml diff --git a/core/bus-jackson/pom.xml b/core/bus-jackson/pom.xml index 08b6b01f1..98ba622aa 100755 --- a/core/bus-jackson/pom.xml +++ b/core/bus-jackson/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/datapool/datapool-api/pom.xml b/core/datapool/datapool-api/pom.xml index 4af180a06..1cf2d9e36 100755 --- a/core/datapool/datapool-api/pom.xml +++ b/core/datapool/datapool-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-datapool-api diff --git a/core/datapool/datapool-core/pom.xml b/core/datapool/datapool-core/pom.xml index cc97f1432..80d6b01a7 100644 --- a/core/datapool/datapool-core/pom.xml +++ b/core/datapool/datapool-core/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-datapool-core diff --git a/core/datapool/datapool-event/pom.xml b/core/datapool/datapool-event/pom.xml index 3f78846b1..ec512df4c 100755 --- a/core/datapool/datapool-event/pom.xml +++ b/core/datapool/datapool-event/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-datapool-event diff --git a/core/datapool/pom.xml b/core/datapool/pom.xml index 75eb0e22e..2ec5f5863 100755 --- a/core/datapool/pom.xml +++ b/core/datapool/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/spring-utils/pom.xml b/core/spring-utils/pom.xml index 3ef776bf2..e120c0e30 100755 --- a/core/spring-utils/pom.xml +++ b/core/spring-utils/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/taskpool/pom.xml b/core/taskpool/pom.xml index b26afe91c..10cc00a60 100755 --- a/core/taskpool/pom.xml +++ b/core/taskpool/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/taskpool/taskpool-api/pom.xml b/core/taskpool/taskpool-api/pom.xml index 4129ddfc0..5d64adc69 100755 --- a/core/taskpool/taskpool-api/pom.xml +++ b/core/taskpool/taskpool-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-taskpool-api diff --git a/core/taskpool/taskpool-core/pom.xml b/core/taskpool/taskpool-core/pom.xml index 99bea3ff5..8865c1bef 100755 --- a/core/taskpool/taskpool-core/pom.xml +++ b/core/taskpool/taskpool-core/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-taskpool-core diff --git a/core/taskpool/taskpool-event/pom.xml b/core/taskpool/taskpool-event/pom.xml index 1b9a3becc..97693357e 100644 --- a/core/taskpool/taskpool-event/pom.xml +++ b/core/taskpool/taskpool-event/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-taskpool-event diff --git a/integration/camunda-bpm/engine-client/pom.xml b/integration/camunda-bpm/engine-client/pom.xml index c69678b6a..251640522 100644 --- a/integration/camunda-bpm/engine-client/pom.xml +++ b/integration/camunda-bpm/engine-client/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-camunda-bpm-engine-client diff --git a/integration/camunda-bpm/pom.xml b/integration/camunda-bpm/pom.xml index 02276e234..052dbb9f0 100644 --- a/integration/camunda-bpm/pom.xml +++ b/integration/camunda-bpm/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT ../../bom/parent/pom.xml diff --git a/integration/camunda-bpm/springboot-autoconfigure/pom.xml b/integration/camunda-bpm/springboot-autoconfigure/pom.xml index f08f402fc..b19f2dd16 100755 --- a/integration/camunda-bpm/springboot-autoconfigure/pom.xml +++ b/integration/camunda-bpm/springboot-autoconfigure/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-camunda-bpm-springboot-autoconfigure diff --git a/integration/camunda-bpm/springboot-starter/pom.xml b/integration/camunda-bpm/springboot-starter/pom.xml index 5b308775d..0170629c0 100755 --- a/integration/camunda-bpm/springboot-starter/pom.xml +++ b/integration/camunda-bpm/springboot-starter/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-camunda-bpm-springboot-starter diff --git a/integration/camunda-bpm/taskpool-collector/pom.xml b/integration/camunda-bpm/taskpool-collector/pom.xml index 46525f4cf..640902bba 100755 --- a/integration/camunda-bpm/taskpool-collector/pom.xml +++ b/integration/camunda-bpm/taskpool-collector/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-camunda-bpm-taskpool-collector diff --git a/integration/camunda-bpm/taskpool-job-sender/pom.xml b/integration/camunda-bpm/taskpool-job-sender/pom.xml index b6604e2f1..2b00ed79c 100755 --- a/integration/camunda-bpm/taskpool-job-sender/pom.xml +++ b/integration/camunda-bpm/taskpool-job-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-camunda-bpm-taskpool-job-sender diff --git a/integration/common/datapool-sender/pom.xml b/integration/common/datapool-sender/pom.xml index abd68ba0e..833edce4f 100755 --- a/integration/common/datapool-sender/pom.xml +++ b/integration/common/datapool-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-datapool-sender diff --git a/integration/common/pom.xml b/integration/common/pom.xml index 95f72d1c8..f60cc068e 100755 --- a/integration/common/pom.xml +++ b/integration/common/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT ../../bom/parent/pom.xml diff --git a/integration/common/tasklist-url-resolver/pom.xml b/integration/common/tasklist-url-resolver/pom.xml index e3cbd5a3f..7f43498eb 100644 --- a/integration/common/tasklist-url-resolver/pom.xml +++ b/integration/common/tasklist-url-resolver/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-tasklist-url-resolver diff --git a/integration/common/taskpool-sender/pom.xml b/integration/common/taskpool-sender/pom.xml index 6f8ecf39e..09ece3f2b 100755 --- a/integration/common/taskpool-sender/pom.xml +++ b/integration/common/taskpool-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-taskpool-sender diff --git a/integration/common/variable-serializer/pom.xml b/integration/common/variable-serializer/pom.xml index 28b2d1476..e8cd375a0 100755 --- a/integration/common/variable-serializer/pom.xml +++ b/integration/common/variable-serializer/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-variable-serializer diff --git a/pom.xml b/pom.xml index a17101a21..2a6ae56b6 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-root - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT pom POM: ${project.artifactId} diff --git a/view/form-url-resolver/pom.xml b/view/form-url-resolver/pom.xml index d8c897e6e..b0d673e79 100644 --- a/view/form-url-resolver/pom.xml +++ b/view/form-url-resolver/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-form-url-resolver diff --git a/view/jpa/pom.xml b/view/jpa/pom.xml index c142683a8..683a48bac 100644 --- a/view/jpa/pom.xml +++ b/view/jpa/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-view-jpa diff --git a/view/mongo/pom.xml b/view/mongo/pom.xml index 7c632893e..b55b65695 100644 --- a/view/mongo/pom.xml +++ b/view/mongo/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-view-mongo diff --git a/view/pom.xml b/view/pom.xml index fe5423c2d..41b300d6a 100644 --- a/view/pom.xml +++ b/view/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT ../bom/parent/pom.xml diff --git a/view/simple/pom.xml b/view/simple/pom.xml index af10601f0..75546ae31 100755 --- a/view/simple/pom.xml +++ b/view/simple/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-view-simple diff --git a/view/view-api-client/pom.xml b/view/view-api-client/pom.xml index d3c085825..53a6fe5e8 100755 --- a/view/view-api-client/pom.xml +++ b/view/view-api-client/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-view-api-client diff --git a/view/view-api/pom.xml b/view/view-api/pom.xml index ce1180e20..1b84ccd71 100755 --- a/view/view-api/pom.xml +++ b/view/view-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.1.7-SNAPSHOT + 4.2.0-SNAPSHOT polyflow-view-api From 02b06875d4f070ce5c6c0398c919b64a79230a81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:08:46 +0000 Subject: [PATCH 08/13] Bump org.apache.maven.plugins:maven-jar-plugin from 3.4.1 to 3.4.2 Bumps [org.apache.maven.plugins:maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.4.1 to 3.4.2. - [Release notes](https://github.com/apache/maven-jar-plugin/releases) - [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.4.1...maven-jar-plugin-3.4.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-jar-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- bom/parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index 6fe206516..29921d716 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -420,7 +420,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.4.1 + 3.4.2 From ae5cf819a0ee5d894be125df79e954b3f8eff2dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 22:38:07 +0200 Subject: [PATCH 09/13] Bump org.apache.maven.plugins:maven-clean-plugin from 3.3.2 to 3.4.0 (#1009) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2a6ae56b6..ee322f86a 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ org.apache.maven.plugins maven-clean-plugin - 3.3.2 + 3.4.0 From b601bd130514e20b2bb42c843027465d44a988b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:37:58 +0200 Subject: [PATCH 10/13] Bump org.apache.maven.plugins:maven-dependency-plugin (#1013) Bumps [org.apache.maven.plugins:maven-dependency-plugin](https://github.com/apache/maven-dependency-plugin) from 3.7.0 to 3.7.1. - [Release notes](https://github.com/apache/maven-dependency-plugin/releases) - [Commits](https://github.com/apache/maven-dependency-plugin/compare/maven-dependency-plugin-3.7.0...maven-dependency-plugin-3.7.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-dependency-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- bom/parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index 29921d716..8ad29c645 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -435,7 +435,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.7.0 + 3.7.1 From ff26257a6e4a022f12d113c5a8ffb7593c1ad742 Mon Sep 17 00:00:00 2001 From: Michael von Bargen <37417767+MichaelVonB@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:34:44 +0200 Subject: [PATCH 11/13] Find DataEntries by user involvement (#1012) * feat(#1008): add field in query * feat(#1008): implement myInvolvement filter in JPA-View * chore(#1008): add Test for In-Memory view * chore(#1008): add query for mongo view * chore(#1008): add documentation for specification * chore(#1008): adjust test so that a modification without a user exists --------- Co-authored-by: Michael von Bargen --- .../jpa/JpaPolyflowViewDataEntryService.kt | 7 +- .../view/jpa/data/DataEntryRepository.kt | 12 + .../JpaPolyflowViewServiceDataEntryITest.kt | 43 ++- .../polyflow/view/mongo/MongoViewService.kt | 12 +- .../view/mongo/data/DataEntryRepository.kt | 8 +- .../service/SimpleDataEntryServiceTest.kt | 352 ++++++++++++++++++ .../query/data/DataEntriesForUserQuery.kt | 12 + 7 files changed, 432 insertions(+), 14 deletions(-) create mode 100644 view/simple/src/test/kotlin/io/holunda/polyflow/view/simple/service/SimpleDataEntryServiceTest.kt diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt index c853b5628..24c7c3095 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt @@ -16,6 +16,7 @@ import io.holunda.polyflow.view.jpa.auth.AuthorizationPrincipal.Companion.user import io.holunda.polyflow.view.jpa.data.* import io.holunda.polyflow.view.jpa.data.DataEntryRepository.Companion.hasEntryId import io.holunda.polyflow.view.jpa.data.DataEntryRepository.Companion.hasEntryType +import io.holunda.polyflow.view.jpa.data.DataEntryRepository.Companion.hasUserInvolvement import io.holunda.polyflow.view.jpa.data.DataEntryRepository.Companion.isAuthorizedFor import io.holunda.polyflow.view.jpa.update.updateDataEntryQuery import io.holunda.polyflow.view.query.PageableSortableQuery @@ -78,8 +79,10 @@ class JpaPolyflowViewDataEntryService( val criteria: List = toCriteria(query.filters) val specification = criteria.toDataEntrySpecification(polyflowJpaViewProperties.includeCorrelatedDataEntriesInDataEntryQueries) val pageRequest = pageRequest(query.page, query.size, query.sort) - - val page = dataEntryRepository.findAll(specification.and(isAuthorizedFor(authorizedPrincipals)), pageRequest) + val userQuery = if (query.involvementsOnly) { + isAuthorizedFor(authorizedPrincipals).and(hasUserInvolvement(query.user.username)) + } else { isAuthorizedFor(authorizedPrincipals) } + val page = dataEntryRepository.findAll(specification.and(userQuery), pageRequest) return constructDataEntryResponse(page) } diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepository.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepository.kt index f78d9fb52..a80b4f1e4 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepository.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryRepository.kt @@ -57,6 +57,18 @@ interface DataEntryRepository : CrudRepository, Jp ) } + /** + * Specification for data entries to check if a user appears in any ProtocolElement + */ + fun hasUserInvolvement(userName: String): Specification = + Specification {dataEntry, _, builder -> + builder.equal( + dataEntry.join>(DataEntryEntity::protocol.name) + .get(ProtocolElement::username.name), + userName + ) + } + /** * Specification for the user-defined state. */ diff --git a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt index 6d451afd3..c43aa675e 100644 --- a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt +++ b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt @@ -105,6 +105,29 @@ internal class JpaPolyflowViewServiceDataEntryITest { metaData = RevisionValue(revision = 1).toMetaData() ) + jpaPolyflowViewService.on( + event = DataEntryUpdatedEvent( + entryType = "io.polyflow.test", + entryId = id, + type = "Test", + applicationName = "test-application", + name = "Test Entry 1", + state = ProcessingType.IN_PROGRESS.of("Internal check"), + payload =serialize(payload = payload, mapper = objectMapper), + authorizations = listOf( + addUser("kermit"), + addGroup("muppets") + ), + updateModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC).plus(5, ChronoUnit.SECONDS), + username = null, + log = "Updated", + logNotes = "Updates the entry" + ) + ), + metaData = RevisionValue(revision = 2).toMetaData() + ) + jpaPolyflowViewService.on( event = DataEntryUpdatedEvent( entryType = "io.polyflow.test", @@ -124,7 +147,7 @@ internal class JpaPolyflowViewServiceDataEntryITest { logNotes = "Updated the entry" ) ), - metaData = RevisionValue(revision = 2).toMetaData() + metaData = RevisionValue(revision = 3).toMetaData() ) jpaPolyflowViewService.on( @@ -283,7 +306,7 @@ internal class JpaPolyflowViewServiceDataEntryITest { ) ) - query_updates_have_been_emitted(query, id, 2) + query_updates_have_been_emitted(query, id, 3) } @Test @@ -333,6 +356,14 @@ internal class JpaPolyflowViewServiceDataEntryITest { assertThat(result.payload.elements.map { it.entryId }).containsExactly(id2) // id4 is not found by correlation to id2, due to property } + @Test + fun `should find data entry by involvements`() { + val result = jpaPolyflowViewService.query( + DataEntriesForUserQuery(user = User("kermit", mutableSetOf("muppets")), involvementsOnly = true) + ) + + assertThat(result.payload.elements.map { it.entryId }).containsExactly(id) // user is allowed to see two dataEntries but has only one involvement + } private fun query_updates_have_been_emitted(query: T, id: String, revision: Long) { captureEmittedQueryUpdates() @@ -372,11 +403,13 @@ internal class JpaPolyflowViewServiceDataEntryITest { assertThat(dataEntry.entryType).isEqualTo("io.polyflow.test") assertThat(dataEntry.name).isEqualTo("Test Entry 1") assertThat(dataEntry.payload).containsKeys("key", "key-int", "complex") - assertThat(dataEntry.protocol.size).isEqualTo(2) + assertThat(dataEntry.protocol.size).isEqualTo(3) assertThat(dataEntry.protocol[0].time).isEqualTo(now) assertThat(dataEntry.protocol[0].username).isEqualTo("kermit") - assertThat(dataEntry.protocol[1].time).isEqualTo(now.plus(10, ChronoUnit.SECONDS)) - assertThat(dataEntry.protocol[1].username).isEqualTo("ironman") + assertThat(dataEntry.protocol[1].time).isEqualTo(now.plus(5, ChronoUnit.SECONDS)) + assertThat(dataEntry.protocol[1].username).isNull() + assertThat(dataEntry.protocol[2].time).isEqualTo(now.plus(10, ChronoUnit.SECONDS)) + assertThat(dataEntry.protocol[2].username).isEqualTo("ironman") } private fun assertTestDataEntry2(dataEntry: DataEntry) { diff --git a/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/MongoViewService.kt b/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/MongoViewService.kt index 4d0ab11d7..e181b5f42 100755 --- a/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/MongoViewService.kt +++ b/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/MongoViewService.kt @@ -141,11 +141,13 @@ class MongoViewService( */ @QueryHandler override fun query(query: DataEntriesForUserQuery, metaData: MetaData): CompletableFuture = - dataEntryRepository - .findAllForUser( - username = query.user.username, - groupNames = query.user.groups - ) + (if (query.involvementsOnly) + dataEntryRepository + .findAllForUserWithInvolvement( + username = query.user.username, + groupNames = query.user.groups + ) + else dataEntryRepository.findAllForUser(username = query.user.username, groupNames = query.user.groups)) .map { it.dataEntry() } .collectList() .map { DataEntriesQueryResult(elements = it).slice(query) } diff --git a/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/data/DataEntryRepository.kt b/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/data/DataEntryRepository.kt index d534ef3c3..c062c77ea 100644 --- a/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/data/DataEntryRepository.kt +++ b/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/data/DataEntryRepository.kt @@ -1,8 +1,6 @@ package io.holunda.polyflow.view.mongo.data -import io.holunda.camunda.taskpool.api.business.DataIdentity import io.holunda.camunda.taskpool.api.business.EntryType -import io.holunda.camunda.taskpool.api.business.dataIdentityString import org.springframework.data.domain.Pageable import org.springframework.data.domain.Sort import org.springframework.data.mongodb.repository.Query @@ -50,6 +48,12 @@ interface DataEntryRepository : @Query("{ \$or: [ { 'authorizedUsers' : ?0 }, { 'authorizedGroups' : { \$in: ?1 } } ], 'deleted': { \$ne: true } }") fun findAllForUser(@Param("username") username: String, @Param("groupNames") groupNames: Set): Flux + /** + * Finder for user. + */ + @Query("{ \$or: [ { 'authorizedUsers' : ?0 }, { 'authorizedGroups' : { \$in: ?1 } } ], 'deleted': { \$ne: true }, 'protocol.username': ?0 }") + fun findAllForUserWithInvolvement(@Param("username") username: String, @Param("groupNames") groupNames: Set): Flux + /** * Retrieves all data entries for user. */ diff --git a/view/simple/src/test/kotlin/io/holunda/polyflow/view/simple/service/SimpleDataEntryServiceTest.kt b/view/simple/src/test/kotlin/io/holunda/polyflow/view/simple/service/SimpleDataEntryServiceTest.kt new file mode 100644 index 000000000..38b47d0f9 --- /dev/null +++ b/view/simple/src/test/kotlin/io/holunda/polyflow/view/simple/service/SimpleDataEntryServiceTest.kt @@ -0,0 +1,352 @@ +package io.holunda.polyflow.view.simple.service + +import io.holixon.axon.gateway.query.RevisionValue +import io.holunda.camunda.taskpool.api.business.* +import io.holunda.camunda.taskpool.api.business.AuthorizationChange.Companion.addGroup +import io.holunda.camunda.taskpool.api.business.AuthorizationChange.Companion.addUser +import io.holunda.polyflow.view.DataEntry +import io.holunda.polyflow.view.auth.User +import io.holunda.polyflow.view.query.data.DataEntriesForUserQuery +import io.holunda.polyflow.view.query.data.DataEntriesQuery +import io.holunda.polyflow.view.query.data.DataEntriesQueryResult +import io.holunda.polyflow.view.query.data.DataEntryForIdentityQuery +import org.assertj.core.api.Assertions.assertThat +import org.axonframework.messaging.MetaData +import org.axonframework.queryhandling.QueryResponseMessage +import org.axonframework.queryhandling.SimpleQueryUpdateEmitter +import org.camunda.bpm.engine.variable.Variables +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import java.time.Instant +import java.time.OffsetDateTime +import java.time.ZoneOffset +import java.time.temporal.ChronoUnit +import java.util.* + +class SimpleDataEntryServiceTest { + + private var service: SimpleDataEntryService = SimpleDataEntryService(queryUpdateEmitter = SimpleQueryUpdateEmitter.builder().build()) + private val id = UUID.randomUUID().toString() + private val id2 = UUID.randomUUID().toString() + private val id3 = UUID.randomUUID().toString() + private val id4 = UUID.randomUUID().toString() + private val now = Instant.now() + + @BeforeEach + fun `ingest events`() { + val payload = Variables.fromMap(mapOf("key" to "value", "key-int" to 1, "complex" to mapOf("attribute1" to "value", "attribute2" to Date.from(now)))) + + service.on( + event = DataEntryCreatedEvent( + entryType = "io.polyflow.test", + entryId = id, + type = "Test", + applicationName = "test-application", + name = "Test Entry 1", + state = ProcessingType.IN_PROGRESS.of("In progress"), + payload = payload, + authorizations = listOf( + addUser("kermit"), + addGroup("muppets") + ), + createModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC), + username = "kermit", + log = "Created", + logNotes = "Created the entry" + ) + ), + metaData = RevisionValue(revision = 1).toMetaData() + ) + + service.on( + event = DataEntryUpdatedEvent( + entryType = "io.polyflow.test", + entryId = id, + type = "Test", + applicationName = "test-application", + name = "Test Entry 1", + state = ProcessingType.IN_PROGRESS.of("Internal check"), + payload = payload, + authorizations = listOf( + addUser("kermit"), + addGroup("muppets") + ), + updateModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC).plus(5, ChronoUnit.SECONDS), + username = null, + log = "Updated", + logNotes = "Updates the entry" + ) + ), + metaData = RevisionValue(revision = 2).toMetaData() + ) + + service.on( + event = DataEntryUpdatedEvent( + entryType = "io.polyflow.test", + entryId = id, + type = "Test", + applicationName = "test-application", + name = "Test Entry 1", + state = ProcessingType.IN_PROGRESS.of("In review"), + payload = payload, + authorizations = listOf( + addUser("ironman"), + ), + updateModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC).plus(10, ChronoUnit.SECONDS), + username = "ironman", + log = "Updated", + logNotes = "Updated the entry" + ) + ), + metaData = RevisionValue(revision = 3).toMetaData() + ) + + service.on( + event = DataEntryCreatedEvent( + entryType = "io.polyflow.test", + entryId = id2, + type = "Test", + applicationName = "test-application", + name = "Test Entry 2", + state = ProcessingType.IN_PROGRESS.of("In review"), + payload = Variables.putValue("key-int", 2).putValue("key", "value"), + authorizations = listOf( + addUser("piggy"), + addGroup("muppets") + ), + createModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC), + username = "piggy", + log = "Created", + logNotes = "Created the entry" + ) + ), + metaData = MetaData.emptyInstance() + ) + + service.on( + event = DataEntryCreatedEvent( + entryType = "io.polyflow.test", + entryId = id3, + type = "Test of deleted", + applicationName = "test-application", + name = "Test Entry 3", + state = ProcessingType.IN_PROGRESS.of("In review"), + payload = Variables.putValue("key-int", 3).putValue("key", "value"), + authorizations = listOf( + addUser("piggy"), + addGroup("muppets") + ), + createModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC), + username = "piggy", + log = "Created", + logNotes = "Created the entry" + ) + ), + metaData = MetaData.emptyInstance() + ) + + service.on( + event = DataEntryDeletedEvent( + entryType = "io.polyflow.test", + entryId = id3, + deleteModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC), + log = "Deleted", + logNotes = "Created by mistake" + ), + state = ProcessingType.DELETED.of("Create error") + ), + metaData = MetaData.emptyInstance() + ) + + service.on( + event = DataEntryCreatedEvent( + entryType = "io.polyflow.test", + entryId = id4, + type = "Test sort", + applicationName = "test-application", + name = "Test Entry 4", + state = ProcessingType.IN_PROGRESS.of("In review"), + payload = Variables.putValue("key-int", 4).putValue("key", "other-value"), + authorizations = listOf( + addUser("hulk"), + addGroup("avenger") + ), + createModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC), + username = "piggy", + log = "Created", + logNotes = "Created the entry" + ), + correlations = Variables.createVariables().addCorrelation("io.polyflow.test", id2) + ), + metaData = MetaData.emptyInstance() + ) + } + + @AfterEach + fun `cleanup projection`() { + listOf(id, id2, id3, id4).forEach { + service.on(DataEntryDeletedEvent(entryId = "io.holunda.polyflow.test", entryType = it), metaData = MetaData.emptyInstance()) + } + } + + + @Test + fun `should find the entry by id`() { + val result = service.query( + DataEntryForIdentityQuery(entryType = "io.polyflow.test", entryId = id) + ) + assertThat(result.payload).isNotNull + assertTestDataEntry1(result.payload) + } + + @Test + fun `should find the entry by user`() { + + val result = service.query( + DataEntriesForUserQuery(user = User("kermit", groups = setOf())) + ) + + assertResultIsTestEntry1(result) + + assertResultIsTestEntry1And2( + service.query( + DataEntriesForUserQuery(user = User("superman", groups = setOf("muppets"))) + ) + ) + + assertResultIsTestEntry1( + service.query( + DataEntriesForUserQuery(user = User("ironman", groups = setOf())) + ) + ) + + assertThat( + service.query( + DataEntriesForUserQuery(user = User("superman", groups = setOf("avengers"))) + ).payload.elements + ).isEmpty() + + } + + @Test + fun `should not fail deleted already deleted entry`() { + service.on( + event = DataEntryDeletedEvent( + entryType = "io.polyflow.test", + entryId = id3, + deleteModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC), + log = "Deleted", + logNotes = "Created by mistake" + ), + state = ProcessingType.DELETED.of("Create error") + ), + metaData = MetaData.emptyInstance() + ) + } + + @Test + fun `should find the entry by user and filter`() { + val query = DataEntriesForUserQuery(user = User("kermit", groups = setOf("muppets")), filters = listOf("key-int=1")) + assertResultIsTestEntry1( + service.query( + query + ) + ) + } + + @Test + fun `should not find the deleted entry`() { + + val result = service.query( + DataEntryForIdentityQuery(entryType = "io.polyflow.test", entryId = id3) + ) + assertThat(result).isNotNull + assertThat(result.payload).isNull() + } + + @Test + fun `should sort entries with multiple criteria`() { + + val result = service.query( + DataEntriesQuery(sort = listOf("+type", "-name")) + ) + assertThat(result.payload.elements.map { it.entryId }).containsExactlyInAnyOrder(id2, id, id4) + } + + @Suppress("DEPRECATION") + @Test + fun `sort should be backwards compatible`() { + + val result = service.query( + DataEntriesQuery(sort = "+type") + ) + assertThat(result.payload.elements.map { it.entryId }).containsExactlyInAnyOrder(id, id2, id4) + } + + @Test + fun `should not find data entry with correlations`() { + val result = service.query( + DataEntriesQuery(filters = listOf("key-int=2")) // key-int 2 is an attribute of data entry 2 + ) + + assertThat(result.payload.elements.map { it.entryId }).containsExactlyInAnyOrder(id2) // id4 is not found by correlation to id2, due to property + } + + @Test + fun `should find data entry by involvements`() { + val result = service.query( + DataEntriesForUserQuery(user = User("kermit", mutableSetOf("muppets")), involvementsOnly = true) + ) + + assertThat(result.payload.elements.map { it.entryId }).containsExactlyInAnyOrder(id) // user is allowed to see two dataEntries but has only one involvement + } + + private fun assertResultIsTestEntry1(result: QueryResponseMessage) { + assertThat(result.payload.elements.size).isEqualTo(1) + val dataEntry = result.payload.elements[0] + assertTestDataEntry1(dataEntry) + } + + private fun assertResultIsTestEntry1And2(result: QueryResponseMessage) { + assertThat(result.payload.elements.size).isEqualTo(2) + assertThat(result.payload.elements.map { it.entryId }).containsExactlyInAnyOrder(id, id2) + assertTestDataEntry1(result.payload.elements.first { it.entryId == id }) + assertTestDataEntry2(result.payload.elements.first { it.entryId == id2 }) + } + + + private fun assertTestDataEntry1(dataEntry: DataEntry) { + assertThat(dataEntry.entryId).isEqualTo(id) + assertThat(dataEntry.entryType).isEqualTo("io.polyflow.test") + assertThat(dataEntry.name).isEqualTo("Test Entry 1") + assertThat(dataEntry.payload).containsKeys("key", "key-int", "complex") + assertThat(dataEntry.protocol.size).isEqualTo(3) + assertThat(dataEntry.protocol[0].time).isEqualTo(now) + assertThat(dataEntry.protocol[0].username).isEqualTo("kermit") + assertThat(dataEntry.protocol[1].time).isEqualTo(now.plus(5, ChronoUnit.SECONDS)) + assertThat(dataEntry.protocol[1].username).isNull() + assertThat(dataEntry.protocol[2].time).isEqualTo(now.plus(10, ChronoUnit.SECONDS)) + assertThat(dataEntry.protocol[2].username).isEqualTo("ironman") + } + + private fun assertTestDataEntry2(dataEntry: DataEntry) { + assertThat(dataEntry.entryId).isEqualTo(id2) + assertThat(dataEntry.entryType).isEqualTo("io.polyflow.test") + assertThat(dataEntry.name).isEqualTo("Test Entry 2") + assertThat(dataEntry.payload).containsKeys("key-int") + assertThat(dataEntry.protocol.size).isEqualTo(1) + assertThat(dataEntry.protocol[0].time).isEqualTo(now) + assertThat(dataEntry.protocol[0].username).isEqualTo("piggy") + } + + +} diff --git a/view/view-api/src/main/kotlin/query/data/DataEntriesForUserQuery.kt b/view/view-api/src/main/kotlin/query/data/DataEntriesForUserQuery.kt index 3cbf1c19a..cc548b753 100644 --- a/view/view-api/src/main/kotlin/query/data/DataEntriesForUserQuery.kt +++ b/view/view-api/src/main/kotlin/query/data/DataEntriesForUserQuery.kt @@ -11,6 +11,7 @@ import io.holunda.polyflow.view.query.PageableSortableQuery /** * Queries data entries for provided user. * @param user user authorized to access data entries. + * @param involvementsOnly controls of the result should contain only data entries where the `user` was involved * @param page current page, zero-based index. * @param size page size. * @param sort sort of data entries. @@ -18,6 +19,7 @@ import io.holunda.polyflow.view.query.PageableSortableQuery */ data class DataEntriesForUserQuery( val user: User, + val involvementsOnly: Boolean = false, override val page: Int = 0, override val size: Int = Int.MAX_VALUE, override val sort: List = listOf(), @@ -38,6 +40,15 @@ data class DataEntriesForUserQuery( filters = filters ) + constructor(user: User, page: Int = 0, size: Int = Int.MAX_VALUE, sort: List, filters: List = listOf()): this( + user = user, + involvementsOnly = false, + page = page, + size = size, + sort = sort, + filters = filters + ) + // jackson serialization works because delegate property is private private val predicates by lazy { createDataEntryPredicates(toCriteria(filters)) } @@ -49,4 +60,5 @@ data class DataEntriesForUserQuery( // authorized groups || (element.authorizedGroups.any { candidateGroup -> this.user.groups.contains(candidateGroup) }) ) + && (if (involvementsOnly) element.protocol.map { it.username }.contains(this.user.username) else true) } From 831df614b48bc12d4efcefce3cf51d596155144f Mon Sep 17 00:00:00 2001 From: S-Tim Date: Wed, 26 Jun 2024 15:56:01 +0200 Subject: [PATCH 12/13] Anonymize Data Entries (#1014) * feat(#1011): Added AnonymizeDataEntryCommand * feat(#1011): Added more parameters to AnonymizeDataEntryCommand * feat(#1011): Removed type from AnonymizeDataEntryCommand * feat(#1011): added tests * feat(#1011): added Mongo implementation of DataEntryAnonymizedEvent * chore(#1011): improved test * chore(#1011): improved tests also removed NotImplementedError that was left there by accident * chore(#1011): removed unnecessary handler --------- Co-authored-by: Simon Zambrovski --- .../api/business/DataEntryCommands.kt | 36 ++++++ .../core/business/DataEntryAggregate.kt | 15 +++ .../core/business/DataEntryAggregateTest.kt | 109 +++++++++++++++++- .../taskpool/api/business/BusinessEvents.kt | 32 +++++ .../camunda/taskpool/api/business/Mappers.kt | 11 ++ .../datapool/sender/DataEntryCommandSender.kt | 7 ++ .../sender/SimpleDataEntryCommandSender.kt | 17 +++ .../jpa/JpaPolyflowViewDataEntryService.kt | 20 ++++ .../polyflow/view/jpa/data/ConverterExt.kt | 23 ++++ .../view/jpa/data/DataEntryEventHandler.kt | 6 + .../JpaPolyflowViewServiceDataEntryITest.kt | 26 +++++ .../holunda/polyflow/view/jpa/TestFixtures.kt | 2 + .../view/jpa/data/ConverterExtKtTest.kt | 45 ++++++++ .../holunda/polyflow/view/mongo/Converters.kt | 25 ++++ .../polyflow/view/mongo/MongoViewService.kt | 13 +++ .../view/mongo/service/PolyflowStages.kt | 5 + .../view/simple/service/Converters.kt | 18 ++- .../simple/service/SimpleDataEntryService.kt | 21 +++- .../simple/service/SimpleTaskPoolService.kt | 22 +++- .../view/simple/service/ConvertersKtTest.kt | 39 +++++++ 20 files changed, 479 insertions(+), 13 deletions(-) create mode 100644 view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExtKtTest.kt create mode 100644 view/simple/src/test/kotlin/io/holunda/polyflow/view/simple/service/ConvertersKtTest.kt diff --git a/core/datapool/datapool-api/src/main/kotlin/io/holunda/camunda/taskpool/api/business/DataEntryCommands.kt b/core/datapool/datapool-api/src/main/kotlin/io/holunda/camunda/taskpool/api/business/DataEntryCommands.kt index 18e1bb768..70f2a5951 100755 --- a/core/datapool/datapool-api/src/main/kotlin/io/holunda/camunda/taskpool/api/business/DataEntryCommands.kt +++ b/core/datapool/datapool-api/src/main/kotlin/io/holunda/camunda/taskpool/api/business/DataEntryCommands.kt @@ -55,3 +55,39 @@ data class DeleteDataEntryCommand( @TargetAggregateIdentifier val dataIdentity: String = dataIdentityString(entryType = entryType, entryId = entryId), ) + +/** + * Command to anonymize the aggregate. + */ +data class AnonymizeDataEntryCommand( + /** + * Entry id. + */ + val entryId: EntryId, + + /** + * Entry type. + */ + val entryType: EntryType, + + /** + * The username that will replace the current username(s) in the protocol of the data entry + */ + val anonymizedUsername: String, + + /** + * Usernames that should be excluded from the anonymization. For example "SYSTEM" + */ + val excludedUsernames: List = listOf(), + + /** + * Modification information. + */ + val anonymizeModification: Modification = Modification.NONE, + + /** + * Addressing information. + */ + @TargetAggregateIdentifier + val dataIdentity: String = dataIdentityString(entryType = entryType, entryId = entryId), +) diff --git a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt index 5c056ec05..99e198cf7 100755 --- a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt +++ b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt @@ -71,6 +71,21 @@ class DataEntryAggregate() { ) } + /** + * Handle anonymize. + */ + @CommandHandler + fun handle(command: AnonymizeDataEntryCommand, @Autowired deletionStrategy: DeletionStrategy) { + if (deletionStrategy.strictMode()) { + if (deleted) { + throw AggregateDeletedException(this.dataIdentity, "The data entry has already been deleted") + } + } + AggregateLifecycle.apply( + command.anonymizeEvent() + ) + } + /** * React on created event. */ diff --git a/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregateTest.kt b/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregateTest.kt index 2f6d34f81..f9f536a36 100644 --- a/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregateTest.kt +++ b/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregateTest.kt @@ -2,11 +2,9 @@ package io.holunda.polyflow.datapool.core.business import com.fasterxml.jackson.databind.ObjectMapper import io.holunda.camunda.taskpool.api.business.* -import io.holunda.polyflow.bus.jackson.JsonAutoDetectAnyVisibility import io.holunda.polyflow.bus.jackson.configurePolyflowJacksonObjectMapper import io.holunda.polyflow.datapool.core.DeletionStrategy import io.holunda.polyflow.datapool.core.configurePolyflowJacksonObjectMapperForDatapool -import org.assertj.core.api.Assertions import org.assertj.core.api.Assertions.assertThat import org.axonframework.eventsourcing.AggregateDeletedException import org.axonframework.test.aggregate.AggregateTestFixture @@ -164,6 +162,113 @@ class DataEntryAggregateTest { ) } + @Test + fun `should anonymize aggregate`() { + + val dataEntryChange = DataEntryChange( + entryType = "io.holunda.My", + entryId = UUID.randomUUID().toString(), + applicationName = "myApp", + name = "My Entry 4711", + type = "My", + payload = Variables.createVariables(), + correlations = newCorrelations() + ) + + val command = AnonymizeDataEntryCommand( + entryType = dataEntryChange.entryType, + entryId = dataEntryChange.entryId, + anonymizedUsername = "ANONYMOUS", + excludedUsernames = listOf("SYSTEM"), + anonymizeModification = Modification(OffsetDateTime.now(), "kermit", "kermit decided to anonymize", logNotes = "Let us anonymize this item") + ) + + fixture + .registerInjectableResource(LAX_POLICY) + .given( + DataEntryCreatedEvent( + entryId = dataEntryChange.entryId, + entryType = dataEntryChange.entryType, + name = "Some name", + type = "Another", + applicationName = "Different application", + state = dataEntryChange.state, + description = dataEntryChange.description, + payload = dataEntryChange.payload, + correlations = dataEntryChange.correlations, + createModification = dataEntryChange.modification, + authorizations = dataEntryChange.authorizationChanges, + formKey = dataEntryChange.formKey + ) + ) + .`when`(command) + .expectEvents( + DataEntryAnonymizedEvent( + entryId = command.entryId, + entryType = command.entryType, + anonymizedUsername = command.anonymizedUsername, + excludedUsernames = command.excludedUsernames, + anonymizeModification = command.anonymizeModification, + ) + ) + } + + @Test + fun `should not anonymize deleted aggregate in strict mode`() { + + val dataEntryChange = DataEntryChange( + entryType = "io.holunda.My", + entryId = UUID.randomUUID().toString(), + applicationName = "myApp", + name = "My Entry 4711", + type = "My", + payload = Variables.createVariables(), + correlations = newCorrelations() + ) + + val deleteCommand = DeleteDataEntryCommand( + entryType = dataEntryChange.entryType, + entryId = dataEntryChange.entryId, + modification = Modification(OffsetDateTime.now(), "kermit", "kermit decided to delete", logNotes = "Let us delete this item"), + state = ProcessingType.DELETED.of("deleted as irrelevant") + ) + + val anonymizeCommand = AnonymizeDataEntryCommand( + entryType = dataEntryChange.entryType, + entryId = dataEntryChange.entryId, + anonymizedUsername = "ANONYMOUS", + excludedUsernames = listOf("SYSTEM"), + anonymizeModification = Modification(OffsetDateTime.now(), "kermit", "kermit decided to anonymize", logNotes = "Let us anonymize this item") + ) + + fixture + .registerInjectableResource(STRICT_POLICY) + .given( + DataEntryCreatedEvent( + entryId = dataEntryChange.entryId, + entryType = dataEntryChange.entryType, + name = "Some name", + type = "Another", + applicationName = "Different application", + state = dataEntryChange.state, + description = dataEntryChange.description, + payload = dataEntryChange.payload, + correlations = dataEntryChange.correlations, + createModification = dataEntryChange.modification, + authorizations = dataEntryChange.authorizationChanges, + formKey = dataEntryChange.formKey + ), + DataEntryDeletedEvent( + entryId = deleteCommand.entryId, + entryType = deleteCommand.entryType, + deleteModification = deleteCommand.modification, + state = deleteCommand.state + ) + ) + .`when`(anonymizeCommand) + .expectException(AggregateDeletedException::class.java) + } + @Test fun `should not delete deleted aggregate in strict mode`() { diff --git a/core/datapool/datapool-event/src/main/kotlin/io/holunda/camunda/taskpool/api/business/BusinessEvents.kt b/core/datapool/datapool-event/src/main/kotlin/io/holunda/camunda/taskpool/api/business/BusinessEvents.kt index 396733a18..43ee338f8 100755 --- a/core/datapool/datapool-event/src/main/kotlin/io/holunda/camunda/taskpool/api/business/BusinessEvents.kt +++ b/core/datapool/datapool-event/src/main/kotlin/io/holunda/camunda/taskpool/api/business/BusinessEvents.kt @@ -138,3 +138,35 @@ data class DataEntryDeletedEvent( */ val state: DataEntryState = ProcessingType.UNDEFINED.of("") ) + +/** + * Data entry anonymized. + */ +@Revision("1") +data class DataEntryAnonymizedEvent( + /** + * Entry type + */ + val entryType: EntryType, + + /** + * Entry id. + */ + val entryId: EntryId, + + /** + * The username that will replace the current username(s) in the protocol of the data entry + */ + val anonymizedUsername: String, + + /** + * Usernames that should be excluded from the anonymization. For example "SYSTEM" + */ + val excludedUsernames: List = listOf(), + + /** + * Modification information. + */ + val anonymizeModification: Modification = Modification.now(), + +) \ No newline at end of file diff --git a/core/datapool/datapool-event/src/main/kotlin/io/holunda/camunda/taskpool/api/business/Mappers.kt b/core/datapool/datapool-event/src/main/kotlin/io/holunda/camunda/taskpool/api/business/Mappers.kt index 154e8f792..451b0b0e3 100644 --- a/core/datapool/datapool-event/src/main/kotlin/io/holunda/camunda/taskpool/api/business/Mappers.kt +++ b/core/datapool/datapool-event/src/main/kotlin/io/holunda/camunda/taskpool/api/business/Mappers.kt @@ -44,4 +44,15 @@ fun DeleteDataEntryCommand.deletedEvent() = DataEntryDeletedEvent( entryType = this.entryType, deleteModification = this.modification, state = this.state +) + +/** + * Maps command to event. + */ +fun AnonymizeDataEntryCommand.anonymizeEvent() = DataEntryAnonymizedEvent( + entryId = this.entryId, + entryType = this.entryType, + anonymizedUsername = this.anonymizedUsername, + excludedUsernames = this.excludedUsernames, + anonymizeModification = this.anonymizeModification ) \ No newline at end of file diff --git a/integration/common/datapool-sender/src/main/kotlin/io/holunda/polyflow/datapool/sender/DataEntryCommandSender.kt b/integration/common/datapool-sender/src/main/kotlin/io/holunda/polyflow/datapool/sender/DataEntryCommandSender.kt index fba06103b..e73d9903d 100755 --- a/integration/common/datapool-sender/src/main/kotlin/io/holunda/polyflow/datapool/sender/DataEntryCommandSender.kt +++ b/integration/common/datapool-sender/src/main/kotlin/io/holunda/polyflow/datapool/sender/DataEntryCommandSender.kt @@ -69,6 +69,13 @@ interface DataEntryCommandSender { * @param metaData meta data, will default to empty metadata. */ fun sendDataEntryDelete(command: DeleteDataEntryCommand, metaData: MetaData = MetaData.emptyInstance()) + + /** + * Sends a data entry anonymize command. + * @param command command to send. + * @param metaData meta data, will default to empty metadata. + */ + fun sendDataEntryAnonymize(command: AnonymizeDataEntryCommand, metaData: MetaData = MetaData.emptyInstance()) } /** diff --git a/integration/common/datapool-sender/src/main/kotlin/io/holunda/polyflow/datapool/sender/SimpleDataEntryCommandSender.kt b/integration/common/datapool-sender/src/main/kotlin/io/holunda/polyflow/datapool/sender/SimpleDataEntryCommandSender.kt index ae32a9f7a..c7bd63688 100755 --- a/integration/common/datapool-sender/src/main/kotlin/io/holunda/polyflow/datapool/sender/SimpleDataEntryCommandSender.kt +++ b/integration/common/datapool-sender/src/main/kotlin/io/holunda/polyflow/datapool/sender/SimpleDataEntryCommandSender.kt @@ -126,5 +126,22 @@ class SimpleDataEntryCommandSender( logger.debug("Would have sent delete command $command") } } + + override fun sendDataEntryAnonymize(command: AnonymizeDataEntryCommand, metaData: MetaData) { + if (properties.enabled) { + val message = GenericCommandMessage + .asCommandMessage(command) + .withMetaData(metaData) + gateway.send(message) { m, r -> + if (r.isExceptional) { + errorHandler.apply(m, r) + } else { + successHandler.apply(m, r) + } + } + } else { + logger.debug("Would have sent anonymize command $command") + } + } } diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt index 24c7c3095..90bd23d22 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt @@ -3,6 +3,7 @@ package io.holunda.polyflow.view.jpa import com.fasterxml.jackson.databind.ObjectMapper import io.holixon.axon.gateway.query.QueryResponseMessageResponseType import io.holixon.axon.gateway.query.RevisionValue +import io.holunda.camunda.taskpool.api.business.DataEntryAnonymizedEvent import io.holunda.camunda.taskpool.api.business.DataEntryCreatedEvent import io.holunda.camunda.taskpool.api.business.DataEntryDeletedEvent import io.holunda.camunda.taskpool.api.business.DataEntryUpdatedEvent @@ -165,6 +166,25 @@ class JpaPolyflowViewDataEntryService( } } + @Suppress("unused") + @EventHandler + override fun on(event: DataEntryAnonymizedEvent, metaData: MetaData) { + if (isDisabledByProperty()) return + + val savedEntity = dataEntryRepository.findByIdOrNull(DataEntryId(entryType = event.entryType, entryId = event.entryId)) + if (savedEntity != null) { + val entity = dataEntryRepository.save( + event.toEntity( + revisionValue = RevisionValue.fromMetaData(metaData), + oldEntry = savedEntity, + ) + ).apply { + logger.debug { "JPA-VIEW-45: Business data entry anonymized $event" } + } + emitDataEntryUpdate(entity) + } + } + /** * Constructs response message slicing it. */ diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt index a26383181..94225e34c 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt @@ -192,3 +192,26 @@ fun DataEntryDeletedEvent.toEntity( }.apply { this.protocol = this.protocol.addModification(this, this@toEntity.deleteModification, this@toEntity.state) } + +/** + * Event to entity for an anonymization, if an optional entry exists. + */ +fun DataEntryAnonymizedEvent.toEntity( + revisionValue: RevisionValue, + oldEntry: DataEntryEntity, +) = oldEntry.also { + it.protocol.forEach { protocolEntry -> + if (protocolEntry.username != null && !this.excludedUsernames.contains(protocolEntry.username)) + protocolEntry.username = this.anonymizedUsername + } + it.authorizedPrincipals = + it.authorizedPrincipals.filter { principal -> !principal.startsWith("USER:") }.toMutableSet() + it.lastModifiedDate = this.anonymizeModification.time.toInstant() + it.revision = if (revisionValue != RevisionValue.NO_REVISION) { + revisionValue.revision + } else { + it.revision + } +}.apply { + this.protocol = this.protocol.addModification(this, this@toEntity.anonymizeModification, this.state.toState()) +} diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEventHandler.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEventHandler.kt index f59b2d7e9..17d827e99 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEventHandler.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEventHandler.kt @@ -1,5 +1,6 @@ package io.holunda.polyflow.view.jpa.data +import io.holunda.camunda.taskpool.api.business.DataEntryAnonymizedEvent import io.holunda.camunda.taskpool.api.business.DataEntryCreatedEvent import io.holunda.camunda.taskpool.api.business.DataEntryDeletedEvent import io.holunda.camunda.taskpool.api.business.DataEntryUpdatedEvent @@ -24,4 +25,9 @@ interface DataEntryEventHandler { * Data entry deleted. */ fun on(event: DataEntryDeletedEvent, metaData: MetaData) + + /** + * Data entry anonymized. + */ + fun on(event: DataEntryAnonymizedEvent, metaData: MetaData) } diff --git a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt index c43aa675e..5fa87df06 100644 --- a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt +++ b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewServiceDataEntryITest.kt @@ -356,6 +356,32 @@ internal class JpaPolyflowViewServiceDataEntryITest { assertThat(result.payload.elements.map { it.entryId }).containsExactly(id2) // id4 is not found by correlation to id2, due to property } + @Test + fun `should anonymize data entry`() { + jpaPolyflowViewService.on( + event = DataEntryAnonymizedEvent( + entryType = "io.polyflow.test", + entryId = id4, + anonymizedUsername = "ANONYMOUS", + excludedUsernames = listOf("SYSTEM"), + anonymizeModification = Modification( + time = OffsetDateTime.ofInstant(now, ZoneOffset.UTC), + username = "SYSTEM", + log = "Created", + logNotes = "Created the entry" + ), + ), + metaData = MetaData.emptyInstance() + ) + + val result = jpaPolyflowViewService.query( + DataEntryForIdentityQuery(entryType = "io.polyflow.test", entryId = id4) + ) + + assertThat(result.payload).matches { entry -> entry.protocol.all { it.username in listOf("SYSTEM", "ANONYMOUS") } } + assertThat(result.payload).matches { entry -> entry.authorizedUsers.isEmpty() } + } + @Test fun `should find data entry by involvements`() { val result = jpaPolyflowViewService.query( diff --git a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/TestFixtures.kt b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/TestFixtures.kt index 0208e69df..ff46d3bdd 100644 --- a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/TestFixtures.kt +++ b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/TestFixtures.kt @@ -1,5 +1,6 @@ package io.holunda.polyflow.view.jpa +import io.holunda.camunda.taskpool.api.business.DataEntryAnonymizedEvent import io.holunda.camunda.taskpool.api.business.DataEntryCreatedEvent import io.holunda.camunda.taskpool.api.business.DataEntryDeletedEvent import io.holunda.camunda.taskpool.api.business.DataEntryUpdatedEvent @@ -83,4 +84,5 @@ class JpaPolyflowViewServiceTxFacade(private val implementation: JpaPolyflowView override fun on(event: DataEntryDeletedEvent, metaData: MetaData) = implementation.on(event = event, metaData = metaData) + override fun on(event: DataEntryAnonymizedEvent, metaData: MetaData) = implementation.on(event = event, metaData = metaData) } diff --git a/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExtKtTest.kt b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExtKtTest.kt new file mode 100644 index 000000000..6a680a83a --- /dev/null +++ b/view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExtKtTest.kt @@ -0,0 +1,45 @@ +package io.holunda.polyflow.view.jpa.data + + +import io.holixon.axon.gateway.query.RevisionValue +import io.holunda.camunda.taskpool.api.business.DataEntryAnonymizedEvent +import io.holunda.camunda.taskpool.api.business.Modification +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.groups.Tuple.tuple +import org.junit.jupiter.api.Test +import java.time.OffsetDateTime + +class ConverterExtKtTest { + @Test + fun shouldAnonymizeDataEntry() { + val now = OffsetDateTime.now() + val event = DataEntryAnonymizedEvent( + "type", + "id", + "ANONYMIZED", + listOf("SYSTEM"), + Modification(now, "SYSTEM", "anonymize", "anonymize") + ) + + val entity = DataEntryEntity( + dataEntryId = DataEntryId("id", "type"), + type = "type", + name = "name", + applicationName = "applicationName", + state = DataEntryStateEmbeddable("IN_PROGRESS", "state"), + authorizedPrincipals = mutableSetOf("USER:example:luffy", "GROUP:example:strawhats") + ).also { + it.protocol + .addModification(it, Modification(username = "luffy"), it.state.toState()) + .addModification(it, Modification(username = "zoro"), it.state.toState()) + .addModification(it, Modification(username = "SYSTEM"), it.state.toState()) + } + + val anonymized = event.toEntity(RevisionValue.NO_REVISION, entity) + + assertThat(anonymized.authorizedPrincipals).hasSize(1) + assertThat(anonymized.authorizedPrincipals).allMatch { it.startsWith("GROUP") } + assertThat(anonymized.protocol).extracting(ProtocolElement::username) + .containsExactly(tuple("ANONYMIZED"), tuple("ANONYMIZED"), tuple("SYSTEM"), tuple("SYSTEM")) + } +} \ No newline at end of file diff --git a/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/Converters.kt b/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/Converters.kt index 637a1331e..1d8f52789 100644 --- a/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/Converters.kt +++ b/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/Converters.kt @@ -80,6 +80,31 @@ fun DataEntryUpdatedEvent.toDocument(oldDocument: DataEntryDocument?) = if (oldD ) } +/** + * Anonymized event to document. + */ +fun DataEntryAnonymizedEvent.toDocument(oldDocument: DataEntryDocument): DataEntryDocument { + val authorizedUsers = AuthorizationChange.applyUserAuthorization( + oldDocument.getAuthorizedUsers(), + oldDocument.getAuthorizedUsers().map { AuthorizationChange.removeUser(it) }) + + val protocol = oldDocument.protocol.map { it.toProtocol() }.map { + it.copy( + username = if (it.username != null && !this.excludedUsernames.contains(it.username)) this.anonymizedUsername else it.username + ) + }.addModification( + this.anonymizeModification, DataEntryStateImpl( + ProcessingType.valueOf(oldDocument.statusType ?: ProcessingType.UNDEFINED.name), oldDocument.state ?: "" + ) + ).map { it.toProtocolElement() } + + return oldDocument.copy( + authorizedUsers = authorizedUsers, + authorizedPrincipals = DataEntryDocument.authorizedPrincipals(authorizedUsers, oldDocument.getAuthorizedGroups()), + protocol = protocol, + lastModifiedDate = this.anonymizeModification.time.toInstant() + ) +} /** * Create a task with data entries from the corresponding mongo document. diff --git a/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/MongoViewService.kt b/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/MongoViewService.kt index e181b5f42..d6b7af642 100755 --- a/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/MongoViewService.kt +++ b/view/mongo/src/main/kotlin/io/holunda/polyflow/view/mongo/MongoViewService.kt @@ -437,6 +437,19 @@ class MongoViewService( deleteDataEntry(dataIdentityString(entryType = event.entryType, entryId = event.entryId)) } + /** + * Delivers data entry anonymized event. + */ + @Suppress("unused") + @EventHandler + fun on(event: DataEntryAnonymizedEvent, metaData: MetaData) { + logger.debug { "Business data entry anonymized $event" } + dataEntryRepository.findNotDeletedById(dataIdentityString(entryType = event.entryType, entryId = event.entryId)) + .map { oldEntry -> event.toDocument(oldEntry) }.map { dataEntryRepository.save(it) } + .then(updateDataEntryQuery(QueryDataIdentity(entryType = event.entryType, entryId = event.entryId))) + .block() + } + private fun deleteDataEntry(id: String) { dataEntryRepository.findNotDeletedById(id) .retryIfEmpty { "Cannot delete data entry '$id' because it does not exist in the database" } diff --git a/view/mongo/src/test/kotlin/io/holunda/polyflow/view/mongo/service/PolyflowStages.kt b/view/mongo/src/test/kotlin/io/holunda/polyflow/view/mongo/service/PolyflowStages.kt index ba5b08982..ba6a2325c 100644 --- a/view/mongo/src/test/kotlin/io/holunda/polyflow/view/mongo/service/PolyflowStages.kt +++ b/view/mongo/src/test/kotlin/io/holunda/polyflow/view/mongo/service/PolyflowStages.kt @@ -3,6 +3,7 @@ package io.holunda.polyflow.view.mongo.service import com.tngtech.jgiven.Stage import com.tngtech.jgiven.annotation.* import com.tngtech.jgiven.integration.spring.JGivenStage +import io.holunda.camunda.taskpool.api.business.DataEntryAnonymizedEvent import io.holunda.camunda.taskpool.api.business.DataEntryCreatedEvent import io.holunda.camunda.taskpool.api.business.DataEntryDeletedEvent import io.holunda.camunda.taskpool.api.business.DataEntryUpdatedEvent @@ -92,6 +93,10 @@ abstract class PolyflowStage> : Stage() { service.on(event, MetaData.emptyInstance()) } + fun data_entry_anonymized_event_is_received(event: DataEntryAnonymizedEvent) = step { + service.on(event, MetaData.emptyInstance()) + } + protected fun captureEmittedQueryUpdates(): List> { val queryTypeCaptor = argumentCaptor>() val predicateCaptor = argumentCaptor>() diff --git a/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/Converters.kt b/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/Converters.kt index ac619c47b..f326ecd9f 100644 --- a/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/Converters.kt +++ b/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/Converters.kt @@ -1,8 +1,6 @@ package io.holunda.polyflow.view.simple.service -import io.holunda.camunda.taskpool.api.business.AuthorizationChange -import io.holunda.camunda.taskpool.api.business.DataEntryCreatedEvent -import io.holunda.camunda.taskpool.api.business.DataEntryUpdatedEvent +import io.holunda.camunda.taskpool.api.business.* import io.holunda.camunda.taskpool.api.process.instance.ProcessInstanceCancelledEvent import io.holunda.camunda.taskpool.api.process.instance.ProcessInstanceEndedEvent import io.holunda.camunda.taskpool.api.process.instance.ProcessInstanceStartedEvent @@ -66,6 +64,20 @@ fun DataEntryCreatedEvent.toDataEntry() = DataEntry( protocol = listOf().addModification(this.createModification, this.state) ) +/** + * Event to entry for an update, if an optional entry exists. + */ +fun DataEntryAnonymizedEvent.toDataEntry(oldEntry: DataEntry) = + oldEntry.copy( + authorizedUsers = AuthorizationChange.applyUserAuthorization(oldEntry.authorizedUsers, + oldEntry.authorizedUsers.map { AuthorizationChange.removeUser(it) }), + protocol = oldEntry.protocol.map { + it.copy( + username = + if (it.username != null && !this.excludedUsernames.contains(it.username)) + this.anonymizedUsername else it.username) } + .addModification(this.anonymizeModification, oldEntry.state)) + /** * Converts event to view model. */ diff --git a/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/SimpleDataEntryService.kt b/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/SimpleDataEntryService.kt index 5537b4ced..f98f7be90 100644 --- a/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/SimpleDataEntryService.kt +++ b/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/SimpleDataEntryService.kt @@ -2,10 +2,7 @@ package io.holunda.polyflow.view.simple.service import io.holixon.axon.gateway.query.QueryResponseMessageResponseType import io.holixon.axon.gateway.query.RevisionValue -import io.holunda.camunda.taskpool.api.business.DataEntryCreatedEvent -import io.holunda.camunda.taskpool.api.business.DataEntryDeletedEvent -import io.holunda.camunda.taskpool.api.business.DataEntryUpdatedEvent -import io.holunda.camunda.taskpool.api.business.dataIdentityString +import io.holunda.camunda.taskpool.api.business.* import io.holunda.polyflow.view.DataEntry import io.holunda.polyflow.view.filter.createDataEntryPredicates import io.holunda.polyflow.view.filter.filterByPredicate @@ -76,6 +73,22 @@ class SimpleDataEntryService( revisionSupport.deleteRevision(entryId) } + /** + * Anonymized data entry. + */ + @Suppress("unused") + @EventHandler + fun on(event: DataEntryAnonymizedEvent, metaData: MetaData) { + logger.debug { "SIMPLE-VIEW-34: Business data entry anonymized $event" } + val entryId = dataIdentityString(entryType = event.entryType, entryId = event.entryId) + dataEntries[entryId]?.let { + dataEntries[entryId] = event.toDataEntry(it) + revisionSupport.updateRevision(entryId, RevisionValue.fromMetaData(metaData)) + updateDataEntryQuery(entryId) + } + + } + /** * Retrieves a list of all data entries of given entry type (and optional id). */ diff --git a/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/SimpleTaskPoolService.kt b/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/SimpleTaskPoolService.kt index 8767b39ae..588d6e39c 100755 --- a/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/SimpleTaskPoolService.kt +++ b/view/simple/src/main/kotlin/io/holunda/polyflow/view/simple/service/SimpleTaskPoolService.kt @@ -1,9 +1,6 @@ package io.holunda.polyflow.view.simple.service -import io.holunda.camunda.taskpool.api.business.DataEntryCreatedEvent -import io.holunda.camunda.taskpool.api.business.DataEntryDeletedEvent -import io.holunda.camunda.taskpool.api.business.DataEntryUpdatedEvent -import io.holunda.camunda.taskpool.api.business.dataIdentityString +import io.holunda.camunda.taskpool.api.business.* import io.holunda.camunda.taskpool.api.task.* import io.holunda.polyflow.view.DataEntry import io.holunda.polyflow.view.Task @@ -357,6 +354,23 @@ class SimpleTaskPoolService( } } + /** + * Anonymize data entry. + */ + @Suppress("unused") + @EventHandler + fun on(event: DataEntryAnonymizedEvent) { + logger.debug { "SIMPLE-VIEW-35: Business data entry anonymized $event" } + val entryId = dataIdentityString(entryType = event.entryType, entryId = event.entryId) + dataEntries[entryId]?.let { + dataEntries[entryId] = event.toDataEntry(it) + findTasksForDataEntry(entryId).forEach { taskId -> + val task = tasks[taskId]!! + updateFilteredQueryQuery(task.id) + } + } + } + /** * Read-only stored data. */ diff --git a/view/simple/src/test/kotlin/io/holunda/polyflow/view/simple/service/ConvertersKtTest.kt b/view/simple/src/test/kotlin/io/holunda/polyflow/view/simple/service/ConvertersKtTest.kt new file mode 100644 index 000000000..4f8d53c70 --- /dev/null +++ b/view/simple/src/test/kotlin/io/holunda/polyflow/view/simple/service/ConvertersKtTest.kt @@ -0,0 +1,39 @@ +package io.holunda.polyflow.view.simple.service + +import io.holunda.camunda.taskpool.api.business.DataEntryAnonymizedEvent +import io.holunda.camunda.taskpool.api.business.Modification +import io.holunda.polyflow.view.DataEntry +import io.holunda.polyflow.view.addModification +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import java.time.OffsetDateTime + +class ConvertersKtTest { + @Test + fun `should apply anonymization`() { + val now = OffsetDateTime.now() + val event = DataEntryAnonymizedEvent( + "type", "id", "ANONYMIZED", listOf("SYSTEM"), Modification(now, "SYSTEM", "anonymize", "anonymize") + ) + + val dataEntry = DataEntry( + entryId = "id", + entryType = "type", + applicationName = "application name", + name = "name", + type = "type", + authorizedGroups = setOf("strawhats"), + authorizedUsers = setOf("luffy") + ).also { + it.protocol.addModification(Modification(username = "luffy"), it.state) + it.protocol.addModification(Modification(username = "zoro"), it.state) + it.protocol.addModification(Modification(username = "SYSTEM"), it.state) + } + + val anonymized = event.toDataEntry(dataEntry) + + assertThat(anonymized.authorizedGroups).containsExactly("strawhats") + assertThat(anonymized.authorizedUsers).isEmpty() + assertThat(anonymized.protocol).allMatch { it.username in listOf("SYSTEM", "ANONYMIZED") } + } +} \ No newline at end of file From f53513abac6726bb26decdf26ecf2f59aa7292b7 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Mon, 1 Jul 2024 14:08:00 +0200 Subject: [PATCH 13/13] Update for next development version --- bom/datapool-dependencies/pom.xml | 2 +- bom/parent/pom.xml | 2 +- bom/taskpool-dependencies/pom.xml | 2 +- core/bus-jackson/pom.xml | 2 +- core/datapool/datapool-api/pom.xml | 2 +- core/datapool/datapool-core/pom.xml | 2 +- core/datapool/datapool-event/pom.xml | 2 +- core/datapool/pom.xml | 2 +- core/spring-utils/pom.xml | 2 +- core/taskpool/pom.xml | 2 +- core/taskpool/taskpool-api/pom.xml | 2 +- core/taskpool/taskpool-core/pom.xml | 2 +- core/taskpool/taskpool-event/pom.xml | 2 +- integration/camunda-bpm/engine-client/pom.xml | 2 +- integration/camunda-bpm/pom.xml | 2 +- integration/camunda-bpm/springboot-autoconfigure/pom.xml | 2 +- integration/camunda-bpm/springboot-starter/pom.xml | 2 +- integration/camunda-bpm/taskpool-collector/pom.xml | 2 +- integration/camunda-bpm/taskpool-job-sender/pom.xml | 2 +- integration/common/datapool-sender/pom.xml | 2 +- integration/common/pom.xml | 2 +- integration/common/tasklist-url-resolver/pom.xml | 2 +- integration/common/taskpool-sender/pom.xml | 2 +- integration/common/variable-serializer/pom.xml | 2 +- pom.xml | 2 +- view/form-url-resolver/pom.xml | 2 +- view/jpa/pom.xml | 2 +- view/mongo/pom.xml | 2 +- view/pom.xml | 2 +- view/simple/pom.xml | 2 +- view/view-api-client/pom.xml | 2 +- view/view-api/pom.xml | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/bom/datapool-dependencies/pom.xml b/bom/datapool-dependencies/pom.xml index 24961c0dc..752228684 100644 --- a/bom/datapool-dependencies/pom.xml +++ b/bom/datapool-dependencies/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.2.0-SNAPSHOT + 4.2.0 ../parent/pom.xml diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index 8ad29c645..372fda354 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-root - 4.2.0-SNAPSHOT + 4.2.0 ../../pom.xml diff --git a/bom/taskpool-dependencies/pom.xml b/bom/taskpool-dependencies/pom.xml index b36e8f2e7..a8899a999 100644 --- a/bom/taskpool-dependencies/pom.xml +++ b/bom/taskpool-dependencies/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.2.0-SNAPSHOT + 4.2.0 ../parent/pom.xml diff --git a/core/bus-jackson/pom.xml b/core/bus-jackson/pom.xml index 98ba622aa..5df9566c5 100755 --- a/core/bus-jackson/pom.xml +++ b/core/bus-jackson/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.2.0-SNAPSHOT + 4.2.0 ../../bom/parent/pom.xml diff --git a/core/datapool/datapool-api/pom.xml b/core/datapool/datapool-api/pom.xml index 1cf2d9e36..1a82d5ece 100755 --- a/core/datapool/datapool-api/pom.xml +++ b/core/datapool/datapool-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-datapool-api diff --git a/core/datapool/datapool-core/pom.xml b/core/datapool/datapool-core/pom.xml index 80d6b01a7..253dede0f 100644 --- a/core/datapool/datapool-core/pom.xml +++ b/core/datapool/datapool-core/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-datapool-core diff --git a/core/datapool/datapool-event/pom.xml b/core/datapool/datapool-event/pom.xml index ec512df4c..2d01870c6 100755 --- a/core/datapool/datapool-event/pom.xml +++ b/core/datapool/datapool-event/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-datapool-event diff --git a/core/datapool/pom.xml b/core/datapool/pom.xml index 2ec5f5863..593e93d5d 100755 --- a/core/datapool/pom.xml +++ b/core/datapool/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.2.0-SNAPSHOT + 4.2.0 ../../bom/parent/pom.xml diff --git a/core/spring-utils/pom.xml b/core/spring-utils/pom.xml index e120c0e30..d92185d16 100755 --- a/core/spring-utils/pom.xml +++ b/core/spring-utils/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.2.0-SNAPSHOT + 4.2.0 ../../bom/parent/pom.xml diff --git a/core/taskpool/pom.xml b/core/taskpool/pom.xml index 10cc00a60..0137c4866 100755 --- a/core/taskpool/pom.xml +++ b/core/taskpool/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.2.0-SNAPSHOT + 4.2.0 ../../bom/parent/pom.xml diff --git a/core/taskpool/taskpool-api/pom.xml b/core/taskpool/taskpool-api/pom.xml index 5d64adc69..dfee6e55c 100755 --- a/core/taskpool/taskpool-api/pom.xml +++ b/core/taskpool/taskpool-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-taskpool-api diff --git a/core/taskpool/taskpool-core/pom.xml b/core/taskpool/taskpool-core/pom.xml index 8865c1bef..ad4bc2753 100755 --- a/core/taskpool/taskpool-core/pom.xml +++ b/core/taskpool/taskpool-core/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-taskpool-core diff --git a/core/taskpool/taskpool-event/pom.xml b/core/taskpool/taskpool-event/pom.xml index 97693357e..5052dd443 100644 --- a/core/taskpool/taskpool-event/pom.xml +++ b/core/taskpool/taskpool-event/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-taskpool-event diff --git a/integration/camunda-bpm/engine-client/pom.xml b/integration/camunda-bpm/engine-client/pom.xml index 251640522..15b304011 100644 --- a/integration/camunda-bpm/engine-client/pom.xml +++ b/integration/camunda-bpm/engine-client/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-camunda-bpm-engine-client diff --git a/integration/camunda-bpm/pom.xml b/integration/camunda-bpm/pom.xml index 052dbb9f0..e5b430dbe 100644 --- a/integration/camunda-bpm/pom.xml +++ b/integration/camunda-bpm/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.2.0-SNAPSHOT + 4.2.0 ../../bom/parent/pom.xml diff --git a/integration/camunda-bpm/springboot-autoconfigure/pom.xml b/integration/camunda-bpm/springboot-autoconfigure/pom.xml index b19f2dd16..30646e3fa 100755 --- a/integration/camunda-bpm/springboot-autoconfigure/pom.xml +++ b/integration/camunda-bpm/springboot-autoconfigure/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-camunda-bpm-springboot-autoconfigure diff --git a/integration/camunda-bpm/springboot-starter/pom.xml b/integration/camunda-bpm/springboot-starter/pom.xml index 0170629c0..0fd4fd802 100755 --- a/integration/camunda-bpm/springboot-starter/pom.xml +++ b/integration/camunda-bpm/springboot-starter/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-camunda-bpm-springboot-starter diff --git a/integration/camunda-bpm/taskpool-collector/pom.xml b/integration/camunda-bpm/taskpool-collector/pom.xml index 640902bba..9fe3ce864 100755 --- a/integration/camunda-bpm/taskpool-collector/pom.xml +++ b/integration/camunda-bpm/taskpool-collector/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-camunda-bpm-taskpool-collector diff --git a/integration/camunda-bpm/taskpool-job-sender/pom.xml b/integration/camunda-bpm/taskpool-job-sender/pom.xml index 2b00ed79c..46f9776f3 100755 --- a/integration/camunda-bpm/taskpool-job-sender/pom.xml +++ b/integration/camunda-bpm/taskpool-job-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-camunda-bpm-taskpool-job-sender diff --git a/integration/common/datapool-sender/pom.xml b/integration/common/datapool-sender/pom.xml index 833edce4f..8c3818fc3 100755 --- a/integration/common/datapool-sender/pom.xml +++ b/integration/common/datapool-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-datapool-sender diff --git a/integration/common/pom.xml b/integration/common/pom.xml index f60cc068e..d9482f078 100755 --- a/integration/common/pom.xml +++ b/integration/common/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.2.0-SNAPSHOT + 4.2.0 ../../bom/parent/pom.xml diff --git a/integration/common/tasklist-url-resolver/pom.xml b/integration/common/tasklist-url-resolver/pom.xml index 7f43498eb..ddb15eb10 100644 --- a/integration/common/tasklist-url-resolver/pom.xml +++ b/integration/common/tasklist-url-resolver/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-tasklist-url-resolver diff --git a/integration/common/taskpool-sender/pom.xml b/integration/common/taskpool-sender/pom.xml index 09ece3f2b..bb6e1f963 100755 --- a/integration/common/taskpool-sender/pom.xml +++ b/integration/common/taskpool-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-taskpool-sender diff --git a/integration/common/variable-serializer/pom.xml b/integration/common/variable-serializer/pom.xml index e8cd375a0..e4e3f334e 100755 --- a/integration/common/variable-serializer/pom.xml +++ b/integration/common/variable-serializer/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-variable-serializer diff --git a/pom.xml b/pom.xml index ee322f86a..e16749dac 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-root - 4.2.0-SNAPSHOT + 4.2.0 pom POM: ${project.artifactId} diff --git a/view/form-url-resolver/pom.xml b/view/form-url-resolver/pom.xml index b0d673e79..6ea885d88 100644 --- a/view/form-url-resolver/pom.xml +++ b/view/form-url-resolver/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-form-url-resolver diff --git a/view/jpa/pom.xml b/view/jpa/pom.xml index 683a48bac..d1ef4e0b5 100644 --- a/view/jpa/pom.xml +++ b/view/jpa/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-view-jpa diff --git a/view/mongo/pom.xml b/view/mongo/pom.xml index b55b65695..6307ea853 100644 --- a/view/mongo/pom.xml +++ b/view/mongo/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-view-mongo diff --git a/view/pom.xml b/view/pom.xml index 41b300d6a..2b08ec2c0 100644 --- a/view/pom.xml +++ b/view/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 4.2.0-SNAPSHOT + 4.2.0 ../bom/parent/pom.xml diff --git a/view/simple/pom.xml b/view/simple/pom.xml index 75546ae31..f714e5ff2 100755 --- a/view/simple/pom.xml +++ b/view/simple/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-view-simple diff --git a/view/view-api-client/pom.xml b/view/view-api-client/pom.xml index 53a6fe5e8..54eaef85a 100755 --- a/view/view-api-client/pom.xml +++ b/view/view-api-client/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-view-api-client diff --git a/view/view-api/pom.xml b/view/view-api/pom.xml index 1b84ccd71..023c9c34e 100755 --- a/view/view-api/pom.xml +++ b/view/view-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 4.2.0-SNAPSHOT + 4.2.0 polyflow-view-api