From 42161af5a80a1f47d12db0f5dd85234ff4f8c320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Wed, 31 Jul 2024 18:34:01 +0200 Subject: [PATCH 1/2] incubator-kie-issues#1408: Enable a JPA version of the Data Index Addons (#2085) * incubator-kie-issues#1408: Enable a JPA version of the Data Index Addons * fix build * Fix ProcessDefinitionRegister: setting right ProcessDefinition type on register * Remove non standard SQL syntax --- .../data-index-storage-jpa-common/pom.xml | 2 +- .../data-index-storage-jpa/pom.xml | 11 +- .../migration/V1.33.0__data_index_create.sql | 18 +-- .../V1.44.0__data_index_definitions.sql | 26 ++-- ...V1.45.0.0__data_index_node_definitions.sql | 22 +-- ....2__data_index_definitions_add_colums.sql} | 16 +-- .../db/migration/V1.45.0.3__add_fk_index.sql | 36 +++++ ...=> V1.45.0.4__increase_varchar_length.sql} | 0 .../addon/ProcessDefinitionRegister.java | 2 +- .../deployment/pom.xml | 70 ++++++++++ .../JPASQLDataIndexPersistenceProcessor.java | 41 ++++++ .../integration-tests-process/pom.xml | 130 ++++++++++++++++++ .../resources/META-INF/processSVG/hello.svg | 71 ++++++++++ .../src/main/resources/application.properties | 34 +++++ .../src/main/resources/hello.bpmn | 47 +++++++ ...AQuarkusAddonDataIndexPersistenceTest.java | 113 +++++++++++++++ .../integration-tests-sw/pom.xml | 129 +++++++++++++++++ .../src/main/resources/application.properties | 35 +++++ .../src/main/resources/greet.sw.json | 71 ++++++++++ ...AQuarkusAddonDataIndexPersistenceTest.java | 112 +++++++++++++++ .../pom.xml | 46 +++++++ .../runtime/pom.xml | 81 +++++++++++ .../resources/META-INF/quarkus-extension.yaml | 35 +++++ .../src/main/resources/application.properties | 27 ++++ .../pom.xml | 1 + .../deployment/pom.xml | 83 +++++++++++ .../deployment/JPADataIndexProcessor.java | 48 +++++++ .../resources/dev-templates/dataindex.html | 32 +++++ .../resources/dev-templates/embedded.html | 24 ++++ .../integration-tests-process/pom.xml | 120 ++++++++++++++++ .../resources/META-INF/processSVG/hello.svg | 71 ++++++++++ .../src/main/resources/application.properties | 35 +++++ .../src/main/resources/hello.bpmn | 47 +++++++ .../index/it/JPAQuarkusAddonDataIndexIT.java | 85 ++++++++++++ .../integration-tests-sw/pom.xml | 116 ++++++++++++++++ .../src/main/resources/application.properties | 35 +++++ .../src/main/resources/greet.sw.json | 71 ++++++++++ .../index/it/JPAQuarkusAddonDataIndexIT.java | 87 ++++++++++++ .../pom.xml | 46 +++++++ .../runtime/pom.xml | 81 +++++++++++ .../resources/META-INF/quarkus-extension.yaml | 38 +++++ .../src/main/resources/application.properties | 28 ++++ .../kogito-addons-quarkus-data-index/pom.xml | 1 + kogito-apps-bom/pom.xml | 56 +++++++- .../persistence-commons-jpa-base/pom.xml | 97 +++++++++++++ .../persistence/postgresql/Constants.java | 0 .../persistence/postgresql/PostgresQuery.java | 0 .../postgresql/PostgresStorage.java | 0 .../postgresql/PostgresStorageService.java | 0 .../hibernate/JsonBinaryConverter.java | 0 .../postgresql/hibernate/JsonBinaryType.java | 0 .../postgresql/model/CacheEntity.java | 0 .../model/CacheEntityRepository.java | 0 .../persistence/postgresql/model/CacheId.java | 0 .../src/main/resources/META-INF/beans.xml | 0 .../persistence-commons-jpa/pom.xml | 33 +---- ...__kogito_apps_create_kogito_data_cache.sql | 25 ++++ .../persistence-commons-postgresql/pom.xml | 2 +- ...__kogito_apps_create_kogito_data_cache.sql | 26 ++++ persistence-commons/pom.xml | 1 + 60 files changed, 2384 insertions(+), 80 deletions(-) rename data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/{V1.45.0.2__data_index_definitions_add_collums.sql => V1.45.0.2__data_index_definitions_add_colums.sql} (78%) create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.3__add_fk_index.sql rename data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/{V1.45.0.3__increase_varchar_length.sql => V1.45.0.4__increase_varchar_length.sql} (100%) create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/deployment/pom.xml create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/persistence/deployment/JPASQLDataIndexPersistenceProcessor.java create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/pom.xml create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/application.properties create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/hello.bpmn create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexPersistenceTest.java create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/pom.xml create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/main/resources/application.properties create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/main/resources/greet.sw.json create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexPersistenceTest.java create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/pom.xml create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/pom.xml create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml create mode 100644 data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/src/main/resources/application.properties create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/pom.xml create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/deployment/JPADataIndexProcessor.java create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/resources/dev-templates/dataindex.html create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/resources/dev-templates/embedded.html create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/pom.xml create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/application.properties create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/hello.bpmn create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexIT.java create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/pom.xml create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/main/resources/application.properties create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/main/resources/greet.sw.json create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexIT.java create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/pom.xml create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/pom.xml create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml create mode 100644 data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/src/main/resources/application.properties create mode 100644 persistence-commons/persistence-commons-jpa-base/pom.xml rename persistence-commons/{persistence-commons-jpa => persistence-commons-jpa-base}/src/main/java/org/kie/kogito/persistence/postgresql/Constants.java (100%) rename persistence-commons/{persistence-commons-jpa => persistence-commons-jpa-base}/src/main/java/org/kie/kogito/persistence/postgresql/PostgresQuery.java (100%) rename persistence-commons/{persistence-commons-jpa => persistence-commons-jpa-base}/src/main/java/org/kie/kogito/persistence/postgresql/PostgresStorage.java (100%) rename persistence-commons/{persistence-commons-jpa => persistence-commons-jpa-base}/src/main/java/org/kie/kogito/persistence/postgresql/PostgresStorageService.java (100%) rename persistence-commons/{persistence-commons-jpa => persistence-commons-jpa-base}/src/main/java/org/kie/kogito/persistence/postgresql/hibernate/JsonBinaryConverter.java (100%) rename persistence-commons/{persistence-commons-jpa => persistence-commons-jpa-base}/src/main/java/org/kie/kogito/persistence/postgresql/hibernate/JsonBinaryType.java (100%) rename persistence-commons/{persistence-commons-jpa => persistence-commons-jpa-base}/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java (100%) rename persistence-commons/{persistence-commons-jpa => persistence-commons-jpa-base}/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntityRepository.java (100%) rename persistence-commons/{persistence-commons-jpa => persistence-commons-jpa-base}/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheId.java (100%) rename persistence-commons/{persistence-commons-jpa => persistence-commons-jpa-base}/src/main/resources/META-INF/beans.xml (100%) create mode 100644 persistence-commons/persistence-commons-jpa/src/main/resources/db/migration/V1.5.0__kogito_apps_create_kogito_data_cache.sql create mode 100644 persistence-commons/persistence-commons-postgresql/src/main/resources/db/migration/V1.5.0__kogito_apps_create_kogito_data_cache.sql diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/pom.xml b/data-index/data-index-storage/data-index-storage-jpa-common/pom.xml index d9d262ac0f..d730218276 100644 --- a/data-index/data-index-storage/data-index-storage-jpa-common/pom.xml +++ b/data-index/data-index-storage/data-index-storage-jpa-common/pom.xml @@ -48,7 +48,7 @@ org.kie.kogito - persistence-commons-jpa + persistence-commons-jpa-base org.mapstruct diff --git a/data-index/data-index-storage/data-index-storage-jpa/pom.xml b/data-index/data-index-storage/data-index-storage-jpa/pom.xml index d5b70212bf..7e52547f18 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/pom.xml +++ b/data-index/data-index-storage/data-index-storage-jpa/pom.xml @@ -42,14 +42,19 @@ data-index-storage-jpa-common - io.quarkus - quarkus-test-h2 - test + org.kie.kogito + persistence-commons-jpa io.quarkus quarkus-jdbc-h2 + + + io.quarkus + quarkus-test-h2 + test + org.kie.kogito data-index-storage-api diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.33.0__data_index_create.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.33.0__data_index_create.sql index 5d315351da..564a9c72e9 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.33.0__data_index_create.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.33.0__data_index_create.sql @@ -43,16 +43,16 @@ create table jobs id varchar(255) not null, callback_endpoint varchar(255), endpoint varchar(255), - execution_counter NUMBER(10), + execution_counter integer, expiration_time timestamp, last_update timestamp, node_instance_id varchar(255), - priority NUMBER(10), + priority integer, process_id varchar(255), process_instance_id varchar(255), - repeat_interval NUMBER(19), - repeat_limit NUMBER(10), - retries NUMBER(10), + repeat_interval bigint, + repeat_limit integer, + retries integer, root_process_id varchar(255), root_process_instance_id varchar(255), scheduled_id varchar(255), @@ -97,8 +97,8 @@ create table processes root_process_id varchar(255), root_process_instance_id varchar(255), start_time timestamp, - state NUMBER(10), - variables blob, + state integer, + variables varbinary(max), CONSTRAINT processes_pk PRIMARY KEY (id), CONSTRAINT processes_variables_json CHECK (variables IS JSON) ); @@ -124,10 +124,10 @@ create table tasks completed timestamp, description varchar(255), endpoint varchar(255), - inputs blob, + inputs varbinary(max), last_update timestamp, name varchar(255), - outputs blob, + outputs varbinary(max), priority varchar(255), process_id varchar(255), process_instance_id varchar(255), diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.44.0__data_index_definitions.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.44.0__data_index_definitions.sql index 96b2ec5f08..4f361d57c1 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.44.0__data_index_definitions.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.44.0__data_index_definitions.sql @@ -19,28 +19,28 @@ create table definitions ( - id varchar2(255 char) not null, - version varchar2(255 char) not null, - name varchar2(255 char), - source blob, - type varchar2(255 char), - endpoint varchar2(255 char), + id varchar2(255) not null, + version varchar2(255) not null, + name varchar2(255), + source bytea, + type varchar2(255), + endpoint varchar2(255), primary key (id, version) ); create table definitions_addons ( - process_id varchar2(255 char) not null, - process_version varchar2(255 char) not null, - addon varchar2(255 char) not null, + process_id varchar2(255) not null, + process_version varchar2(255) not null, + addon varchar2(255) not null, primary key (process_id, process_version, addon) ); create table definitions_roles ( - process_id varchar2(255 char) not null, - process_version varchar2(255 char) not null, - role varchar2(255 char) not null, + process_id varchar2(255) not null, + process_version varchar2(255) not null, + role varchar2(255) not null, primary key (process_id, process_version, role) ); @@ -57,4 +57,4 @@ alter table definitions_roles on delete cascade; alter table processes - add version varchar2(255 char); \ No newline at end of file + add column version varchar2(255); \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.0__data_index_node_definitions.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.0__data_index_node_definitions.sql index ee98614a4e..7bce973a34 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.0__data_index_node_definitions.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.0__data_index_node_definitions.sql @@ -19,22 +19,22 @@ create table definitions_nodes ( - id varchar2(255 char) not null, - name varchar2(255 char), - type varchar2(255 char), - unique_id varchar2(255 char), - process_id varchar2(255 char) not null, - process_version varchar2(255 char) not null, + id varchar2(255) not null, + name varchar2(255), + type varchar2(255), + unique_id varchar2(255), + process_id varchar2(255) not null, + process_version varchar2(255) not null, primary key (id, process_id, process_version) ); create table definitions_nodes_metadata ( - node_id varchar2(255 char) not null, - process_id varchar2(255 char) not null, - process_version varchar2(255 char) not null, - value varchar2(255 char), - key varchar2(255 char) not null, + node_id varchar2(255) not null, + process_id varchar2(255) not null, + process_version varchar2(255) not null, + value varchar2(255), + key varchar2(255) not null, primary key (node_id, process_id, process_version, key) ); diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.2__data_index_definitions_add_collums.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.2__data_index_definitions_add_colums.sql similarity index 78% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.2__data_index_definitions_add_collums.sql rename to data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.2__data_index_definitions_add_colums.sql index 00ec3ce934..8abae1b55a 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.2__data_index_definitions_add_collums.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.2__data_index_definitions_add_colums.sql @@ -19,18 +19,18 @@ create table definitions_annotations ( - value varchar2(255 char) not null, - process_id varchar2(255 char) not null, - process_version varchar2(255 char) not null, + value varchar2(255) not null, + process_id varchar2(255) not null, + process_version varchar2(255) not null, primary key (value, process_id, process_version) ); create table definitions_metadata ( - process_id varchar2(255 char) not null, - process_version varchar2(255 char) not null, - value varchar2(255 char), - key varchar2(255 char) not null, + process_id varchar2(255) not null, + process_version varchar2(255) not null, + value varchar2(255), + key varchar2(255) not null, primary key (process_id, process_version, key) ); @@ -47,5 +47,5 @@ alter table definitions_metadata on delete cascade; alter table definitions - add (description varchar2(255 char)); + add (description varchar2(255)); diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.3__add_fk_index.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.3__add_fk_index.sql new file mode 100644 index 0000000000..c8cc1c3a6c --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.3__add_fk_index.sql @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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 index idx_attachments_tid on attachments(task_id); +create index idx_comments_tid on comments(task_id); +create index idx_definitions_addons_pid_pv on definitions_addons(process_id, process_version); +create index idx_definitions_annotations_pid_pv on definitions_annotations(process_id, process_version); +create index idx_definitions_metadata_pid_pv on definitions_metadata(process_id, process_version); +create index idx_definitions_nodes_pid_pv on definitions_nodes(process_id, process_version); +create index idx_definitions_nodes_metadata_pid_pv on definitions_nodes_metadata(process_id, process_version); +create index idx_definitions_roles_pid_pv on definitions_roles(process_id, process_version); +create index idx_milestones_piid on milestones(process_instance_id); +create index idx_nodes_piid on nodes(process_instance_id); +create index idx_processes_addons_pid on processes_addons(process_id); +create index idx_processes_roles_pid on processes_roles(process_id); +create index idx_tasks_admin_groups_tid on tasks_admin_groups(task_id); +create index idx_tasks_admin_users_tid on tasks_admin_users(task_id); +create index idx_tasks_excluded_users_tid on tasks_excluded_users(task_id); +create index idx_tasks_potential_groups_tid on tasks_potential_groups(task_id); +create index idx_tasks_potential_users_tid on tasks_potential_users(task_id); diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.3__increase_varchar_length.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.4__increase_varchar_length.sql similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.3__increase_varchar_length.sql rename to data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.4__increase_varchar_length.sql diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/ProcessDefinitionRegister.java b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/ProcessDefinitionRegister.java index b291feb5dc..8dcd70904c 100644 --- a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/ProcessDefinitionRegister.java +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/ProcessDefinitionRegister.java @@ -71,7 +71,7 @@ private Function, ProcessDefinition> mapProcessDefinition(Set pd.setId(p.id()); pd.setName(p.name()); pd.setVersion(p.version()); - pd.setType(pd.getType()); + pd.setType(p.type()); pd.setAddons(addons); // See ProcessInstanceEventBatch.buildSource pd.setEndpoint(endpoint + "/" + (p.id().contains(".") ? p.id().substring(p.id().lastIndexOf('.') + 1) : p.id())); diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/deployment/pom.xml b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/deployment/pom.xml new file mode 100644 index 0000000000..0fadc66e68 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/deployment/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa-parent + 999-SNAPSHOT + + kogito-addons-quarkus-data-index-persistence-jpa-deployment + Kogito Apps :: Kogito Addons Quarkus Data Index Persistence JPA :: Deployment + + + org.kie + kogito-addons-quarkus-data-index-persistence-common-deployment + + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa + + + io.quarkus + quarkus-flyway-deployment + + + io.quarkus + quarkus-hibernate-orm-panache-deployment + + + io.quarkus + quarkus-jdbc-h2-deployment + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${version.io.quarkus} + + + + + + + diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/persistence/deployment/JPASQLDataIndexPersistenceProcessor.java b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/persistence/deployment/JPASQLDataIndexPersistenceProcessor.java new file mode 100644 index 0000000000..ef3d052f69 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/persistence/deployment/JPASQLDataIndexPersistenceProcessor.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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. + */ +package org.kie.kogito.addons.quarkus.data.index.persistence.deployment; + +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageResourcePatternsBuildItem; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; + +public class JPASQLDataIndexPersistenceProcessor extends AbstractKogitoAddonsQuarkusDataIndexPersistenceProcessor { + + private static final String FEATURE = "kogito-addons-quarkus-data-index-persistence-jpa"; + + @BuildStep + public FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) + public void addNativeResources(BuildProducer resources) { + resources.produce(new NativeImageResourcePatternsBuildItem.Builder().includeGlob("sql/*.sql").build()); + } + +} diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/pom.xml b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/pom.xml new file mode 100644 index 0000000000..dc97fc4543 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/pom.xml @@ -0,0 +1,130 @@ + + + + 4.0.0 + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa-parent + 999-SNAPSHOT + + kogito-addons-quarkus-data-index-persistence-jpa-integration-tests-process + Kogito Apps :: Kogito Addons Quarkus Data Index Persistence JPA :: Integration Tests :: Process + + + + org.jbpm + jbpm-quarkus + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-resteasy-jackson + + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa + + + org.kie + kie-addons-quarkus-persistence-jdbc + + + org.kie + kie-addons-quarkus-process-svg + + + io.quarkus + quarkus-agroal + + + io.quarkus + quarkus-jdbc-h2 + + + org.assertj + assertj-core + test + + + io.quarkus + quarkus-test-h2 + test + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa-deployment + ${project.version} + pom + test + + + * + * + + + + + + + + io.quarkus + quarkus-maven-plugin + ${version.io.quarkus} + + + + build + + + + + + + + + native + + + native + + + + native + **/*IT.java + + + + diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg new file mode 100644 index 0000000000..716974fb87 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/application.properties b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/application.properties new file mode 100644 index 0000000000..d9cdfadcd3 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/application.properties @@ -0,0 +1,34 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); 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. +# + +kogito.service.url=http://localhost:8080 +kogito.persistence.type=jdbc +quarkus.flyway.migrate-at-start=true + +quarkus.datasource.db-kind=h2 +quarkus.datasource.username=kogito +quarkus.datasource.jdbc.url=jdbc:h2:mem:default;NON_KEYWORDS=VALUE,KEY + +# Not using Keycloak Dev service in test +quarkus.keycloak.devservices.enabled=false + +# Security +quarkus.oidc.enabled=false +quarkus.oidc.tenant-enabled=false +quarkus.oidc.auth-server-url=none diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/hello.bpmn b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/hello.bpmn new file mode 100644 index 0000000000..939c411bbd --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/hello.bpmn @@ -0,0 +1,47 @@ + + + + + + + + + _9FD38FF8-A530-41E7-8EA0-E1F71353CBB3 + + + _9FD38FF8-A530-41E7-8EA0-E1F71353CBB3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _hT2oIPJzEDuE8tm0q8uK_w + _hT2oIPJzEDuE8tm0q8uK_w + + \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexPersistenceTest.java b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexPersistenceTest.java new file mode 100644 index 0000000000..5c3e306d09 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexPersistenceTest.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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. + */ +package org.kie.kogito.addons.quarkus.data.index.it; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.kie.kogito.index.jpa.storage.ProcessDefinitionEntityStorage; +import org.kie.kogito.index.jpa.storage.ProcessInstanceEntityStorage; +import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; +import org.kie.kogito.index.model.ProcessInstance; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +import jakarta.inject.Inject; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +class JPAQuarkusAddonDataIndexPersistenceTest { + + @Inject + ProcessDefinitionEntityStorage processDefinitionEntityStorage; + + @Inject + ProcessInstanceEntityStorage processInstanceEntityStorage; + + static { + RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); + } + + @Test + void testDataIndexAddon() { + + String processDefId = "hello"; + String version = "1.0"; + + ProcessDefinition definition = processDefinitionEntityStorage.get(new ProcessDefinitionKey(processDefId, version)); + + Assertions.assertThat(definition) + .isNotNull() + .hasFieldOrPropertyWithValue("id", processDefId) + .hasFieldOrPropertyWithValue("version", version) + .hasFieldOrPropertyWithValue("name", processDefId) + .hasFieldOrPropertyWithValue("type", "BPMN") + .hasFieldOrProperty("description") + .hasFieldOrProperty("source") + .hasFieldOrProperty("addons") + .hasFieldOrProperty("roles") + .hasFieldOrProperty("endpoint") + .hasFieldOrProperty("nodes"); + + Assertions.assertThat(definition.getSource()) + .isNotBlank(); + + Assertions.assertThat(definition.getAddons()) + .hasSize(3) + .contains("jdbc-persistence", "process-svg", "source-files"); + + Assertions.assertThat(definition.getNodes()) + .hasSize(2); + + String processInstanceId = given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .post("/hello") + .then() + .statusCode(201) + .body("id", is(notNullValue())) + .extract().path("id"); + + Assertions.assertThat(processInstanceId) + .isNotBlank(); + + ProcessInstance instance = processInstanceEntityStorage.get(processInstanceId); + + Assertions.assertThat(instance) + .isNotNull() + .hasFieldOrPropertyWithValue("id", processInstanceId) + .hasFieldOrPropertyWithValue("processId", processDefId) + .hasFieldOrPropertyWithValue("processName", processDefId) + .hasFieldOrPropertyWithValue("version", version) + .hasFieldOrPropertyWithValue("state", 2) + .hasFieldOrProperty("nodes") + .hasFieldOrProperty("start") + .hasFieldOrProperty("end") + .hasFieldOrProperty("lastUpdate"); + } + +} diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/pom.xml b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/pom.xml new file mode 100644 index 0000000000..d231cf9861 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/pom.xml @@ -0,0 +1,129 @@ + + + + 4.0.0 + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa-parent + 999-SNAPSHOT + + kogito-addons-quarkus-data-index-persistence-jpa-integration-tests-sw + Kogito Apps :: Kogito Addons Quarkus Data Index Persistence JPA :: Integration Tests :: SW + + + + org.apache.kie.sonataflow + sonataflow-quarkus + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-resteasy-jackson + + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa + + + org.kie + kie-addons-quarkus-persistence-jdbc + + + org.kie + kie-addons-quarkus-source-files + + + io.quarkus + quarkus-agroal + + + io.quarkus + quarkus-jdbc-h2 + + + io.quarkus + quarkus-test-h2 + test + + + org.kie.kogito + data-index-test-utils + test + + + org.kie.kogito + kogito-test-utils + + + org.assertj + assertj-core + test + + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa-deployment + ${project.version} + pom + test + + + * + * + + + + + + + + io.quarkus + quarkus-maven-plugin + ${version.io.quarkus} + + + + build + + + + + + + + + native + + + native + + + + native + **/*IT.java + + + + diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/main/resources/application.properties b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/main/resources/application.properties new file mode 100644 index 0000000000..d2d4bcade6 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/main/resources/application.properties @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); 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. +# + +kogito.persistence.type=jdbc +kogito.service.url=http://localhost:8080 + +quarkus.flyway.migrate-at-start=true +quarkus.flyway.baseline-on-migrate=true + +quarkus.datasource.db-kind=h2 +quarkus.datasource.username=kogito +quarkus.datasource.jdbc.url=jdbc:h2:mem:default;NON_KEYWORDS=VALUE,KEY + +quarkus.devservices.enabled=false + +# Security +quarkus.oidc.enabled=false +quarkus.oidc.tenant-enabled=false +quarkus.oidc.auth-server-url=none \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/main/resources/greet.sw.json b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/main/resources/greet.sw.json new file mode 100644 index 0000000000..a849f440e1 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/main/resources/greet.sw.json @@ -0,0 +1,71 @@ +{ + "id": "greet", + "version": "1.0", + "name": "Greeting workflow", + "expressionLang": "jsonpath", + "description": "JSON based greeting workflow", + "start": "ChooseOnLanguage", + "functions": [ + { + "name": "greetFunction", + "type": "custom", + "operation": "sysout" + }, + { + "name": "isEnglish", + "type": "expression", + "operation" : "$.[?(@.language == 'English')]" + } + ], + "states": [ + { + "name": "ChooseOnLanguage", + "type": "switch", + "dataConditions": [ + { + "condition": "fn:isEnglish", + "transition": "GreetInEnglish" + }, + { + "condition": "${ $.[?(@.language == 'Spanish')] }", + "transition": "GreetInSpanish" + } + ], + "defaultCondition": { + "transition": "GreetInEnglish" + } + }, + { + "name": "GreetInEnglish", + "type": "inject", + "data": { + "greeting": "Hello from JSON Workflow," + }, + "transition": "GreetPerson" + }, + { + "name": "GreetInSpanish", + "type": "inject", + "data": { + "greeting": "Saludos desde JSON Workflow," + }, + "transition": "GreetPerson" + }, + { + "name": "GreetPerson", + "type": "operation", + "actions": [ + { + "name": "greetAction", + "functionRef": { + "refName": "greetFunction", + "arguments": { + "message": "$.greeting $.name" + } + } + } + ], + "end": true + } + ] +} \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexPersistenceTest.java b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexPersistenceTest.java new file mode 100644 index 0000000000..aa173cee8b --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-sw/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexPersistenceTest.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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. + */ +package org.kie.kogito.addons.quarkus.data.index.it; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.kie.kogito.index.jpa.storage.ProcessDefinitionEntityStorage; +import org.kie.kogito.index.jpa.storage.ProcessInstanceEntityStorage; +import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; +import org.kie.kogito.index.model.ProcessInstance; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +import jakarta.inject.Inject; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +class JPAQuarkusAddonDataIndexPersistenceTest { + + static { + RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); + } + + @Inject + ProcessDefinitionEntityStorage processDefinitionEntityStorage; + + @Inject + ProcessInstanceEntityStorage processInstanceEntityStorage; + + @Test + void testDataIndexAddon() { + String processDefId = "greet"; + String version = "1.0"; + + ProcessDefinition definition = processDefinitionEntityStorage.get(new ProcessDefinitionKey(processDefId, version)); + + Assertions.assertThat(definition) + .isNotNull() + .hasFieldOrPropertyWithValue("id", processDefId) + .hasFieldOrPropertyWithValue("version", version) + .hasFieldOrPropertyWithValue("name", "Greeting workflow") + .hasFieldOrPropertyWithValue("type", "SW") + .hasFieldOrProperty("description") + .hasFieldOrProperty("source") + .hasFieldOrProperty("addons") + .hasFieldOrProperty("roles") + .hasFieldOrProperty("endpoint") + .hasFieldOrProperty("nodes"); + + Assertions.assertThat(definition.getSource()) + .isNotBlank(); + + Assertions.assertThat(definition.getAddons()) + .hasSize(3) + .contains("jdbc-persistence", "source-files", "cloudevents"); + + Assertions.assertThat(definition.getNodes()) + .hasSize(12); + + String processInstanceId = given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body("{\"workflowdata\" : {\"name\" : \"John\", \"language\":\"English\"}}").when() + .post("/greet") + .then() + .statusCode(201) + .body("workflowdata.greeting", is("Hello from JSON Workflow,")) + .extract().path("id"); + + Assertions.assertThat(processInstanceId) + .isNotBlank(); + + ProcessInstance instance = processInstanceEntityStorage.get(processInstanceId); + + Assertions.assertThat(instance) + .isNotNull() + .hasFieldOrPropertyWithValue("id", processInstanceId) + .hasFieldOrPropertyWithValue("processId", processDefId) + .hasFieldOrPropertyWithValue("processName", "Greeting workflow") + .hasFieldOrPropertyWithValue("version", version) + .hasFieldOrPropertyWithValue("state", 2) + .hasFieldOrProperty("nodes") + .hasFieldOrProperty("start") + .hasFieldOrProperty("end") + .hasFieldOrProperty("lastUpdate"); + } + +} diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/pom.xml b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/pom.xml new file mode 100644 index 0000000000..e2efc62015 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.kie + kogito-addons-quarkus-data-index-persistence + 999-SNAPSHOT + + kogito-addons-quarkus-data-index-persistence-jpa-parent + pom + + Kogito Apps :: Kogito Addons Quarkus Data Index Persistence JPA + + + org.kie.kogito.index.quarkus.data.index.persistence.jpa + + + + deployment + runtime + integration-tests-process + integration-tests-sw + + + diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/pom.xml b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/pom.xml new file mode 100644 index 0000000000..a15db88680 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/pom.xml @@ -0,0 +1,81 @@ + + + + 4.0.0 + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa-parent + 999-SNAPSHOT + + kogito-addons-quarkus-data-index-persistence-jpa + Kogito Apps :: Kogito Addons Quarkus Data Index Persistence JPA :: Runtime + + + org.kie + kogito-addons-quarkus-data-index-persistence-common-runtime + + + io.quarkus + quarkus-flyway + + + org.kie.kogito + data-index-storage-jpa + + + + + + io.quarkus + quarkus-extension-maven-plugin + ${version.io.quarkus} + + + compile + + extension-descriptor + + + ${project.groupId}:${project.artifactId}-deployment:${project.version} + + org.kie.kogito.data-index.persistence + + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${version.io.quarkus} + + + + + + + diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000000..9c8c26914b --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); 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. +# + +name: Kogito Data Index Persistence JPA Quarkus Add-On +description: Add-On to colocate the Data Index Persistence (JPA) in your application. +metadata: + keywords: + - data-index + - kogito + - processes + - workflows + - tasks + - jobs + - BPMN + - JPA + guide: https://quarkus.io/guides/kogito + categories: + - "business-automation" + status: "stable" \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/src/main/resources/application.properties b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/src/main/resources/application.properties new file mode 100644 index 0000000000..472da84431 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/runtime/src/main/resources/application.properties @@ -0,0 +1,27 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); 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. +# + +#Data Index +kogito.apps.persistence.type=jdbc + +#Hibernate +quarkus.hibernate-orm.jdbc.timezone=UTC +quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy +quarkus.flyway.locations=classpath:db/migration +quarkus.flyway.repair-at-start=true \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/pom.xml b/data-index/kogito-addons-quarkus-data-index-persistence/pom.xml index d4cb56a63f..23f142e140 100644 --- a/data-index/kogito-addons-quarkus-data-index-persistence/pom.xml +++ b/data-index/kogito-addons-quarkus-data-index-persistence/pom.xml @@ -36,6 +36,7 @@ kogito-addons-quarkus-data-index-persistence-common kogito-addons-quarkus-data-index-persistence-postgresql + kogito-addons-quarkus-data-index-persistence-jpa kogito-addons-quarkus-data-index-persistence-infinispan kogito-addons-quarkus-data-index-persistence-mongodb diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/pom.xml b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/pom.xml new file mode 100644 index 0000000000..9b04a7dcd6 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.kie + kogito-addons-quarkus-data-index-jpa-parent + 999-SNAPSHOT + + kogito-addons-quarkus-data-index-jpa-deployment + Kogito Apps :: Kogito Addons Quarkus Data Index JPA :: Deployment + + + org.kie + kogito-addons-quarkus-data-index-common-deployment + + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa-deployment + + + org.kie + kogito-addons-quarkus-data-index-jpa + + + io.quarkus + quarkus-vertx-deployment + + + io.quarkus + quarkus-vertx-graphql-deployment + + + io.quarkus + quarkus-hibernate-orm-panache-deployment + + + io.quarkus + quarkus-reactive-routes-deployment + + + io.quarkus + quarkus-junit5-internal + test + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${version.io.quarkus} + + + + + + + diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/deployment/JPADataIndexProcessor.java b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/deployment/JPADataIndexProcessor.java new file mode 100644 index 0000000000..538c9d2f89 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/deployment/JPADataIndexProcessor.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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. + */ +package org.kie.kogito.addons.quarkus.data.index.deployment; + +import java.util.List; + +import io.quarkus.deployment.IsDevelopment; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.SystemPropertyBuildItem; +import io.quarkus.devui.spi.page.CardPageBuildItem; +import io.quarkus.devui.spi.page.Page; + +public class JPADataIndexProcessor extends AbstractKogitoAddonsQuarkusDataIndexProcessor { + + private static final String FEATURE = "kogito-addons-quarkus-data-index-jpa"; + + @BuildStep + public FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep(onlyIf = { IsDevelopment.class }) + CardPageBuildItem createDevUILink(List systemPropertyBuildItems) { + CardPageBuildItem cardPageBuildItem = new CardPageBuildItem(); + cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI") + .url("/q/graphql-ui/") + .isHtmlContent() + .icon("font-awesome-solid:signs-post")); + return cardPageBuildItem; + } +} diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/resources/dev-templates/dataindex.html b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/resources/dev-templates/dataindex.html new file mode 100644 index 0000000000..c121df7858 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/resources/dev-templates/dataindex.html @@ -0,0 +1,32 @@ + +{#include main fluid=true} {#style} .main-container { margin: 0; padding: 0; } +{/style} {#title}Data Index GraphQL UI{/title} {#body} +
+
+ +
+
+{/body} {/include} diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/resources/dev-templates/embedded.html b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/resources/dev-templates/embedded.html new file mode 100644 index 0000000000..09553d5f19 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/deployment/src/main/resources/dev-templates/embedded.html @@ -0,0 +1,24 @@ + + + + Data Index GraphQL UI + diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/pom.xml b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/pom.xml new file mode 100644 index 0000000000..f724fcdadc --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/pom.xml @@ -0,0 +1,120 @@ + + + + 4.0.0 + + org.kie + kogito-addons-quarkus-data-index-jpa-parent + 999-SNAPSHOT + + kogito-addons-quarkus-data-index-jpa-integration-tests-process + Kogito Apps :: Kogito Addons Quarkus Data Index JPA :: Integration Tests :: Process + + + + org.jbpm + jbpm-quarkus + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-resteasy-jackson + + + org.kie + kogito-addons-quarkus-data-index-jpa + + + org.kie + kie-addons-quarkus-persistence-jdbc + + + org.kie + kie-addons-quarkus-process-svg + + + io.quarkus + quarkus-agroal + + + io.quarkus + quarkus-jdbc-h2 + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.kie + kogito-addons-quarkus-data-index-postgresql-deployment + ${project.version} + pom + test + + + * + * + + + + + + + + io.quarkus + quarkus-maven-plugin + ${version.io.quarkus} + + + + build + + + + + + + + + native + + + native + + + + native + **/*IT.java + + + + diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg new file mode 100644 index 0000000000..716974fb87 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/application.properties b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/application.properties new file mode 100644 index 0000000000..2e5b20da68 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/application.properties @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); 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. +# + +kogito.persistence.type=jdbc +quarkus.flyway.migrate-at-start=true + +quarkus.kogito.data-index.graphql.ui.always-include=true + +quarkus.datasource.db-kind=h2 +quarkus.datasource.username=kogito +quarkus.datasource.jdbc.url=jdbc:h2:mem:default;NON_KEYWORDS=VALUE,KEY + +# Not using Keycloak Dev service in test +quarkus.keycloak.devservices.enabled=false + +# Security +quarkus.oidc.enabled=false +quarkus.oidc.tenant-enabled=false +quarkus.oidc.auth-server-url=none diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/hello.bpmn b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/hello.bpmn new file mode 100644 index 0000000000..939c411bbd --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/hello.bpmn @@ -0,0 +1,47 @@ + + + + + + + + + _9FD38FF8-A530-41E7-8EA0-E1F71353CBB3 + + + _9FD38FF8-A530-41E7-8EA0-E1F71353CBB3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _hT2oIPJzEDuE8tm0q8uK_w + _hT2oIPJzEDuE8tm0q8uK_w + + \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexIT.java b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexIT.java new file mode 100644 index 0000000000..c281a08e33 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexIT.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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. + */ +package org.kie.kogito.addons.quarkus.data.index.it; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; + +@QuarkusIntegrationTest +class JPAQuarkusAddonDataIndexIT { + + static { + RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); + } + + @Test + void testDataIndexAddon() { + String processDefId = "hello"; + given().contentType(ContentType.JSON).body("{ \"query\" : \"{ProcessDefinitions(where: { id: {equal: \\\"" + processDefId + + "\\\"}}){ id, version, name } }\" }") + .when().post("/graphql") + .then().statusCode(200) + .body("data.ProcessDefinitions.size()", is(1)) + .body("data.ProcessDefinitions[0].id", is("hello")) + .body("data.ProcessDefinitions[0].version", is("1.0")) + .body("data.ProcessDefinitions[0].name", is("hello")); + + given().contentType(ContentType.JSON).body("{ \"query\" : \"{ProcessInstances{ id } }\" }") + .when().post("/graphql") + .then().statusCode(200) + .body("data.ProcessInstances.size()", is(greaterThanOrEqualTo(0))); + + String processInstanceId = given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .post("/hello") + .then() + .statusCode(201) + .body("id", is(notNullValue())) + .extract().path("id"); + + given().contentType(ContentType.JSON) + .body("{ \"query\" : \"{ProcessInstances(where: { id: {equal: \\\"" + processInstanceId + "\\\"}}){ id, state, diagram, source, nodeDefinitions { name } } }\" }") + .when().post("/graphql") + .then().statusCode(200) + .body("data.ProcessInstances.size()", is(1)) + .body("data.ProcessInstances[0].id", is(processInstanceId)) + .body("data.ProcessInstances[0].state", is("COMPLETED")) + .body("data.ProcessInstances[0].diagram", is(notNullValue())) + .body("data.ProcessInstances[0].source", is(notNullValue())) + .body("data.ProcessInstances[0].nodeDefinitions.size()", is(2)); + } + + @Test + void testGraphQLUI() { + given().contentType(ContentType.HTML) + .when().get("/q/graphql-ui/") + .then().statusCode(200) + .body("html.head.title", is("GraphiQL")); + } + +} diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/pom.xml b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/pom.xml new file mode 100644 index 0000000000..990859cdff --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/pom.xml @@ -0,0 +1,116 @@ + + + + 4.0.0 + + org.kie + kogito-addons-quarkus-data-index-jpa-parent + 999-SNAPSHOT + + kogito-addons-quarkus-data-index-jpa-integration-tests-sw + Kogito Apps :: Kogito Addons Quarkus Data Index JPA :: Integration Tests :: SW + + + + org.apache.kie.sonataflow + sonataflow-quarkus + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-resteasy-jackson + + + org.kie + kogito-addons-quarkus-data-index-jpa + + + org.kie + kie-addons-quarkus-persistence-jdbc + + + io.quarkus + quarkus-agroal + + + io.quarkus + quarkus-jdbc-h2 + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.kie + kogito-addons-quarkus-data-index-jpa-deployment + ${project.version} + pom + test + + + * + * + + + + + + + + io.quarkus + quarkus-maven-plugin + ${version.io.quarkus} + + + + build + + + + + + + + + native + + + native + + + + native + **/*IT.java + + + + diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/main/resources/application.properties b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/main/resources/application.properties new file mode 100644 index 0000000000..2e5b20da68 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/main/resources/application.properties @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); 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. +# + +kogito.persistence.type=jdbc +quarkus.flyway.migrate-at-start=true + +quarkus.kogito.data-index.graphql.ui.always-include=true + +quarkus.datasource.db-kind=h2 +quarkus.datasource.username=kogito +quarkus.datasource.jdbc.url=jdbc:h2:mem:default;NON_KEYWORDS=VALUE,KEY + +# Not using Keycloak Dev service in test +quarkus.keycloak.devservices.enabled=false + +# Security +quarkus.oidc.enabled=false +quarkus.oidc.tenant-enabled=false +quarkus.oidc.auth-server-url=none diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/main/resources/greet.sw.json b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/main/resources/greet.sw.json new file mode 100644 index 0000000000..a849f440e1 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/main/resources/greet.sw.json @@ -0,0 +1,71 @@ +{ + "id": "greet", + "version": "1.0", + "name": "Greeting workflow", + "expressionLang": "jsonpath", + "description": "JSON based greeting workflow", + "start": "ChooseOnLanguage", + "functions": [ + { + "name": "greetFunction", + "type": "custom", + "operation": "sysout" + }, + { + "name": "isEnglish", + "type": "expression", + "operation" : "$.[?(@.language == 'English')]" + } + ], + "states": [ + { + "name": "ChooseOnLanguage", + "type": "switch", + "dataConditions": [ + { + "condition": "fn:isEnglish", + "transition": "GreetInEnglish" + }, + { + "condition": "${ $.[?(@.language == 'Spanish')] }", + "transition": "GreetInSpanish" + } + ], + "defaultCondition": { + "transition": "GreetInEnglish" + } + }, + { + "name": "GreetInEnglish", + "type": "inject", + "data": { + "greeting": "Hello from JSON Workflow," + }, + "transition": "GreetPerson" + }, + { + "name": "GreetInSpanish", + "type": "inject", + "data": { + "greeting": "Saludos desde JSON Workflow," + }, + "transition": "GreetPerson" + }, + { + "name": "GreetPerson", + "type": "operation", + "actions": [ + { + "name": "greetAction", + "functionRef": { + "refName": "greetFunction", + "arguments": { + "message": "$.greeting $.name" + } + } + } + ], + "end": true + } + ] +} \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexIT.java b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexIT.java new file mode 100644 index 0000000000..fcf179910c --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-sw/src/test/java/org/kie/kogito/addons/quarkus/data/index/it/JPAQuarkusAddonDataIndexIT.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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. + */ +package org.kie.kogito.addons.quarkus.data.index.it; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; + +@QuarkusIntegrationTest +class JPAQuarkusAddonDataIndexIT { + + static { + RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); + } + + @Test + void testDataIndexAddon() { + String processDefId = "greet"; + given().contentType(ContentType.JSON).body("{ \"query\" : \"{ProcessDefinitions(where: { id: {equal: \\\"" + processDefId + + "\\\"}}){ id, version, name } }\" }") + .when().post("/graphql") + .then().statusCode(200) + .body("data.ProcessDefinitions.size()", is(1)) + .body("data.ProcessDefinitions[0].id", is("greet")) + .body("data.ProcessDefinitions[0].version", is("1.0")) + .body("data.ProcessDefinitions[0].name", is("Greeting workflow")); + + given().contentType(ContentType.JSON).body("{ \"query\" : \"{ProcessInstances{ id } }\" }") + .when().post("/graphql") + .then().statusCode(200) + .body("data.ProcessInstances.size()", is(greaterThanOrEqualTo(0))); + + String processInstanceId = given() + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .body("{\"workflowdata\" : {\"name\" : \"John\", \"language\":\"English\"}}").when() + .post("/greet") + .then() + .statusCode(201) + .body("workflowdata.greeting", is("Hello from JSON Workflow,")) + .extract().path("id"); + + given().contentType(ContentType.JSON) + .body("{ \"query\" : \"{ProcessInstances(where: { id: {equal: \\\"" + processInstanceId + "\\\"}}){ id, state, diagram, source, nodeDefinitions { name } } }\" }") + .when().post("/graphql") + .then().statusCode(200) + .body("data.ProcessInstances.size()", is(1)) + .body("data.ProcessInstances[0].id", is(processInstanceId)) + .body("data.ProcessInstances[0].state", is("COMPLETED")) + .body("data.ProcessInstances[0].diagram", is(nullValue())) + .body("data.ProcessInstances[0].source", is(notNullValue())) + .body("data.ProcessInstances[0].nodeDefinitions.size()", is(12)); + } + + @Test + void testGraphQLUI() { + given().contentType(ContentType.HTML) + .when().get("/q/graphql-ui/") + .then().statusCode(200) + .body("html.head.title", is("GraphiQL")); + } + +} diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/pom.xml b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/pom.xml new file mode 100644 index 0000000000..aa7cd8598e --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.kie + kogito-addons-quarkus-data-index + 999-SNAPSHOT + + kogito-addons-quarkus-data-index-jpa-parent + pom + + Kogito Apps :: Kogito Addons Quarkus Data Index JPA + + + org.kie.kogito.addons.quarkus.data.index.jpa + + + + deployment + runtime + integration-tests-sw + integration-tests-process + + + diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/pom.xml b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/pom.xml new file mode 100644 index 0000000000..5a9e0e2289 --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/pom.xml @@ -0,0 +1,81 @@ + + + + 4.0.0 + + org.kie + kogito-addons-quarkus-data-index-jpa-parent + 999-SNAPSHOT + + kogito-addons-quarkus-data-index-jpa + Kogito Apps :: Kogito Addons Quarkus Data Index JPA :: Runtime + + + org.kie + kogito-addons-quarkus-data-index-common-runtime + + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa + + + io.quarkus + quarkus-vertx-graphql + + + + + + io.quarkus + quarkus-extension-maven-plugin + ${version.io.quarkus} + + + compile + + extension-descriptor + + + ${project.groupId}:${project.artifactId}-deployment:${project.version} + + org.kie.kogito.data-index + + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${version.io.quarkus} + + + + + + + diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000000..4086152b7e --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); 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. +# + +name: Kogito Data Index PostgreSQL Quarkus Add-On +description: Runs the Kogito Data Index embedded with JPA persistence +metadata: + keywords: + - data-index + - kogito + - processes + - workflows + - tasks + - jobs + - BPMN + - postgresql + guide: https://quarkus.io/guides/kogito + categories: + - "business-automation" + status: "stable" + config: + - "kogito.data-index." + - "kogito.dataindex." \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/src/main/resources/application.properties b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/src/main/resources/application.properties new file mode 100644 index 0000000000..648cbe8fcc --- /dev/null +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/runtime/src/main/resources/application.properties @@ -0,0 +1,28 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); 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. +# + +#Data Index +kogito.apps.persistence.type=jdbc +kogito.data-index.domain-indexing=false +kogito.data-index.blocking=true + +#Hibernate +quarkus.hibernate-orm.jdbc.timezone=UTC +quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy +quarkus.flyway.locations=classpath:db/migration \ No newline at end of file diff --git a/data-index/kogito-addons-quarkus-data-index/pom.xml b/data-index/kogito-addons-quarkus-data-index/pom.xml index 2996e9027a..e7aacaefb0 100644 --- a/data-index/kogito-addons-quarkus-data-index/pom.xml +++ b/data-index/kogito-addons-quarkus-data-index/pom.xml @@ -39,6 +39,7 @@ kogito-addons-quarkus-data-index-postgresql kogito-addons-quarkus-data-index-infinispan kogito-addons-quarkus-data-index-mongodb + kogito-addons-quarkus-data-index-jpa diff --git a/kogito-apps-bom/pom.xml b/kogito-apps-bom/pom.xml index 90fce247cf..5e903d4972 100644 --- a/kogito-apps-bom/pom.xml +++ b/kogito-apps-bom/pom.xml @@ -444,6 +444,28 @@ ${project.version} sources
+ + org.kie + kogito-addons-quarkus-data-index-persistence-jpa + ${project.version} + + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa + ${project.version} + sources + + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa-deployment + ${project.version} + + + org.kie + kogito-addons-quarkus-data-index-persistence-jpa-deployment + ${project.version} + sources + org.kie kogito-addons-quarkus-data-index-common-runtime @@ -466,7 +488,28 @@ ${project.version} sources - + + org.kie + kogito-addons-quarkus-data-index-jpa + ${project.version} + + + org.kie + kogito-addons-quarkus-data-index-jpa + ${project.version} + sources + + + org.kie + kogito-addons-quarkus-data-index-jpa-deployment + ${project.version} + + + org.kie + kogito-addons-quarkus-data-index-jpa-deployment + ${project.version} + sources + @@ -576,6 +619,17 @@ ${project.version} sources + + org.kie.kogito + persistence-commons-jpa-base + ${project.version} + + + org.kie.kogito + persistence-commons-jpa-base + ${project.version} + sources + org.kie.kogito persistence-commons-jpa diff --git a/persistence-commons/persistence-commons-jpa-base/pom.xml b/persistence-commons/persistence-commons-jpa-base/pom.xml new file mode 100644 index 0000000000..3b2e9c2754 --- /dev/null +++ b/persistence-commons/persistence-commons-jpa-base/pom.xml @@ -0,0 +1,97 @@ + + + + + persistence-commons + org.kie.kogito + 999-SNAPSHOT + + 4.0.0 + + persistence-commons-jpa-base + Kogito Apps :: Persistence Commons JPA - Base + + + org.kie.kogito.persistence.jpa.base + + + + + org.kie.kogito + persistence-commons-api + + + io.quarkus + quarkus-hibernate-orm-panache + + + org.hibernate.orm + hibernate-ant + + + io.quarkus + quarkus-jackson + + + org.kie.kogito + kogito-jackson-utils + + + org.kie.kogito + kogito-quarkus-test-utils + test + + + io.quarkus + quarkus-junit5-mockito + test + + + org.assertj + assertj-core + test + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + org.jboss.logmanager.LogManager + + + + + + integration-test + verify + + + + + + + \ No newline at end of file diff --git a/persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/Constants.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/Constants.java similarity index 100% rename from persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/Constants.java rename to persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/Constants.java diff --git a/persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/PostgresQuery.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/PostgresQuery.java similarity index 100% rename from persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/PostgresQuery.java rename to persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/PostgresQuery.java diff --git a/persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/PostgresStorage.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/PostgresStorage.java similarity index 100% rename from persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/PostgresStorage.java rename to persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/PostgresStorage.java diff --git a/persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/PostgresStorageService.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/PostgresStorageService.java similarity index 100% rename from persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/PostgresStorageService.java rename to persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/PostgresStorageService.java diff --git a/persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/hibernate/JsonBinaryConverter.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/hibernate/JsonBinaryConverter.java similarity index 100% rename from persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/hibernate/JsonBinaryConverter.java rename to persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/hibernate/JsonBinaryConverter.java diff --git a/persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/hibernate/JsonBinaryType.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/hibernate/JsonBinaryType.java similarity index 100% rename from persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/hibernate/JsonBinaryType.java rename to persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/hibernate/JsonBinaryType.java diff --git a/persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java similarity index 100% rename from persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java rename to persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java diff --git a/persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntityRepository.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntityRepository.java similarity index 100% rename from persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntityRepository.java rename to persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntityRepository.java diff --git a/persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheId.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheId.java similarity index 100% rename from persistence-commons/persistence-commons-jpa/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheId.java rename to persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheId.java diff --git a/persistence-commons/persistence-commons-jpa/src/main/resources/META-INF/beans.xml b/persistence-commons/persistence-commons-jpa-base/src/main/resources/META-INF/beans.xml similarity index 100% rename from persistence-commons/persistence-commons-jpa/src/main/resources/META-INF/beans.xml rename to persistence-commons/persistence-commons-jpa-base/src/main/resources/META-INF/beans.xml diff --git a/persistence-commons/persistence-commons-jpa/pom.xml b/persistence-commons/persistence-commons-jpa/pom.xml index d40f23b990..929f672775 100644 --- a/persistence-commons/persistence-commons-jpa/pom.xml +++ b/persistence-commons/persistence-commons-jpa/pom.xml @@ -39,38 +39,7 @@ org.kie.kogito - persistence-commons-api - - - io.quarkus - quarkus-hibernate-orm-panache - - - org.hibernate.orm - hibernate-ant - - - io.quarkus - quarkus-jackson - - - org.kie.kogito - kogito-jackson-utils - - - org.kie.kogito - kogito-quarkus-test-utils - test - - - io.quarkus - quarkus-junit5-mockito - test - - - org.assertj - assertj-core - test + persistence-commons-jpa-base diff --git a/persistence-commons/persistence-commons-jpa/src/main/resources/db/migration/V1.5.0__kogito_apps_create_kogito_data_cache.sql b/persistence-commons/persistence-commons-jpa/src/main/resources/db/migration/V1.5.0__kogito_apps_create_kogito_data_cache.sql new file mode 100644 index 0000000000..3b6a41389d --- /dev/null +++ b/persistence-commons/persistence-commons-jpa/src/main/resources/db/migration/V1.5.0__kogito_apps_create_kogito_data_cache.sql @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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 if not exists kogito_data_cache ( + key varchar(255) not null, + name varchar(255) not null, + json_value varbinary(max), + primary key (key, name) +); \ No newline at end of file diff --git a/persistence-commons/persistence-commons-postgresql/pom.xml b/persistence-commons/persistence-commons-postgresql/pom.xml index 181b102f72..fbfbf2a0f9 100644 --- a/persistence-commons/persistence-commons-postgresql/pom.xml +++ b/persistence-commons/persistence-commons-postgresql/pom.xml @@ -39,7 +39,7 @@ org.kie.kogito - persistence-commons-jpa + persistence-commons-jpa-base io.quarkus diff --git a/persistence-commons/persistence-commons-postgresql/src/main/resources/db/migration/V1.5.0__kogito_apps_create_kogito_data_cache.sql b/persistence-commons/persistence-commons-postgresql/src/main/resources/db/migration/V1.5.0__kogito_apps_create_kogito_data_cache.sql new file mode 100644 index 0000000000..c8167cd40e --- /dev/null +++ b/persistence-commons/persistence-commons-postgresql/src/main/resources/db/migration/V1.5.0__kogito_apps_create_kogito_data_cache.sql @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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 if not exists kogito_data_cache ( + key varchar(255) not null, + name varchar(255) not null, + json_value jsonb, + primary key (key, name) +); diff --git a/persistence-commons/pom.xml b/persistence-commons/pom.xml index 9c7fb64511..83a58f41e9 100644 --- a/persistence-commons/pom.xml +++ b/persistence-commons/pom.xml @@ -37,6 +37,7 @@ persistence-commons-api persistence-commons-protobuf + persistence-commons-jpa-base persistence-commons-jpa persistence-commons-postgresql persistence-commons-infinispan From 6330a1f6edb376244e15b87df39098758e2f15a1 Mon Sep 17 00:00:00 2001 From: Walter Medvedeo Date: Fri, 2 Aug 2024 14:35:13 +0200 Subject: [PATCH 2/2] kie-kogito-apps-issues-2083: Add the possibility of disabling the default data-index-url calculation in the data-index-addon (#2084) --- ...KogitoAddonsQuarkusDataIndexProcessor.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/deployment/AbstractKogitoAddonsQuarkusDataIndexProcessor.java b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/deployment/AbstractKogitoAddonsQuarkusDataIndexProcessor.java index c6235729b6..6a319765a7 100644 --- a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/deployment/AbstractKogitoAddonsQuarkusDataIndexProcessor.java +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/deployment/src/main/java/org/kie/kogito/addons/quarkus/data/index/deployment/AbstractKogitoAddonsQuarkusDataIndexProcessor.java @@ -43,6 +43,12 @@ public abstract class AbstractKogitoAddonsQuarkusDataIndexProcessor extends OneO private static final String QUARKUS_HTTP_PORT = "quarkus.http.port"; private static final String KOGITO_SERVICE_URL_PROP = "kogito.service.url"; private static final String KOGITO_DATA_INDEX_PROP = "kogito.data-index.url"; + /** + * Skips the setting of the default kogito.data-index.url from the runtime url. + * This is convenient in scenarios like the dev-ui executing in k8s where want it to set this url using window + * location instead. Must be explicitly set to true to take effect. + */ + private static final String SKIP_DEFAULT_DATA_INDEX_URL_PROP = "kogito.data-index-addons.skip-default-data-index-url"; AbstractKogitoAddonsQuarkusDataIndexProcessor() { super(KogitoCapability.SERVERLESS_WORKFLOW, KogitoCapability.PROCESSES); @@ -50,12 +56,15 @@ public abstract class AbstractKogitoAddonsQuarkusDataIndexProcessor extends OneO @BuildStep(onlyIf = IsDevelopment.class) public void buildDefaultDataIndexURLSystemProperty(BuildProducer systemProperties) { - // Setting a default `kogito.data-index.url` accordingly to the runtime url. - String dataIndexUrl = ConfigProvider.getConfig().getOptionalValue(KOGITO_SERVICE_URL_PROP, String.class).orElseGet(() -> { - Integer port = ConfigProvider.getConfig().getOptionalValue(QUARKUS_HTTP_PORT, Integer.class).orElse(8080); - return "http://localhost:" + port; - }); - systemProperties.produce(new SystemPropertyBuildItem(KOGITO_DATA_INDEX_PROP, dataIndexUrl)); + boolean skipDefaultDataIndexUrl = ConfigProvider.getConfig().getOptionalValue(SKIP_DEFAULT_DATA_INDEX_URL_PROP, Boolean.class).orElse(false); + if (!skipDefaultDataIndexUrl) { + // Setting a default `kogito.data-index.url` accordingly to the runtime url. + String dataIndexUrl = ConfigProvider.getConfig().getOptionalValue(KOGITO_SERVICE_URL_PROP, String.class).orElseGet(() -> { + Integer port = ConfigProvider.getConfig().getOptionalValue(QUARKUS_HTTP_PORT, Integer.class).orElse(8080); + return "http://localhost:" + port; + }); + systemProperties.produce(new SystemPropertyBuildItem(KOGITO_DATA_INDEX_PROP, dataIndexUrl)); + } } @BuildStep(onlyIf = IsDevelopment.class)