diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index bf82ff01c6..0000000000 Binary files a/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonProcessInstanceDataEventDeserializer.java b/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonProcessInstanceDataEventDeserializer.java deleted file mode 100644 index de164e6ff3..0000000000 --- a/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonProcessInstanceDataEventDeserializer.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.app.audit.json; - -import java.io.IOException; - -import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; -import org.kie.kogito.event.process.ProcessInstanceDataEvent; -import org.kie.kogito.event.process.ProcessInstanceErrorDataEvent; -import org.kie.kogito.event.process.ProcessInstanceNodeDataEvent; -import org.kie.kogito.event.process.ProcessInstanceSLADataEvent; -import org.kie.kogito.event.process.ProcessInstanceStateDataEvent; -import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; - -public class JsonProcessInstanceDataEventDeserializer extends StdDeserializer> { - - private static final Logger LOGGER = LoggerFactory.getLogger(JsonProcessInstanceDataEventDeserializer.class); - - private static final long serialVersionUID = 6152014726577574241L; - - public JsonProcessInstanceDataEventDeserializer() { - this(null); - } - - public JsonProcessInstanceDataEventDeserializer(Class vc) { - super(vc); - } - - @Override - public ProcessInstanceDataEvent deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - JsonNode node = jp.getCodec().readTree(jp); - LOGGER.debug("Deserialize process instance data event: {}", node); - String type = node.get("type").asText(); - - switch (type) { - case MultipleProcessInstanceDataEvent.TYPE: - return jp.getCodec().treeToValue(node, MultipleProcessInstanceDataEvent.class); - case "ProcessInstanceErrorDataEvent": - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceErrorDataEvent.class); - case "ProcessInstanceNodeDataEvent": - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceNodeDataEvent.class); - case "ProcessInstanceSLADataEvent": - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceSLADataEvent.class); - case "ProcessInstanceStateDataEvent": - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceStateDataEvent.class); - case "ProcessInstanceVariableDataEvent": - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceVariableDataEvent.class); - default: - LOGGER.warn("Unknown type {} in json data {}", type, node); - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceDataEvent.class); - - } - } -} \ No newline at end of file diff --git a/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUserTaskInstanceDataEventDeserializer.java b/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUserTaskInstanceDataEventDeserializer.java deleted file mode 100644 index 32e53e4f98..0000000000 --- a/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUserTaskInstanceDataEventDeserializer.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.app.audit.json; - -import java.io.IOException; - -import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceCommentDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceDeadlineDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceStateDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceVariableDataEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; - -public class JsonUserTaskInstanceDataEventDeserializer extends StdDeserializer> { - - private static final Logger LOGGER = LoggerFactory.getLogger(JsonUserTaskInstanceDataEventDeserializer.class); - - private static final long serialVersionUID = -6626663191296012306L; - - public JsonUserTaskInstanceDataEventDeserializer() { - this(null); - } - - public JsonUserTaskInstanceDataEventDeserializer(Class vc) { - super(vc); - } - - @Override - public UserTaskInstanceDataEvent deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - JsonNode node = jp.getCodec().readTree(jp); - LOGGER.debug("Deserialize user task instance data event: {}", node); - String type = node.get("type").asText(); - - switch (type) { - case MultipleUserTaskInstanceDataEvent.TYPE: - return jp.getCodec().treeToValue(node, MultipleUserTaskInstanceDataEvent.class); - case "UserTaskInstanceAssignmentDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceAssignmentDataEvent.class); - case "UserTaskInstanceAttachmentDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceAttachmentDataEvent.class); - case "UserTaskInstanceCommentDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceCommentDataEvent.class); - case "UserTaskInstanceDeadlineDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceDeadlineDataEvent.class); - case "UserTaskInstanceStateDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceStateDataEvent.class); - case "UserTaskInstanceVariableDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceVariableDataEvent.class); - default: - LOGGER.warn("Unknown type {} in json data {}", type, node); - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceDataEvent.class); - - } - } -} \ No newline at end of file diff --git a/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUtils.java b/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUtils.java index 52ece97fd5..3006244f04 100644 --- a/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUtils.java +++ b/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUtils.java @@ -19,13 +19,10 @@ package org.kie.kogito.app.audit.json; import org.kie.kogito.event.job.JobInstanceDataEvent; -import org.kie.kogito.event.process.ProcessInstanceDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import io.cloudevents.jackson.JsonFormat; @@ -41,15 +38,7 @@ public static ObjectMapper getObjectMapper() { } public static ObjectMapper configure(ObjectMapper objectMapper) { - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - objectMapper.registerModule(JsonFormat.getCloudEventJacksonModule()); - objectMapper.registerModule(new JavaTimeModule()); - - SimpleModule module = new SimpleModule("Kogito Cloud Events"); - module.addDeserializer(ProcessInstanceDataEvent.class, new JsonProcessInstanceDataEventDeserializer()); - module.addDeserializer(UserTaskInstanceDataEvent.class, new JsonUserTaskInstanceDataEventDeserializer()); - module.addDeserializer(JobInstanceDataEvent.class, new JsonJobDataEventDeserializer()); - objectMapper.registerModule(module); - return objectMapper; + return objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).registerModule(JsonFormat.getCloudEventJacksonModule()) + .registerModule(new SimpleModule("Data Audit").addDeserializer(JobInstanceDataEvent.class, new JsonJobDataEventDeserializer())).findAndRegisterModules(); } } diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonProcessInstanceDataEventDeserializer.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonProcessInstanceDataEventDeserializer.java deleted file mode 100644 index 261bcc4084..0000000000 --- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonProcessInstanceDataEventDeserializer.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.index.json; - -import java.io.IOException; - -import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; -import org.kie.kogito.event.process.ProcessInstanceDataEvent; -import org.kie.kogito.event.process.ProcessInstanceErrorDataEvent; -import org.kie.kogito.event.process.ProcessInstanceNodeDataEvent; -import org.kie.kogito.event.process.ProcessInstanceSLADataEvent; -import org.kie.kogito.event.process.ProcessInstanceStateDataEvent; -import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; - -public class JsonProcessInstanceDataEventDeserializer extends StdDeserializer> { - - private static final Logger LOGGER = LoggerFactory.getLogger(JsonProcessInstanceDataEventDeserializer.class); - - private static final long serialVersionUID = 6152014726577574241L; - - public JsonProcessInstanceDataEventDeserializer() { - this(null); - } - - public JsonProcessInstanceDataEventDeserializer(Class vc) { - super(vc); - } - - @Override - public ProcessInstanceDataEvent deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - JsonNode node = jp.getCodec().readTree(jp); - LOGGER.debug("Deserialize process instance data event: {}", node); - String type = node.get("type").asText(); - - switch (type) { - case MultipleProcessInstanceDataEvent.TYPE: - return jp.getCodec().treeToValue(node, MultipleProcessInstanceDataEvent.class); - case "ProcessInstanceErrorDataEvent": - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceErrorDataEvent.class); - case "ProcessInstanceNodeDataEvent": - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceNodeDataEvent.class); - case "ProcessInstanceSLADataEvent": - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceSLADataEvent.class); - case "ProcessInstanceStateDataEvent": - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceStateDataEvent.class); - case "ProcessInstanceVariableDataEvent": - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceVariableDataEvent.class); - default: - LOGGER.warn("Unknown type {} in json data {}", type, node); - return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceDataEvent.class); - - } - } -} \ No newline at end of file diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUserTaskInstanceDataEventDeserializer.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUserTaskInstanceDataEventDeserializer.java deleted file mode 100644 index 3a515a5e8b..0000000000 --- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUserTaskInstanceDataEventDeserializer.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.index.json; - -import java.io.IOException; - -import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceCommentDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceDeadlineDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceStateDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceVariableDataEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; - -public class JsonUserTaskInstanceDataEventDeserializer extends StdDeserializer> { - - private static final Logger LOGGER = LoggerFactory.getLogger(JsonUserTaskInstanceDataEventDeserializer.class); - - private static final long serialVersionUID = -6626663191296012306L; - - public JsonUserTaskInstanceDataEventDeserializer() { - this(null); - } - - public JsonUserTaskInstanceDataEventDeserializer(Class vc) { - super(vc); - } - - @Override - public UserTaskInstanceDataEvent deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - JsonNode node = jp.getCodec().readTree(jp); - LOGGER.debug("Deserialize user task instance data event: {}", node); - String type = node.get("type").asText(); - - switch (type) { - case MultipleUserTaskInstanceDataEvent.TYPE: - return jp.getCodec().treeToValue(node, MultipleUserTaskInstanceDataEvent.class); - case "UserTaskInstanceAssignmentDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceAssignmentDataEvent.class); - case "UserTaskInstanceAttachmentDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceAttachmentDataEvent.class); - case "UserTaskInstanceCommentDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceCommentDataEvent.class); - case "UserTaskInstanceDeadlineDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceDeadlineDataEvent.class); - case "UserTaskInstanceStateDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceStateDataEvent.class); - case "UserTaskInstanceVariableDataEvent": - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceVariableDataEvent.class); - default: - LOGGER.warn("Unknown type {} in json data {}", type, node); - return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceDataEvent.class); - - } - } -} diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUtils.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUtils.java index 8dbf880581..c660fb31ce 100644 --- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUtils.java +++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUtils.java @@ -18,17 +18,13 @@ */ package org.kie.kogito.index.json; -import org.kie.kogito.event.process.ProcessInstanceDataEvent; -import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent; import org.kie.kogito.jackson.utils.JsonObjectUtils; import org.kie.kogito.jackson.utils.MergeUtils; import org.kie.kogito.jackson.utils.ObjectMapperFactory; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import io.cloudevents.jackson.JsonFormat; @@ -44,15 +40,7 @@ public static ObjectMapper getObjectMapper() { } public static ObjectMapper configure(ObjectMapper objectMapper) { - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - objectMapper.registerModule(JsonFormat.getCloudEventJacksonModule()); - objectMapper.registerModule(new JavaTimeModule()); - - SimpleModule module = new SimpleModule("Kogito Cloud Events"); - module.addDeserializer(ProcessInstanceDataEvent.class, new JsonProcessInstanceDataEventDeserializer()); - module.addDeserializer(UserTaskInstanceDataEvent.class, new JsonUserTaskInstanceDataEventDeserializer()); - objectMapper.registerModule(module); - return objectMapper; + return objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).registerModule(JsonFormat.getCloudEventJacksonModule()).findAndRegisterModules(); } public static ObjectNode mergeVariable(String variableName, Object variableValue, ObjectNode variables) { diff --git a/data-index/data-index-common/src/test/java/org/kie/kogito/index/event/DataEventDeserializerTest.java b/data-index/data-index-common/src/test/java/org/kie/kogito/index/event/DataEventDeserializerTest.java index 03f4625fc4..80b4ae9c66 100644 --- a/data-index/data-index-common/src/test/java/org/kie/kogito/index/event/DataEventDeserializerTest.java +++ b/data-index/data-index-common/src/test/java/org/kie/kogito/index/event/DataEventDeserializerTest.java @@ -44,8 +44,7 @@ public class DataEventDeserializerTest { @BeforeAll public void beforeAll() { - mapper = new ObjectMapper(); - JsonUtils.configure(mapper); + mapper = JsonUtils.configure(new ObjectMapper()); } @Test diff --git a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLInstrumentation.java b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLInstrumentation.java index a479318c7b..65b3b82b66 100644 --- a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLInstrumentation.java +++ b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLInstrumentation.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.JsonNode; +import graphql.execution.instrumentation.InstrumentationState; import graphql.execution.instrumentation.SimpleInstrumentation; import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters; import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters; @@ -36,7 +37,7 @@ public class GraphQLInstrumentation extends SimpleInstrumentation { GraphQLSchemaManager manager; @Override - public DataFetcher instrumentDataFetcher(DataFetcher dataFetcher, InstrumentationFieldFetchParameters parameters) { + public DataFetcher instrumentDataFetcher(DataFetcher dataFetcher, InstrumentationFieldFetchParameters parameters, InstrumentationState instrumentationState) { if (parameters.getEnvironment().getSource() instanceof JsonNode && dataFetcher instanceof PropertyDataFetcher) { return new JsonPropertyDataFetcher(); } else { @@ -45,7 +46,7 @@ public DataFetcher instrumentDataFetcher(DataFetcher dataFetcher, Instrume } @Override - public GraphQLSchema instrumentSchema(GraphQLSchema schema, InstrumentationExecutionParameters parameters) { + public GraphQLSchema instrumentSchema(GraphQLSchema schema, InstrumentationExecutionParameters parameters, InstrumentationState instrumentationState) { return manager.getGraphQLSchema(); } } diff --git a/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverter.java b/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverter.java index cef45271e0..0b29028820 100644 --- a/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverter.java +++ b/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverter.java @@ -21,11 +21,13 @@ import java.io.IOException; import java.lang.reflect.Type; import java.util.Collection; -import java.util.function.Supplier; import org.eclipse.microprofile.reactive.messaging.Message; -import org.kie.kogito.event.AbstractDataEvent; +import org.kie.kogito.event.Converter; import org.kie.kogito.event.DataEvent; +import org.kie.kogito.event.DataEventFactory; +import org.kie.kogito.event.impl.JacksonCloudEventDataConverter; +import org.kie.kogito.event.impl.JacksonTypeCloudEventDataConverter; import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessDefinitionDataEvent; import org.kie.kogito.event.process.ProcessDefinitionEventBody; @@ -40,6 +42,7 @@ import org.kie.kogito.event.process.ProcessInstanceStateEventBody; import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent; import org.kie.kogito.event.process.ProcessInstanceVariableEventBody; +import org.kie.kogito.event.serializer.MultipleProcessDataInstanceConverterFactory; import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentEventBody; @@ -64,6 +67,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.cloudevents.CloudEvent; +import io.cloudevents.CloudEventData; import io.cloudevents.core.message.MessageReader; import io.cloudevents.http.vertx.VertxMessageFactory; import io.quarkus.reactivemessaging.http.runtime.IncomingHttpMetadata; @@ -71,6 +75,7 @@ import io.vertx.core.MultiMap; import io.vertx.core.buffer.Buffer; +import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; @@ -90,6 +95,38 @@ public int getPriority() { return CONVERTER_DEFAULT_PRIORITY - 2; } + private Converter errorConverter; + private Converter nodeConverter; + private Converter slaConverter; + private Converter varConverter; + private Converter stateConverter; + private Converter assignConverter; + private Converter attachConverter; + private Converter commentConverter; + private Converter deadlineConverter; + private Converter taskStateConverter; + private Converter taskVariableConverter; + private Converter>> taskCollectionConverter; + private Converter definitionConverter; + + @PostConstruct + void init() { + this.errorConverter = new JacksonCloudEventDataConverter<>(objectMapper, ProcessInstanceErrorEventBody.class); + this.nodeConverter = new JacksonCloudEventDataConverter<>(objectMapper, ProcessInstanceNodeEventBody.class); + this.slaConverter = new JacksonCloudEventDataConverter<>(objectMapper, ProcessInstanceSLAEventBody.class); + this.varConverter = new JacksonCloudEventDataConverter<>(objectMapper, ProcessInstanceVariableEventBody.class); + this.stateConverter = new JacksonCloudEventDataConverter<>(objectMapper, ProcessInstanceStateEventBody.class); + this.assignConverter = new JacksonCloudEventDataConverter<>(objectMapper, UserTaskInstanceAssignmentEventBody.class); + this.attachConverter = new JacksonCloudEventDataConverter<>(objectMapper, UserTaskInstanceAttachmentEventBody.class); + this.commentConverter = new JacksonCloudEventDataConverter<>(objectMapper, UserTaskInstanceCommentEventBody.class); + this.deadlineConverter = new JacksonCloudEventDataConverter<>(objectMapper, UserTaskInstanceDeadlineEventBody.class); + this.taskStateConverter = new JacksonCloudEventDataConverter<>(objectMapper, UserTaskInstanceStateEventBody.class); + this.taskVariableConverter = new JacksonCloudEventDataConverter<>(objectMapper, UserTaskInstanceVariableEventBody.class); + this.taskCollectionConverter = new JacksonTypeCloudEventDataConverter<>(objectMapper, new TypeReference>>() { + }); + this.definitionConverter = new JacksonCloudEventDataConverter<>(objectMapper, ProcessDefinitionEventBody.class); + } + @Override public boolean canConvert(Message message, Type type) { return isIndexable(type) && @@ -133,12 +170,7 @@ public Message convert(Message message, Type type) { } private ProcessDefinitionDataEvent buildProcessDefinitionEvent(CloudEvent cloudEvent) throws IOException { - ProcessDefinitionDataEvent event = new ProcessDefinitionDataEvent(); - applyCloudEventAttributes(cloudEvent, event); - if (cloudEvent.getData() != null) { - event.setData(objectMapper.readValue(cloudEvent.getData().toBytes(), ProcessDefinitionEventBody.class)); - } - return event; + return DataEventFactory.from(new ProcessDefinitionDataEvent(), cloudEvent, definitionConverter); } @Inject @@ -148,19 +180,18 @@ public void setObjectMapper(ObjectMapper objectMapper) { private DataEvent buildProcessInstanceDataEventVariant(CloudEvent cloudEvent) throws IOException { switch (cloudEvent.getType()) { - case MultipleProcessInstanceDataEvent.TYPE: - return buildDataEvent(cloudEvent, objectMapper, MultipleProcessInstanceDataEvent::new, new TypeReference>>() { - }); - case "ProcessInstanceErrorDataEvent": - return buildDataEvent(cloudEvent, objectMapper, ProcessInstanceErrorDataEvent::new, ProcessInstanceErrorEventBody.class); - case "ProcessInstanceNodeDataEvent": - return buildDataEvent(cloudEvent, objectMapper, ProcessInstanceNodeDataEvent::new, ProcessInstanceNodeEventBody.class); - case "ProcessInstanceSLADataEvent": - return buildDataEvent(cloudEvent, objectMapper, ProcessInstanceSLADataEvent::new, ProcessInstanceSLAEventBody.class); - case "ProcessInstanceStateDataEvent": - return buildDataEvent(cloudEvent, objectMapper, ProcessInstanceStateDataEvent::new, ProcessInstanceStateEventBody.class); - case "ProcessInstanceVariableDataEvent": - return buildDataEvent(cloudEvent, objectMapper, ProcessInstanceVariableDataEvent::new, ProcessInstanceVariableEventBody.class); + case MultipleProcessInstanceDataEvent.MULTIPLE_TYPE: + return DataEventFactory.from(new MultipleProcessInstanceDataEvent(), cloudEvent, MultipleProcessDataInstanceConverterFactory.fromCloudEvent(cloudEvent, objectMapper)); + case ProcessInstanceErrorDataEvent.ERROR_TYPE: + return DataEventFactory.from(new ProcessInstanceErrorDataEvent(), cloudEvent, errorConverter); + case ProcessInstanceNodeDataEvent.NODE_TYPE: + return DataEventFactory.from(new ProcessInstanceNodeDataEvent(), cloudEvent, nodeConverter); + case ProcessInstanceSLADataEvent.SLA_TYPE: + return DataEventFactory.from(new ProcessInstanceSLADataEvent(), cloudEvent, slaConverter); + case ProcessInstanceStateDataEvent.STATE_TYPE: + return DataEventFactory.from(new ProcessInstanceStateDataEvent(), cloudEvent, stateConverter); + case ProcessInstanceVariableDataEvent.VAR_TYPE: + return DataEventFactory.from(new ProcessInstanceVariableDataEvent(), cloudEvent, varConverter); default: throw new IllegalArgumentException("Unknown ProcessInstanceDataEvent variant: " + cloudEvent.getType()); } @@ -169,20 +200,19 @@ private DataEvent buildProcessInstanceDataEventVariant(CloudEvent cloudEvent) private DataEvent buildUserTaskInstanceDataEvent(CloudEvent cloudEvent) throws IOException { switch (cloudEvent.getType()) { case MultipleUserTaskInstanceDataEvent.TYPE: - return buildDataEvent(cloudEvent, objectMapper, MultipleUserTaskInstanceDataEvent::new, new TypeReference>>() { - }); + return DataEventFactory.from(new MultipleUserTaskInstanceDataEvent(), cloudEvent, taskCollectionConverter); case "UserTaskInstanceAssignmentDataEvent": - return buildDataEvent(cloudEvent, objectMapper, UserTaskInstanceAssignmentDataEvent::new, UserTaskInstanceAssignmentEventBody.class); + return DataEventFactory.from(new UserTaskInstanceAssignmentDataEvent(), cloudEvent, assignConverter); case "UserTaskInstanceAttachmentDataEvent": - return buildDataEvent(cloudEvent, objectMapper, UserTaskInstanceAttachmentDataEvent::new, UserTaskInstanceAttachmentEventBody.class); + return DataEventFactory.from(new UserTaskInstanceAttachmentDataEvent(), cloudEvent, attachConverter); case "UserTaskInstanceCommentDataEvent": - return buildDataEvent(cloudEvent, objectMapper, UserTaskInstanceCommentDataEvent::new, UserTaskInstanceCommentEventBody.class); + return DataEventFactory.from(new UserTaskInstanceCommentDataEvent(), cloudEvent, commentConverter); case "UserTaskInstanceDeadlineDataEvent": - return buildDataEvent(cloudEvent, objectMapper, UserTaskInstanceDeadlineDataEvent::new, UserTaskInstanceDeadlineEventBody.class); + return DataEventFactory.from(new UserTaskInstanceDeadlineDataEvent(), cloudEvent, deadlineConverter); case "UserTaskInstanceStateDataEvent": - return buildDataEvent(cloudEvent, objectMapper, UserTaskInstanceStateDataEvent::new, UserTaskInstanceStateEventBody.class); + return DataEventFactory.from(new UserTaskInstanceStateDataEvent(), cloudEvent, taskStateConverter); case "UserTaskInstanceVariableDataEvent": - return buildDataEvent(cloudEvent, objectMapper, UserTaskInstanceVariableDataEvent::new, UserTaskInstanceVariableEventBody.class); + return DataEventFactory.from(new UserTaskInstanceVariableDataEvent(), cloudEvent, taskVariableConverter); default: throw new IllegalArgumentException("Unknown UserTaskInstanceDataEvent variant: " + cloudEvent.getType()); } @@ -203,41 +233,4 @@ private KogitoJobCloudEvent buildKogitoJobCloudEvent(CloudEvent cloudEvent) thro return jobCloudEvent; } - private static , T> E buildDataEvent(CloudEvent cloudEvent, ObjectMapper objectMapper, Supplier supplier, TypeReference typeReference) throws IOException { - E dataEvent = buildEvent(cloudEvent, objectMapper, supplier); - if (cloudEvent.getData() != null) { - dataEvent.setData(objectMapper.readValue(cloudEvent.getData().toBytes(), typeReference)); - } - return dataEvent; - } - - private static , T> E buildDataEvent(CloudEvent cloudEvent, ObjectMapper objectMapper, Supplier supplier, Class clazz) throws IOException { - E dataEvent = buildEvent(cloudEvent, objectMapper, supplier); - if (cloudEvent.getData() != null) { - dataEvent.setData(objectMapper.readValue(cloudEvent.getData().toBytes(), clazz)); - } - return dataEvent; - } - - private static > E buildEvent(CloudEvent cloudEvent, ObjectMapper objectMapper, Supplier supplier) throws IOException { - E dataEvent = supplier.get(); - applyCloudEventAttributes(cloudEvent, dataEvent); - applyExtensions(cloudEvent, dataEvent); - return dataEvent; - } - - private static void applyCloudEventAttributes(CloudEvent cloudEvent, AbstractDataEvent dataEvent) { - dataEvent.setSpecVersion(cloudEvent.getSpecVersion()); - dataEvent.setId(cloudEvent.getId()); - dataEvent.setType(cloudEvent.getType()); - dataEvent.setSource(cloudEvent.getSource()); - dataEvent.setDataContentType(cloudEvent.getDataContentType()); - dataEvent.setDataSchema(cloudEvent.getDataSchema()); - dataEvent.setSubject(cloudEvent.getSubject()); - dataEvent.setTime(cloudEvent.getTime()); - } - - private static void applyExtensions(CloudEvent cloudEvent, AbstractDataEvent dataEvent) { - cloudEvent.getExtensionNames().forEach(extensionName -> dataEvent.addExtensionAttribute(extensionName, cloudEvent.getExtension(extensionName))); - } } diff --git a/data-index/data-index-service/data-index-service-common/src/main/resources/META-INF/microprofile-config.properties b/data-index/data-index-service/data-index-service-common/src/main/resources/META-INF/microprofile-config.properties index 15ec93572e..331e25555d 100644 --- a/data-index/data-index-service/data-index-service-common/src/main/resources/META-INF/microprofile-config.properties +++ b/data-index/data-index-service/data-index-service-common/src/main/resources/META-INF/microprofile-config.properties @@ -17,15 +17,6 @@ # under the License. # -# Quarkus -quarkus.log.level=INFO -quarkus.log.console.enable=true -quarkus.log.console.level=INFO -quarkus.log.category."org.kie.kogito".level=INFO -#quarkus.log.category."io.vertx".level=INFO -quarkus.log.category."graphql".level=INFO -quarkus.log.category."org.apache.kafka".level=INFO - # Quarkus HTTP quarkus.http.port=8180 quarkus.http.test-port=8181 diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java index d9a1364fcf..6513658fbf 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.List; +import org.kie.kogito.event.process.KogitoMarshallEventSupport; import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessDefinitionDataEvent; import org.kie.kogito.event.process.ProcessInstanceDataEvent; @@ -76,7 +77,7 @@ protected void sendJobEvent() throws Exception { } protected void sendProcessInstanceEventCollection() throws Exception { - Collection> events = List.of( + Collection> events = List.of( getProcessCloudEvent("travels", "processId-UUID1", ProcessInstanceState.ACTIVE, null, null, null, "user1"), getProcessCloudEvent("travels", "processId-UUID2", ProcessInstanceState.ACTIVE, null, null, null, "user2")); connector.source(KOGITO_PROCESSINSTANCES_EVENTS).send(new MultipleProcessInstanceDataEvent(URI.create("test"), events)); diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingKafkaConsumerIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingKafkaConsumerIT.java index c8091f1ee0..fd85d8dfeb 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingKafkaConsumerIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingKafkaConsumerIT.java @@ -25,6 +25,7 @@ import org.eclipse.microprofile.config.inject.ConfigProperty; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.kie.kogito.event.process.KogitoMarshallEventSupport; import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessInstanceDataEvent; import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; @@ -81,7 +82,7 @@ protected void sendJobEvent() throws Exception { @Override protected void sendProcessInstanceEventCollection() throws Exception { - Collection> events = List.of( + Collection> events = List.of( getProcessCloudEvent("travels", "processId-UUID1", ProcessInstanceState.ACTIVE, null, null, null, "user1"), getProcessCloudEvent("travels", "processId-UUID2", ProcessInstanceState.ACTIVE, null, null, null, "user2")); kafkaClient.produce(ObjectMapperFactory.get().writeValueAsString(new MultipleProcessInstanceDataEvent(URI.create("test"), events)), KOGITO_PROCESSINSTANCES_EVENTS); diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/BlockingMessagingEventConsumerTest.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/BlockingMessagingEventConsumerTest.java index c8ac500d96..5fce1f4c80 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/BlockingMessagingEventConsumerTest.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/BlockingMessagingEventConsumerTest.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.kie.kogito.event.DataEvent; +import org.kie.kogito.event.process.KogitoMarshallEventSupport; import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessDefinitionDataEvent; import org.kie.kogito.event.process.ProcessInstanceDataEvent; @@ -70,9 +71,9 @@ void setUp() { @Test void testOnProcessInstanceEvent() { // Arrange - ProcessInstanceDataEvent event1 = mock(ProcessInstanceDataEvent.class); - ProcessInstanceDataEvent event2 = mock(ProcessInstanceDataEvent.class); - Collection> events = Arrays.asList(event1, event2); + ProcessInstanceDataEvent event1 = mock(ProcessInstanceDataEvent.class); + ProcessInstanceDataEvent event2 = mock(ProcessInstanceDataEvent.class); + Collection> events = Arrays.asList(event1, event2); MultipleProcessInstanceDataEvent event = new MultipleProcessInstanceDataEvent(URI.create("dummy"), events); // Act @@ -129,8 +130,8 @@ void testOnProcessDefinitionDataEvent() { @Test void testErrorHandlingInOnProcessInstanceEvent() { // Arrange - ProcessInstanceDataEvent event = mock(ProcessInstanceDataEvent.class); - Collection> events = Arrays.asList(event); + ProcessInstanceDataEvent event = mock(ProcessInstanceDataEvent.class); + Collection> events = Arrays.asList(event); doThrow(new RuntimeException("On purpose! Indexing failed")).when(indexingService).indexProcessInstanceEvent(event); // Act diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverterTest.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverterTest.java index c9ce83ace9..d4bfb38dc7 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverterTest.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverterTest.java @@ -101,6 +101,7 @@ void setUp() { ObjectMapper objectMapper = JsonUtils.getObjectMapper(); new ObjectMapperProducer().customize(objectMapper); converter.setObjectMapper(objectMapper); + converter.init(); } @Test diff --git a/data-index/data-index-service/data-index-service-inmemory/src/main/resources/application.properties b/data-index/data-index-service/data-index-service-inmemory/src/main/resources/application.properties index 8f28492088..d7b4b2778f 100644 --- a/data-index/data-index-service/data-index-service-inmemory/src/main/resources/application.properties +++ b/data-index/data-index-service/data-index-service-inmemory/src/main/resources/application.properties @@ -28,7 +28,7 @@ quarkus.datasource.db-kind=postgresql #Flyway - It's safe to enable Flyway by default for in-memory storage quarkus.flyway.migrate-at-start=true quarkus.flyway.baseline-on-migrate=true -quarkus.flyway.locations=classpath:kie-flyway/db/data-index/postgresql +quarkus.flyway.locations=classpath:kie-flyway/db/data-index/postgresql,classpath:kie-flyway/db/persistence-commons/postgresql #Hibernate quarkus.hibernate-orm.jdbc.timezone=UTC diff --git a/data-index/data-index-service/data-index-service-postgresql/src/main/resources/application.properties b/data-index/data-index-service/data-index-service-postgresql/src/main/resources/application.properties index 4b9e5a219e..acd24a5c60 100644 --- a/data-index/data-index-service/data-index-service-postgresql/src/main/resources/application.properties +++ b/data-index/data-index-service/data-index-service-postgresql/src/main/resources/application.properties @@ -38,4 +38,4 @@ quarkus.container-image.group=org.kie.kogito quarkus.jib.jvm-arguments=-Dquarkus.http.port=8080 # Flyway Locations -quarkus.flyway.locations=classpath:kie-flyway/db/data-index/postgresql \ No newline at end of file +quarkus.flyway.locations=classpath:kie-flyway/db/data-index/postgresql,classpath:kie-flyway/db/persistence-commons/postgresql \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/TestUtils.java b/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/TestUtils.java index 57c05f0498..59ee7601a0 100644 --- a/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/TestUtils.java +++ b/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/TestUtils.java @@ -18,21 +18,16 @@ */ package org.kie.kogito.index.test; +import java.net.URI; import java.time.Instant; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; import org.apache.commons.lang3.RandomStringUtils; -import org.kie.kogito.event.process.ProcessInstanceStateDataEvent; -import org.kie.kogito.event.process.ProcessInstanceStateEventBody; -import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent; -import org.kie.kogito.event.process.ProcessInstanceVariableEventBody; +import org.kie.kogito.event.process.*; +import org.kie.kogito.event.usertask.*; import org.kie.kogito.index.model.Attachment; import org.kie.kogito.index.model.Comment; import org.kie.kogito.index.model.Job; @@ -88,6 +83,137 @@ public static ProcessInstanceVariableDataEvent createProcessInstanceVariableEven return event; } + public static ProcessInstanceNodeDataEvent createProcessInstanceNodeDataEvent(String processInstance, String processId, String nodeDefinitionId, String nodeInstanceId, String nodeName, + String nodeType, int eventType) { + + ProcessInstanceNodeEventBody body = ProcessInstanceNodeEventBody.create() + .processId(processId) + .processInstanceId(processInstance) + .nodeDefinitionId(nodeDefinitionId) + .nodeInstanceId(nodeInstanceId) + .nodeName(nodeName) + .nodeType(nodeType) + .eventDate(new Date()) + .eventType(eventType) + .build(); + + ProcessInstanceNodeDataEvent event = new ProcessInstanceNodeDataEvent(); + event.setKogitoProcessId(processId); + event.setKogitoProcessInstanceId(processInstance); + event.setData(body); + + return event; + } + + public static ProcessInstanceErrorDataEvent createProcessInstanceErrorDataEvent(String processInstance, String processId, String userId, String errorMessage, String nodeDefinitionId, + String nodeInstanceId) { + ProcessInstanceErrorEventBody body = ProcessInstanceErrorEventBody.create() + .eventDate(new Date()) + .eventUser(userId) + .processId(processId) + .processInstanceId(processInstance) + .errorMessage(errorMessage) + .nodeDefinitionId(nodeDefinitionId) + .nodeInstanceId(nodeInstanceId) + .build(); + + ProcessInstanceErrorDataEvent event = new ProcessInstanceErrorDataEvent(); + event.setKogitoProcessInstanceId(processInstance); + event.setKogitoProcessId(processId); + event.setData(body); + return event; + } + + public static UserTaskInstanceStateDataEvent createUserTaskStateEvent(String taskId, String taskName, String processInstanceId, String processId, String state) { + UserTaskInstanceStateEventBody body = UserTaskInstanceStateEventBody.create() + .userTaskInstanceId(taskId) + .userTaskName(taskName) + .state(state) + .processInstanceId(processInstanceId) + .build(); + + UserTaskInstanceStateDataEvent event = new UserTaskInstanceStateDataEvent(); + + event.setKogitoUserTaskInstanceId(taskId); + event.setKogitoProcessInstanceId(processInstanceId); + event.setKogitoProcessId(processId); + + event.setData(body); + + return event; + } + + public static UserTaskInstanceCommentDataEvent createUserTaskCommentEvent(String taskId, String processInstanceId, String processId, String commentId, String comment, String userId, + int eventType) { + + UserTaskInstanceCommentEventBody body = UserTaskInstanceCommentEventBody.create() + .commentId(commentId) + .eventUser(userId) + .commentContent(comment) + .eventDate(new Date()) + .eventType(eventType) + .userTaskInstanceId(taskId) + .build(); + + UserTaskInstanceCommentDataEvent event = new UserTaskInstanceCommentDataEvent(); + event.setKogitoUserTaskInstanceId(taskId); + event.setKogitoProcessInstanceId(processInstanceId); + event.setKogitoProcessId(processId); + event.setData(body); + return event; + } + + public static UserTaskInstanceAttachmentDataEvent createUserTaskAttachmentEvent(String taskId, String processInstanceId, String processId, String attachmentId, String attachmentName, + URI attachmentURI, String userId, int eventType) { + + UserTaskInstanceAttachmentEventBody body = UserTaskInstanceAttachmentEventBody.create() + .attachmentId(attachmentId) + .eventUser(userId) + .attachmentName(attachmentName) + .attachmentURI(attachmentURI) + .eventDate(new Date()) + .eventType(eventType) + .userTaskInstanceId(taskId) + .build(); + + UserTaskInstanceAttachmentDataEvent event = new UserTaskInstanceAttachmentDataEvent(); + event.setKogitoUserTaskInstanceId(taskId); + event.setKogitoProcessInstanceId(processInstanceId); + event.setKogitoProcessId(processId); + event.setData(body); + return event; + } + + public static UserTaskInstanceAssignmentDataEvent createUserTaskAssignmentEvent(String taskId, String processInstanceId, String processId, String assignmentType, String... users) { + UserTaskInstanceAssignmentEventBody body = UserTaskInstanceAssignmentEventBody.create() + .users(users) + .assignmentType(assignmentType) + .build(); + + UserTaskInstanceAssignmentDataEvent event = new UserTaskInstanceAssignmentDataEvent(); + event.setKogitoUserTaskInstanceId(taskId); + event.setKogitoProcessInstanceId(processInstanceId); + event.setKogitoProcessId(processId); + event.setData(body); + return event; + } + + public static UserTaskInstanceVariableDataEvent createUserTaskVariableEvent(String taskId, String processInstanceId, String processId, String variableName, Object variableValue, + String variableType) { + UserTaskInstanceVariableEventBody body = UserTaskInstanceVariableEventBody.create() + .variableName(variableName) + .variableValue(variableValue) + .variableType(variableType) + .build(); + + UserTaskInstanceVariableDataEvent event = new UserTaskInstanceVariableDataEvent(); + event.setKogitoUserTaskInstanceId(taskId); + event.setKogitoProcessInstanceId(processInstanceId); + event.setKogitoProcessId(processId); + event.setData(body); + return event; + } + public static ProcessInstance createProcessInstance(String processInstanceId, String processId, String rootProcessInstanceId, diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java index 1ea09ce497..b60f7ed300 100644 --- a/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java @@ -20,29 +20,158 @@ import java.util.UUID; -import org.apache.commons.lang3.RandomStringUtils; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.model.ProcessInstanceEntityRepository; +import org.kie.kogito.event.process.ProcessInstanceNodeEventBody; +import org.kie.kogito.index.model.ProcessInstance; import org.kie.kogito.index.model.ProcessInstanceState; import org.kie.kogito.index.test.TestUtils; import jakarta.inject.Inject; +import jakarta.transaction.Transactional; public abstract class AbstractProcessInstanceStorageIT { + private static final String PROCESS_ID = "travels"; + private static final String TRAVELER_NAME = "John"; + private static final String TRAVELER_LAST_NAME = "Doe"; @Inject - ProcessInstanceEntityRepository repository; + ProcessInstanceEntityStorage storage; @Test - public void testProcessInstanceEntity() { + @Transactional + public void testProcessInstanceStateEvent() { + String processInstanceId = createNewProcessInstance(); + + ProcessInstance processInstance = storage.get(processInstanceId); + Assertions.assertThat(processInstance) + .isNotNull() + .hasFieldOrPropertyWithValue("id", processInstanceId) + .hasFieldOrPropertyWithValue("processId", PROCESS_ID) + .hasFieldOrPropertyWithValue("state", ProcessInstanceState.ACTIVE.ordinal()) + .hasFieldOrPropertyWithValue("rootProcessInstanceId", null) + .hasFieldOrPropertyWithValue("rootProcessId", null) + .hasFieldOrPropertyWithValue("variables", null); + + storage.indexState(TestUtils.createProcessInstanceEvent(processInstanceId, PROCESS_ID, null, null, ProcessInstanceState.COMPLETED.ordinal())); + + processInstance = storage.get(processInstanceId); + Assertions.assertThat(processInstance) + .isNotNull() + .hasFieldOrPropertyWithValue("id", processInstanceId) + .hasFieldOrPropertyWithValue("processId", PROCESS_ID) + .hasFieldOrPropertyWithValue("state", ProcessInstanceState.COMPLETED.ordinal()) + .hasFieldOrPropertyWithValue("rootProcessInstanceId", null) + .hasFieldOrPropertyWithValue("rootProcessId", null) + .hasFieldOrPropertyWithValue("variables", null); + } + + @Test + @Transactional + public void testProcessInstanceErrorEvent() { + String processInstanceId = createNewProcessInstance(); + + ProcessInstance processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getError()) + .isNull(); + + String nodeDefinitionId = UUID.randomUUID().toString(); + storage.indexError(TestUtils.createProcessInstanceErrorDataEvent(processInstanceId, PROCESS_ID, TRAVELER_NAME, "This is really wrong", nodeDefinitionId, UUID.randomUUID().toString())); + + processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getError()) + .isNotNull() + .hasFieldOrPropertyWithValue("nodeDefinitionId", nodeDefinitionId) + .hasFieldOrPropertyWithValue("message", "This is really wrong"); + } + + @Test + @Transactional + public void testProcessInstanceNodeEvent() { + String processInstanceId = createNewProcessInstance(); + + ProcessInstance processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getNodes()) + .isEmpty(); + + String nodeDefinitionId = UUID.randomUUID().toString(); + String nodeInstanceId = UUID.randomUUID().toString(); + + storage.indexNode(TestUtils.createProcessInstanceNodeDataEvent(processInstanceId, PROCESS_ID, nodeDefinitionId, nodeInstanceId, "nodeName", "BoundaryEventNode", + ProcessInstanceNodeEventBody.EVENT_TYPE_ENTER)); + + processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getNodes()) + .hasSize(1); + + Assertions.assertThat(processInstance.getNodes().get(0)) + .hasNoNullFieldsOrPropertiesExcept("exit") + .hasFieldOrPropertyWithValue("name", "nodeName") + .hasFieldOrPropertyWithValue("type", "BoundaryEventNode") + .hasFieldOrPropertyWithValue("definitionId", nodeDefinitionId) + .hasFieldOrPropertyWithValue("nodeId", nodeDefinitionId) + .hasFieldOrPropertyWithValue("id", nodeInstanceId); + + storage.indexNode(TestUtils.createProcessInstanceNodeDataEvent(processInstanceId, PROCESS_ID, nodeDefinitionId, nodeInstanceId, "nodeName", "BoundaryEventNode", + ProcessInstanceNodeEventBody.EVENT_TYPE_EXIT)); + + processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getNodes()) + .hasSize(1); + + Assertions.assertThat(processInstance.getNodes().get(0)) + .hasNoNullFieldsOrProperties() + .hasFieldOrPropertyWithValue("name", "nodeName") + .hasFieldOrPropertyWithValue("type", "BoundaryEventNode") + .hasFieldOrPropertyWithValue("definitionId", nodeDefinitionId) + .hasFieldOrPropertyWithValue("nodeId", nodeDefinitionId) + .hasFieldOrPropertyWithValue("id", nodeInstanceId); + } + + @Test + @Transactional + public void testProcessInstanceVariableEvent() { + String processInstanceId = createNewProcessInstance(); + + ProcessInstance processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getVariables()) + .isNull(); + + storage.indexVariable(TestUtils.createProcessInstanceVariableEvent(processInstanceId, PROCESS_ID, TRAVELER_NAME, TRAVELER_LAST_NAME)); + + processInstance = storage.get(processInstanceId); + + Assertions.assertThatObject(processInstance.getVariables()) + .isNotNull() + .extracting(jsonNodes -> jsonNodes.at("/traveller/firstName").asText(), jsonNodes -> jsonNodes.at("/traveller/lastName").asText()) + .contains(TRAVELER_NAME, TRAVELER_LAST_NAME); + } + + private String createNewProcessInstance() { String processInstanceId = UUID.randomUUID().toString(); - TestUtils - .createProcessInstance(processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), - RandomStringUtils.randomAlphabetic(10), ProcessInstanceState.ACTIVE.ordinal(), 0L); - TestUtils - .createProcessInstance(processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), - RandomStringUtils.randomAlphabetic(10), ProcessInstanceState.COMPLETED.ordinal(), 1000L); + Assertions.assertThat(storage.get(processInstanceId)) + .isNull(); + + storage.indexState(TestUtils.createProcessInstanceEvent(processInstanceId, PROCESS_ID, null, null, ProcessInstanceState.ACTIVE.ordinal())); + + ProcessInstance processInstance = storage.get(processInstanceId); + Assertions.assertThat(processInstance) + .isNotNull() + .hasFieldOrPropertyWithValue("id", processInstanceId) + .hasFieldOrPropertyWithValue("processId", PROCESS_ID) + .hasFieldOrPropertyWithValue("state", ProcessInstanceState.ACTIVE.ordinal()) + .hasFieldOrPropertyWithValue("rootProcessInstanceId", null) + .hasFieldOrPropertyWithValue("rootProcessId", null) + .hasFieldOrPropertyWithValue("variables", null); + + return processInstanceId; } } diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java index 9b8c0056c9..d44d534955 100644 --- a/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java @@ -18,19 +18,226 @@ */ package org.kie.kogito.index.jpa.storage; -import java.util.UUID; +import java.net.URI; +import java.util.*; import org.apache.commons.lang3.RandomStringUtils; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; +import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentEventBody; +import org.kie.kogito.index.jpa.model.UserTaskInstanceEntity; import org.kie.kogito.index.jpa.model.UserTaskInstanceEntityRepository; +import org.kie.kogito.index.model.UserTaskInstance; +import org.kie.kogito.index.storage.UserTaskInstanceStorage; import org.kie.kogito.index.test.TestUtils; import jakarta.inject.Inject; +import jakarta.transaction.Transactional; public abstract class AbstractUserTaskInstanceStorageIT { + private static final String PROCESS_INSTANCE_ID = "87daz3446-2386-4056-91dc-dbc3804d157c"; + private static final String PROCESS_ID = "travels"; + private static final String TASK_NAME = "HR Interview"; + + @Inject + UserTaskInstanceStorage storage; + @Inject - UserTaskInstanceEntityRepository repository; + UserTaskInstanceEntityRepository userTaskInstanceRepository; + + @Test + @Transactional + public void testUserTaskStateEvent() { + String taskId = createUserTaskInstance(); + + storage.indexState(TestUtils.createUserTaskStateEvent(taskId, TASK_NAME, PROCESS_INSTANCE_ID, PROCESS_ID, "Completed")); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task) + .isNotNull() + .hasFieldOrPropertyWithValue("id", taskId) + .hasFieldOrPropertyWithValue("name", TASK_NAME) + .hasFieldOrPropertyWithValue("processId", PROCESS_ID) + .hasFieldOrPropertyWithValue("processInstanceId", PROCESS_INSTANCE_ID) + .hasFieldOrPropertyWithValue("state", "Completed"); + } + + @Test + @Transactional + public void testUserTaskAssignmentEvents() { + + String taskId = createUserTaskInstance(); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task) + .hasFieldOrPropertyWithValue("potentialUsers", null) + .hasFieldOrPropertyWithValue("potentialGroups", null) + .hasFieldOrPropertyWithValue("adminGroups", null) + .hasFieldOrPropertyWithValue("adminUsers", null) + .hasFieldOrPropertyWithValue("excludedUsers", null); + + storage.indexAssignment(TestUtils.createUserTaskAssignmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "USER_OWNERS", "John")); + storage.indexAssignment(TestUtils.createUserTaskAssignmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "USER_GROUPS", "user-group")); + storage.indexAssignment(TestUtils.createUserTaskAssignmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "ADMIN_GROUPS", "administrators")); + storage.indexAssignment(TestUtils.createUserTaskAssignmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "ADMIN_USERS", "super-user")); + storage.indexAssignment(TestUtils.createUserTaskAssignmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "USERS_EXCLUDED", "excluded-user")); + + task = storage.get(taskId); + + Assertions.assertThat(task.getPotentialUsers()) + .containsExactly("John"); + Assertions.assertThat(task.getPotentialGroups()) + .containsExactly("user-group"); + Assertions.assertThat(task.getAdminGroups()) + .containsExactly("administrators"); + Assertions.assertThat(task.getAdminUsers()) + .containsExactly("super-user"); + Assertions.assertThat(task.getExcludedUsers()) + .containsExactly("excluded-user"); + } + + @Transactional + @Test + public void testUserTaskVariableEvents() { + String taskId = createUserTaskInstance(); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task.getInputs()) + .isNull(); + Assertions.assertThat(task.getOutputs()) + .isNull(); + + Map person = new HashMap<>(); + person.put("firstName", "John"); + person.put("lastName", "Doe"); + + storage.indexVariable(TestUtils.createUserTaskVariableEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "person", person, "INPUT")); + + task = storage.get(taskId); + + Assertions.assertThatObject(task.getInputs()) + .isNotNull() + .extracting(jsonNodes -> jsonNodes.at("/person/firstName").asText(), jsonNodes -> jsonNodes.at("/person/lastName").asText()) + .contains("John", "Doe"); + + Assertions.assertThat(task.getOutputs()) + .isNull(); + + person = new HashMap<>(); + person.put("age", 50); + person.put("married", true); + + storage.indexVariable(TestUtils.createUserTaskVariableEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "person", person, "OUTPUT")); + + task = storage.get(taskId); + + Assertions.assertThatObject(task.getOutputs()) + .isNotNull() + .extracting(jsonNodes -> jsonNodes.at("/person/age").asInt(), jsonNodes -> jsonNodes.at("/person/married").asBoolean()) + .contains(50, true); + } + + @Transactional + @Test + public void testUserTaskCommentEvents() { + String taskId = createUserTaskInstance(); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task.getComments()) + .isEmpty(); + + String commentId = UUID.randomUUID().toString(); + storage.indexComment( + TestUtils.createUserTaskCommentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, commentId, "this is a comment", "John", UserTaskInstanceAttachmentEventBody.EVENT_TYPE_ADDED)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getComments()) + .hasSize(1); + + Assertions.assertThat(task.getComments().get(0)) + .hasNoNullFieldsOrProperties() + .hasFieldOrPropertyWithValue("id", commentId) + .hasFieldOrPropertyWithValue("content", "this is a comment") + .hasFieldOrPropertyWithValue("updatedBy", "John"); + + storage.indexComment( + TestUtils.createUserTaskCommentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, commentId, "this is an updated comment", "John", UserTaskInstanceAttachmentEventBody.EVENT_TYPE_CHANGE)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getComments()) + .hasSize(1); + + Assertions.assertThat(task.getComments().get(0)) + .hasNoNullFieldsOrProperties() + .hasFieldOrPropertyWithValue("id", commentId) + .hasFieldOrPropertyWithValue("content", "this is an updated comment") + .hasFieldOrPropertyWithValue("updatedBy", "John"); + + storage.indexComment( + TestUtils.createUserTaskCommentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, commentId, "this is an updated comment", "John", UserTaskInstanceAttachmentEventBody.EVENT_TYPE_DELETED)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getComments()) + .hasSize(0); + } + + @Transactional + @Test + public void testUserTaskAttachmentEvents() { + String taskId = createUserTaskInstance(); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task.getAttachments()) + .isEmpty(); + + String attachmentId = UUID.randomUUID().toString(); + storage.indexAttachment(TestUtils.createUserTaskAttachmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, attachmentId, "Attachment-1", URI.create("http://localhost:8080/my-doc.txt"), "John", + UserTaskInstanceAttachmentEventBody.EVENT_TYPE_ADDED)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getAttachments()) + .hasSize(1); + + Assertions.assertThat(task.getAttachments().get(0)) + .hasNoNullFieldsOrProperties() + .hasFieldOrPropertyWithValue("id", attachmentId) + .hasFieldOrPropertyWithValue("name", "Attachment-1") + .hasFieldOrPropertyWithValue("content", "http://localhost:8080/my-doc.txt") + .hasFieldOrPropertyWithValue("updatedBy", "John"); + + storage.indexAttachment(TestUtils.createUserTaskAttachmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, attachmentId, "Attachment-1.2", URI.create("http://localhost:8080/my-doc2.txt"), + "John", UserTaskInstanceAttachmentEventBody.EVENT_TYPE_CHANGE)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getAttachments()) + .hasSize(1); + + Assertions.assertThat(task.getAttachments().get(0)) + .hasNoNullFieldsOrProperties() + .hasFieldOrPropertyWithValue("id", attachmentId) + .hasFieldOrPropertyWithValue("name", "Attachment-1.2") + .hasFieldOrPropertyWithValue("content", "http://localhost:8080/my-doc2.txt") + .hasFieldOrPropertyWithValue("updatedBy", "John"); + + storage.indexAttachment(TestUtils.createUserTaskAttachmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, attachmentId, "Attachment-1", URI.create("http://localhost:8080/my-doc2.txt"), "John", + UserTaskInstanceAttachmentEventBody.EVENT_TYPE_DELETED)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getAttachments()) + .hasSize(0); + } @Test public void testUserTaskInstanceEntity() { @@ -46,4 +253,26 @@ public void testUserTaskInstanceEntity() { RandomStringUtils.randomAlphabetic(10), "Completed", 1000L); } + private String createUserTaskInstance() { + String taskId = UUID.randomUUID().toString(); + + storage.indexState(TestUtils.createUserTaskStateEvent(taskId, TASK_NAME, PROCESS_INSTANCE_ID, PROCESS_ID, "InProgress")); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task) + .isNotNull() + .hasFieldOrPropertyWithValue("id", taskId) + .hasFieldOrPropertyWithValue("name", TASK_NAME) + .hasFieldOrPropertyWithValue("processId", PROCESS_ID) + .hasFieldOrPropertyWithValue("processInstanceId", PROCESS_INSTANCE_ID) + .hasFieldOrPropertyWithValue("state", "InProgress"); + + // Initializing comments and attachments just for the test + UserTaskInstanceEntity taskInstanceEntity = userTaskInstanceRepository.findById(taskId); + taskInstanceEntity.setComments(new ArrayList<>()); + taskInstanceEntity.setAttachments(new ArrayList<>()); + + return taskId; + } } 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 393cc0901d..7db734cf5e 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 @@ -38,7 +38,7 @@ src/main/resources/${path.to.flyway.location} ${path.to.postgresql.storage}/${path.to.script.folder} target/classes/${path.to.flyway.location} - org.kie.kogito.index.jpa + org.kie.kogito.index.jpa @@ -60,6 +60,11 @@ quarkus-test-h2 test + + io.quarkus + quarkus-jdbc-postgresql + test + org.kie.kogito data-index-storage-api diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/kie-flyway.properties b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/kie-flyway.properties index 41c52109f4..35f70ad9f3 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/kie-flyway.properties +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/kie-flyway.properties @@ -19,5 +19,5 @@ module.name=data-index -module.locations.postgresql=classpath:kie-flyway/db/data-index/postgresql,classpath:kie-flyway/db/persistence-commons/postgresql -module.locations.default=classpath:kie-flyway/db/data-index/ansi,classpath:kie-flyway/db/persistence-commons/ansi \ No newline at end of file +module.locations.postgresql=classpath:kie-flyway/db/data-index/postgresql +module.locations.default=classpath:kie-flyway/db/data-index/ansi \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/orm.xml b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/orm.xml deleted file mode 100644 index 2e9789c752..0000000000 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/orm.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.33.0__data_index_create.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.33.0__data_index_create.sql index 564a9c72e9..3aa01f1e84 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.33.0__data_index_create.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.33.0__data_index_create.sql @@ -98,7 +98,7 @@ create table processes root_process_instance_id varchar(255), start_time timestamp, state integer, - variables varbinary(max), + variables varchar(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 varbinary(max), + inputs varchar(max), last_update timestamp, name varchar(255), - outputs varbinary(max), + outputs varchar(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/kie-flyway/db/data-index/ansi/V1.44.0__data_index_definitions.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.44.0__data_index_definitions.sql index 4f361d57c1..2dbdee38e1 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.44.0__data_index_definitions.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.44.0__data_index_definitions.sql @@ -19,28 +19,28 @@ create table definitions ( - id varchar2(255) not null, - version varchar2(255) not null, - name varchar2(255), + id varchar(255) not null, + version varchar(255) not null, + name varchar(255), source bytea, - type varchar2(255), - endpoint varchar2(255), + type varchar(255), + endpoint varchar(255), primary key (id, version) ); create table definitions_addons ( - process_id varchar2(255) not null, - process_version varchar2(255) not null, - addon varchar2(255) not null, + process_id varchar(255) not null, + process_version varchar(255) not null, + addon varchar(255) not null, primary key (process_id, process_version, addon) ); create table definitions_roles ( - process_id varchar2(255) not null, - process_version varchar2(255) not null, - role varchar2(255) not null, + process_id varchar(255) not null, + process_version varchar(255) not null, + role varchar(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 column version varchar2(255); \ No newline at end of file + add column version varchar(255); \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.0__data_index_node_definitions.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.0__data_index_node_definitions.sql index 7bce973a34..e318e7d5f8 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.0__data_index_node_definitions.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.0__data_index_node_definitions.sql @@ -19,22 +19,22 @@ create table definitions_nodes ( - 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, + id varchar(255) not null, + name varchar(255), + type varchar(255), + unique_id varchar(255), + process_id varchar(255) not null, + process_version varchar(255) not null, primary key (id, process_id, process_version) ); create table definitions_nodes_metadata ( - 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, + node_id varchar(255) not null, + process_id varchar(255) not null, + process_version varchar(255) not null, + value varchar(255), + key varchar(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/kie-flyway/db/data-index/ansi/V1.45.0.2__data_index_definitions_add_colums.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.2__data_index_definitions_add_colums.sql index 8abae1b55a..30dad9ca80 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.2__data_index_definitions_add_colums.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.2__data_index_definitions_add_colums.sql @@ -19,18 +19,18 @@ create table definitions_annotations ( - value varchar2(255) not null, - process_id varchar2(255) not null, - process_version varchar2(255) not null, + value varchar(255) not null, + process_id varchar(255) not null, + process_version varchar(255) not null, primary key (value, process_id, process_version) ); create table definitions_metadata ( - process_id varchar2(255) not null, - process_version varchar2(255) not null, - value varchar2(255), - key varchar2(255) not null, + process_id varchar(255) not null, + process_version varchar(255) not null, + value varchar(255), + key varchar(255) not null, primary key (process_id, process_version, key) ); diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/readme.txt b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/readme.txt new file mode 100644 index 0000000000..e08db4d0ae --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/readme.txt @@ -0,0 +1,2 @@ +Ensure migration scripts are developed to support several executions over the same database without any error. +This feature will make sure this migration execution would be compatible with other needed flyway migrations without broking the chain. \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/H2QuarkusTestProfile.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/H2QuarkusTestProfile.java new file mode 100644 index 0000000000..b42ab3699d --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/H2QuarkusTestProfile.java @@ -0,0 +1,30 @@ +/* + * 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.index.jdbc; + +import io.quarkus.test.junit.QuarkusTestProfile; + +public class H2QuarkusTestProfile implements QuarkusTestProfile { + + @Override + public String getConfigProfile() { + return "test-h2"; + } +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/PostgreSQLQuarkusTestProfile.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/PostgreSQLQuarkusTestProfile.java new file mode 100644 index 0000000000..4445c0f4ff --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/PostgreSQLQuarkusTestProfile.java @@ -0,0 +1,30 @@ +/* + * 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.index.jdbc; + +import io.quarkus.test.junit.QuarkusTestProfile; + +public class PostgreSQLQuarkusTestProfile implements QuarkusTestProfile { + + @Override + public String getConfigProfile() { + return "test-postgresql"; + } +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/JobEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2JobEntityQueryIT.java similarity index 75% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/JobEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2JobEntityQueryIT.java index a99c7eeabd..88aa60b863 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/JobEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2JobEntityQueryIT.java @@ -18,14 +18,19 @@ */ package org.kie.kogito.index.jdbc.query; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.query.AbstractJobEntityQueryIT; +import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class JobEntityQueryIT extends AbstractJobEntityQueryIT { +@TestTransaction +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +class H2JobEntityQueryIT extends AbstractJobEntityQueryIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessDefinitionEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessDefinitionEntityQueryIT.java similarity index 74% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessDefinitionEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessDefinitionEntityQueryIT.java index c99803b83a..704c46164b 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessDefinitionEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessDefinitionEntityQueryIT.java @@ -18,14 +18,19 @@ */ package org.kie.kogito.index.jdbc.query; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.query.AbstractProcessDefinitionEntityQueryIT; +import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class ProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionEntityQueryIT { +@TestTransaction +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +class H2ProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionEntityQueryIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessInstanceEntityQueryIT.java similarity index 75% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessInstanceEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessInstanceEntityQueryIT.java index 10bd679b53..c68e22d9d0 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessInstanceEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessInstanceEntityQueryIT.java @@ -18,15 +18,20 @@ */ package org.kie.kogito.index.jdbc.query; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.query.AbstractProcessInstanceEntityQueryIT; +import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class ProcessInstanceEntityQueryIT extends AbstractProcessInstanceEntityQueryIT { +@TestTransaction +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +class H2ProcessInstanceEntityQueryIT extends AbstractProcessInstanceEntityQueryIT { @Override protected Boolean isDateTimeAsLong() { diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/UserTaskInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2UserTaskInstanceEntityQueryIT.java similarity index 74% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/UserTaskInstanceEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2UserTaskInstanceEntityQueryIT.java index abaffc8741..79e6ea184b 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/UserTaskInstanceEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2UserTaskInstanceEntityQueryIT.java @@ -18,14 +18,19 @@ */ package org.kie.kogito.index.jdbc.query; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.query.AbstractUserTaskInstanceEntityQueryIT; +import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class UserTaskInstanceEntityQueryIT extends AbstractUserTaskInstanceEntityQueryIT { +@TestTransaction +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +class H2UserTaskInstanceEntityQueryIT extends AbstractUserTaskInstanceEntityQueryIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLJobEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLJobEntityQueryIT.java new file mode 100644 index 0000000000..049b7596de --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLJobEntityQueryIT.java @@ -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. + */ +package org.kie.kogito.index.jdbc.query; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.query.AbstractJobEntityQueryIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgreSQLJobEntityQueryIT extends AbstractJobEntityQueryIT { + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessDefinitionEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessDefinitionEntityQueryIT.java new file mode 100644 index 0000000000..55d756025d --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessDefinitionEntityQueryIT.java @@ -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. + */ +package org.kie.kogito.index.jdbc.query; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.query.AbstractProcessDefinitionEntityQueryIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgreSQLProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionEntityQueryIT { + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessInstanceEntityQueryIT.java new file mode 100644 index 0000000000..13fddcf9c0 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessInstanceEntityQueryIT.java @@ -0,0 +1,40 @@ +/* + * 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.index.jdbc.query; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.query.AbstractProcessInstanceEntityQueryIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgreSQLProcessInstanceEntityQueryIT extends AbstractProcessInstanceEntityQueryIT { + + @Override + protected Boolean isDateTimeAsLong() { + return false; + } +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLUserTaskInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLUserTaskInstanceEntityQueryIT.java new file mode 100644 index 0000000000..1574f3833c --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLUserTaskInstanceEntityQueryIT.java @@ -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. + */ +package org.kie.kogito.index.jdbc.query; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.query.AbstractUserTaskInstanceEntityQueryIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgreSQLUserTaskInstanceEntityQueryIT extends AbstractUserTaskInstanceEntityQueryIT { + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/JobStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2JobStorageIT.java similarity index 79% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/JobStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2JobStorageIT.java index 88c5db0fbb..3a6815e467 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/JobStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2JobStorageIT.java @@ -18,14 +18,16 @@ */ package org.kie.kogito.index.jdbc.storage; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.storage.AbstractJobStorageIT; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -public class JobStorageIT extends AbstractJobStorageIT { +@TestTransaction +@TestProfile(H2QuarkusTestProfile.class) +public class H2JobStorageIT extends AbstractJobStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessDefinitionStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessDefinitionStorageIT.java similarity index 78% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessDefinitionStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessDefinitionStorageIT.java index b0369d8369..ab110245e0 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessDefinitionStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessDefinitionStorageIT.java @@ -18,14 +18,16 @@ */ package org.kie.kogito.index.jdbc.storage; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.storage.AbstractProcessDefinitionStorageIT; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class ProcessDefinitionStorageIT extends AbstractProcessDefinitionStorageIT { +@TestTransaction +@TestProfile(H2QuarkusTestProfile.class) +class H2ProcessDefinitionStorageIT extends AbstractProcessDefinitionStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessInstanceStorageIT.java similarity index 77% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessInstanceStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessInstanceStorageIT.java index 9f40d50928..3b73dd3fb3 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessInstanceStorageIT.java @@ -18,13 +18,15 @@ */ package org.kie.kogito.index.jdbc.storage; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.storage.AbstractProcessInstanceStorageIT; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -public class ProcessInstanceStorageIT extends AbstractProcessInstanceStorageIT { +@TestTransaction +@TestProfile(H2QuarkusTestProfile.class) +public class H2ProcessInstanceStorageIT extends AbstractProcessInstanceStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/UserTaskInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2UserTaskInstanceStorageIT.java similarity index 77% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/UserTaskInstanceStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2UserTaskInstanceStorageIT.java index 4a6b9921e5..b8b5105c6a 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/UserTaskInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2UserTaskInstanceStorageIT.java @@ -18,13 +18,15 @@ */ package org.kie.kogito.index.jdbc.storage; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.storage.AbstractUserTaskInstanceStorageIT; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -public class UserTaskInstanceStorageIT extends AbstractUserTaskInstanceStorageIT { +@TestTransaction +@TestProfile(H2QuarkusTestProfile.class) +public class H2UserTaskInstanceStorageIT extends AbstractUserTaskInstanceStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLJobStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLJobStorageIT.java new file mode 100644 index 0000000000..df8d352480 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLJobStorageIT.java @@ -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. + */ +package org.kie.kogito.index.jdbc.storage; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.storage.AbstractJobStorageIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +public class PostgreSQLJobStorageIT extends AbstractJobStorageIT { + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessDefinitionStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessDefinitionStorageIT.java new file mode 100644 index 0000000000..31c2f1109d --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessDefinitionStorageIT.java @@ -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. + */ +package org.kie.kogito.index.jdbc.storage; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.storage.AbstractProcessDefinitionStorageIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgreSQLProcessDefinitionStorageIT extends AbstractProcessDefinitionStorageIT { + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessInstanceStorageIT.java new file mode 100644 index 0000000000..19c7e61237 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessInstanceStorageIT.java @@ -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. + */ +package org.kie.kogito.index.jdbc.storage; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.storage.AbstractProcessInstanceStorageIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +public class PostgreSQLProcessInstanceStorageIT extends AbstractProcessInstanceStorageIT { +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLUserTaskInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLUserTaskInstanceStorageIT.java new file mode 100644 index 0000000000..f0284db9f0 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLUserTaskInstanceStorageIT.java @@ -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. + */ +package org.kie.kogito.index.jdbc.storage; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.storage.AbstractUserTaskInstanceStorageIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +public class PostgreSQLUserTaskInstanceStorageIT extends AbstractUserTaskInstanceStorageIT { +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties b/data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties index a5b6fe7459..eb83483fe9 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties @@ -21,13 +21,19 @@ kogito.apps.persistence.type=jdbc kie.flyway.enabled=true -# Data source -quarkus.datasource.db-kind=h2 -quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test;NON_KEYWORDS=VALUE,KEY +# Data sources +%test-postgresql.quarkus.datasource.db-kind=postgresql +%test-postgresql.quarkus.datasource.devservices.enabled=false +%test-h2.quarkus.datasource.db-kind=h2 +%test-h2.quarkus.datasource.username=kogito +%test-h2.quarkus.datasource.jdbc.url=jdbc:h2:mem:default;NON_KEYWORDS=VALUE,KEY + # Hibernate quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy quarkus.hibernate-orm.jdbc.timezone=UTC -quarkus.hibernate-orm.log.sql=true +# Enforcing flush to ensure data is correctly stored in DB +quarkus.hibernate-orm.flush.mode=always + # Disabling Security for tests quarkus.oidc.enabled=false diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/META-INF/kie-flyway.properties b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/META-INF/kie-flyway.properties index 383546a8fe..4adfed0d42 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/META-INF/kie-flyway.properties +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/META-INF/kie-flyway.properties @@ -19,4 +19,4 @@ module.name=data-index -module.locations.postgresql=classpath:kie-flyway/db/data-index/postgresql,classpath:kie-flyway/db/persistence-commons/postgresql \ No newline at end of file +module.locations.postgresql=classpath:kie-flyway/db/data-index/postgresql \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessInstanceStorageIT.java index 0ad8baf9b6..0ac176627c 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessInstanceStorageIT.java @@ -21,10 +21,12 @@ import org.kie.kogito.index.jpa.storage.AbstractProcessInstanceStorageIT; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; +import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; @QuarkusTest +@TestTransaction @QuarkusTestResource(PostgreSqlQuarkusTestResource.class) public class ProcessInstanceStorageIT extends AbstractProcessInstanceStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/resources/application.properties b/data-index/data-index-storage/data-index-storage-postgresql/src/test/resources/application.properties index b5637dfd64..a91fc1a378 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/resources/application.properties +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/resources/application.properties @@ -25,8 +25,7 @@ quarkus.datasource.username=kogito quarkus.datasource.password=kogito quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/kogito # Hibernate -quarkus.hibernate-orm.database.generation=drop-and-create -quarkus.hibernate-orm.database.generation.halt-on-error=true + quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy quarkus.hibernate-orm.jdbc.timezone=UTC quarkus.hibernate-orm.log.sql=true diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-inmemory/runtime/src/main/resources/application.properties b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-inmemory/runtime/src/main/resources/application.properties index 17182933f0..36c137123b 100644 --- a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-inmemory/runtime/src/main/resources/application.properties +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-inmemory/runtime/src/main/resources/application.properties @@ -32,7 +32,7 @@ quarkus.hibernate-orm.datasource=data_index quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy #Flyway -quarkus.flyway."data_index".locations=classpath:/kie-flyway/db/data-index/postgresql +quarkus.flyway."data_index".locations=classpath:/kie-flyway/db/data-index/postgresql,classpath:kie-flyway/db/persistence-commons/postgresql quarkus.flyway."data_index".migrate-at-start=true kie.flyway.modules."data-index".enabled=false \ No newline at end of file diff --git a/jitexecutor/jitexecutor-common/src/main/java/org/kie/kogito/jitexecutor/common/Constants.java b/jitexecutor/jitexecutor-common/src/main/java/org/kie/kogito/jitexecutor/common/Constants.java index ed8079006b..17999225e6 100644 --- a/jitexecutor/jitexecutor-common/src/main/java/org/kie/kogito/jitexecutor/common/Constants.java +++ b/jitexecutor/jitexecutor-common/src/main/java/org/kie/kogito/jitexecutor/common/Constants.java @@ -6,9 +6,9 @@ * 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 diff --git a/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/DMNEvaluator.java b/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/DMNEvaluator.java index 92ec93303f..7c73c5eccc 100644 --- a/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/DMNEvaluator.java +++ b/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/DMNEvaluator.java @@ -22,7 +22,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Optional; @@ -81,12 +80,12 @@ public JITDMNResult evaluate(Map context) { DMNContext dmnContext = new DynamicDMNContextBuilder(dmnRuntime.newContext(), dmnModel).populateContextWith(context); DMNResult dmnResult = dmnRuntime.evaluateAll(dmnModel, dmnContext); - Optional> evaluationHitIds = dmnRuntime.getListeners().stream() + Optional> evaluationHitIds = dmnRuntime.getListeners().stream() .filter(JITDMNListener.class::isInstance) .findFirst() .map(JITDMNListener.class::cast) .map(JITDMNListener::getEvaluationHitIds); - return new JITDMNResult(getNamespace(), getName(), dmnResult, evaluationHitIds.orElse(Collections.emptyList())); + return new JITDMNResult(getNamespace(), getName(), dmnResult, evaluationHitIds.orElse(Collections.emptyMap())); } public static DMNEvaluator fromMultiple(MultipleResourcesPayload payload) { diff --git a/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/JITDMNListener.java b/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/JITDMNListener.java index 9f753e7548..2da2e74e4c 100644 --- a/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/JITDMNListener.java +++ b/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/JITDMNListener.java @@ -18,8 +18,8 @@ */ package org.kie.kogito.jitexecutor.dmn; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import org.kie.dmn.api.core.event.AfterConditionalEvaluationEvent; import org.kie.dmn.api.core.event.AfterEvaluateAllEvent; @@ -36,14 +36,14 @@ public class JITDMNListener implements DMNRuntimeEventListener { - private final List evaluationHitIds = new ArrayList<>(); + private final Map evaluationHitIds = new HashMap<>(); private static final Logger LOGGER = LoggerFactory.getLogger(JITDMNListener.class); @Override public void afterEvaluateDecisionTable(AfterEvaluateDecisionTableEvent event) { logEvent(event); - evaluationHitIds.addAll(event.getSelectedIds()); + event.getSelectedIds().forEach(s -> evaluationHitIds.compute(s, (k, v) -> v == null ? 1 : v + 1)); } @Override @@ -79,10 +79,10 @@ public void afterEvaluateAll(AfterEvaluateAllEvent event) { @Override public void afterConditionalEvaluation(AfterConditionalEvaluationEvent event) { logEvent(event); - evaluationHitIds.add(event.getExecutedId()); + evaluationHitIds.compute(event.getExecutedId(), (k, v) -> v == null ? 1 : v + 1); } - public List getEvaluationHitIds() { + public Map getEvaluationHitIds() { return evaluationHitIds; } diff --git a/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/responses/JITDMNResult.java b/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/responses/JITDMNResult.java index 4f43a123f6..c444dd0148 100644 --- a/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/responses/JITDMNResult.java +++ b/jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/responses/JITDMNResult.java @@ -50,17 +50,17 @@ public class JITDMNResult implements Serializable, private Map decisionResults = new HashMap<>(); - private List evaluationHitIds; + private Map evaluationHitIds; public JITDMNResult() { // Intentionally blank. } public JITDMNResult(String namespace, String modelName, org.kie.dmn.api.core.DMNResult dmnResult) { - this(namespace, modelName, dmnResult, Collections.emptyList()); + this(namespace, modelName, dmnResult, Collections.emptyMap()); } - public JITDMNResult(String namespace, String modelName, org.kie.dmn.api.core.DMNResult dmnResult, List evaluationHitIds) { + public JITDMNResult(String namespace, String modelName, org.kie.dmn.api.core.DMNResult dmnResult, Map evaluationHitIds) { this.namespace = namespace; this.modelName = modelName; this.setDmnContext(dmnResult.getContext().getAll()); @@ -110,11 +110,11 @@ public void setDecisionResults(List decisionResults } } - public List getEvaluationHitIds() { + public Map getEvaluationHitIds() { return evaluationHitIds; } - public void setEvaluationHitIds(List evaluationHitIds) { + public void setEvaluationHitIds(Map evaluationHitIds) { this.evaluationHitIds = evaluationHitIds; } diff --git a/jitexecutor/jitexecutor-dmn/src/test/java/org/kie/kogito/jitexecutor/dmn/JITDMNServiceImplTest.java b/jitexecutor/jitexecutor-dmn/src/test/java/org/kie/kogito/jitexecutor/dmn/JITDMNServiceImplTest.java index e99957ef0c..0e627f7a33 100644 --- a/jitexecutor/jitexecutor-dmn/src/test/java/org/kie/kogito/jitexecutor/dmn/JITDMNServiceImplTest.java +++ b/jitexecutor/jitexecutor-dmn/src/test/java/org/kie/kogito/jitexecutor/dmn/JITDMNServiceImplTest.java @@ -79,7 +79,8 @@ void testDecisionTableModelEvaluation() throws IOException { JITDMNResult dmnResult = jitdmnService.evaluateModel(decisionTableModel, context); Assertions.assertEquals("LoanEligibility", dmnResult.getModelName()); - Assertions.assertEquals("https://github.com/kiegroup/kogito-examples/dmn-quarkus-listener-example", dmnResult.getNamespace()); + Assertions.assertEquals("https://github.com/kiegroup/kogito-examples/dmn-quarkus-listener-example", + dmnResult.getNamespace()); Assertions.assertTrue(dmnResult.getMessages().isEmpty()); Assertions.assertEquals("Yes", dmnResult.getDecisionResultByName("Eligibility").getResult()); } @@ -101,12 +102,12 @@ void testEvaluationHitIds() throws IOException { Assertions.assertEquals("DMN_A77074C1-21FE-4F7E-9753-F84661569AFC", dmnResult.getModelName()); Assertions.assertTrue(dmnResult.getMessages().isEmpty()); Assertions.assertEquals(BigDecimal.valueOf(50), dmnResult.getDecisionResultByName("Risk Score").getResult()); - List evaluationHitIds = dmnResult.getEvaluationHitIds(); + Map evaluationHitIds = dmnResult.getEvaluationHitIds(); Assertions.assertNotNull(evaluationHitIds); Assertions.assertEquals(3, evaluationHitIds.size()); - Assertions.assertTrue(evaluationHitIds.contains(elseElementId)); - Assertions.assertTrue(evaluationHitIds.contains(ruleId0)); - Assertions.assertTrue(evaluationHitIds.contains(ruleId3)); + Assertions.assertTrue(evaluationHitIds.containsKey(elseElementId)); + Assertions.assertTrue(evaluationHitIds.containsKey(ruleId0)); + Assertions.assertTrue(evaluationHitIds.containsKey(ruleId3)); context = new HashMap<>(); context.put("Credit Score", "Excellent"); @@ -118,9 +119,9 @@ void testEvaluationHitIds() throws IOException { evaluationHitIds = dmnResult.getEvaluationHitIds(); Assertions.assertNotNull(evaluationHitIds); Assertions.assertEquals(3, evaluationHitIds.size()); - Assertions.assertTrue(evaluationHitIds.contains(thenElementId)); - Assertions.assertTrue(evaluationHitIds.contains(ruleId1)); - Assertions.assertTrue(evaluationHitIds.contains(ruleId4)); + Assertions.assertTrue(evaluationHitIds.containsKey(thenElementId)); + Assertions.assertTrue(evaluationHitIds.containsKey(ruleId1)); + Assertions.assertTrue(evaluationHitIds.containsKey(ruleId4)); } @Test @@ -141,12 +142,12 @@ void testConditionalWithNestedDecisionTableFromRiskScoreEvaluation() throws IOEx Assertions.assertTrue(dmnResult.getMessages().isEmpty()); Assertions.assertEquals(BigDecimal.valueOf(50), dmnResult.getDecisionResultByName("Risk Score").getResult()); - List evaluationHitIds = dmnResult.getEvaluationHitIds(); + Map evaluationHitIds = dmnResult.getEvaluationHitIds(); Assertions.assertNotNull(evaluationHitIds); Assertions.assertEquals(3, evaluationHitIds.size()); - Assertions.assertTrue(evaluationHitIds.contains(thenElementId)); - Assertions.assertTrue(evaluationHitIds.contains(thenRuleId0)); - Assertions.assertTrue(evaluationHitIds.contains(thenRuleId4)); + Assertions.assertTrue(evaluationHitIds.containsKey(thenElementId)); + Assertions.assertTrue(evaluationHitIds.containsKey(thenRuleId0)); + Assertions.assertTrue(evaluationHitIds.containsKey(thenRuleId4)); context = new HashMap<>(); context.put("Credit Score", "Excellent"); @@ -159,9 +160,9 @@ void testConditionalWithNestedDecisionTableFromRiskScoreEvaluation() throws IOEx evaluationHitIds = dmnResult.getEvaluationHitIds(); Assertions.assertNotNull(evaluationHitIds); Assertions.assertEquals(3, evaluationHitIds.size()); - Assertions.assertTrue(evaluationHitIds.contains(elseElementId)); - Assertions.assertTrue(evaluationHitIds.contains(elseRuleId2)); - Assertions.assertTrue(evaluationHitIds.contains(elseRuleId5)); + Assertions.assertTrue(evaluationHitIds.containsKey(elseElementId)); + Assertions.assertTrue(evaluationHitIds.containsKey(elseRuleId2)); + Assertions.assertTrue(evaluationHitIds.containsKey(elseRuleId5)); } @Test @@ -185,12 +186,12 @@ void testMultipleHitRulesEvaluation() throws IOException { expectedStatistcs.add(BigDecimal.valueOf(1)); Assertions.assertTrue(dmnResult.getMessages().isEmpty()); Assertions.assertEquals(expectedStatistcs, dmnResult.getDecisionResultByName("Statistics").getResult()); - final List evaluationHitIds = dmnResult.getEvaluationHitIds(); + final Map evaluationHitIds = dmnResult.getEvaluationHitIds(); Assertions.assertNotNull(evaluationHitIds); - Assertions.assertEquals(6, evaluationHitIds.size()); - Assertions.assertEquals(3, evaluationHitIds.stream().filter(rule0::equals).count()); - Assertions.assertEquals(2, evaluationHitIds.stream().filter(rule1::equals).count()); - Assertions.assertEquals(1, evaluationHitIds.stream().filter(rule2::equals).count()); + Assertions.assertEquals(3, evaluationHitIds.size()); + Assertions.assertEquals(3, evaluationHitIds.get(rule0)); + Assertions.assertEquals(2, evaluationHitIds.get(rule1)); + Assertions.assertEquals(1, evaluationHitIds.get(rule2)); } @Test diff --git a/jitexecutor/jitexecutor-dmn/src/test/java/org/kie/kogito/jitexecutor/dmn/api/JITDMNResourceTest.java b/jitexecutor/jitexecutor-dmn/src/test/java/org/kie/kogito/jitexecutor/dmn/api/JITDMNResourceTest.java index 6c29603088..cacf238916 100644 --- a/jitexecutor/jitexecutor-dmn/src/test/java/org/kie/kogito/jitexecutor/dmn/api/JITDMNResourceTest.java +++ b/jitexecutor/jitexecutor-dmn/src/test/java/org/kie/kogito/jitexecutor/dmn/api/JITDMNResourceTest.java @@ -19,7 +19,10 @@ package org.kie.kogito.jitexecutor.dmn.api; import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.assertj.core.api.Assertions; @@ -31,7 +34,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import io.quarkus.test.junit.QuarkusTest; import io.restassured.http.ContentType; @@ -43,9 +46,9 @@ @QuarkusTest public class JITDMNResourceTest { - private static String model; + private static String invalidModel; private static String modelWithExtensionElements; - private static String modelWithEvaluationHitIds; + private static String modelWithMultipleEvaluationHitIds; private static final ObjectMapper MAPPER = new ObjectMapper(); @@ -57,14 +60,14 @@ public class JITDMNResourceTest { @BeforeAll public static void setup() throws IOException { - model = getModelFromIoUtils("invalid_models/DMNv1_x/test.dmn"); + invalidModel = getModelFromIoUtils("invalid_models/DMNv1_x/test.dmn"); modelWithExtensionElements = getModelFromIoUtils("valid_models/DMNv1_x/testWithExtensionElements.dmn"); - modelWithEvaluationHitIds = getModelFromIoUtils("valid_models/DMNv1_5/RiskScore_Simple.dmn"); + modelWithMultipleEvaluationHitIds = getModelFromIoUtils("valid_models/DMNv1_5/MultipleHitRules.dmn"); } @Test void testjitEndpoint() { - JITDMNPayload jitdmnpayload = new JITDMNPayload(model, buildContext()); + JITDMNPayload jitdmnpayload = new JITDMNPayload(invalidModel, buildContext()); given() .contentType(ContentType.JSON) .body(jitdmnpayload) @@ -76,46 +79,44 @@ void testjitEndpoint() { @Test void testjitdmnResultEndpoint() { - JITDMNPayload jitdmnpayload = new JITDMNPayload(model, buildContext()); + JITDMNPayload jitdmnpayload = new JITDMNPayload(modelWithMultipleEvaluationHitIds, buildMultipleHitContext()); given() .contentType(ContentType.JSON) .body(jitdmnpayload) .when().post("/jitdmn/dmnresult") .then() .statusCode(200) - .body(containsString("Loan Approval"), containsString("Approved"), containsString("xls2dmn")); + .body(containsString("Statistics")); } @Test void testjitdmnResultEndpointWithEvaluationHitIds() throws JsonProcessingException { - JITDMNPayload jitdmnpayload = new JITDMNPayload(modelWithEvaluationHitIds, buildRiskScoreContext()); - final String elseElementId = "_2CD02CB2-6B56-45C4-B461-405E89D45633"; - final String ruleId0 = "_1578BD9E-2BF9-4BFC-8956-1A736959C937"; - final String ruleId3 = "_2545E1A8-93D3-4C8A-A0ED-8AD8B10A58F9"; + JITDMNPayload jitdmnpayload = new JITDMNPayload(modelWithMultipleEvaluationHitIds, buildMultipleHitContext()); + final String rule0 = "_E5C380DA-AF7B-4401-9804-C58296EC09DD"; + final String rule1 = "_DFD65E8B-5648-4BFD-840F-8C76B8DDBD1A"; + final String rule2 = "_E80EE7F7-1C0C-4050-B560-F33611F16B05"; String response = given().contentType(ContentType.JSON) .body(jitdmnpayload) .when().post("/jitdmn/dmnresult") .then() .statusCode(200) - .body(containsString("Risk Score"), - containsString("Loan Pre-Qualification"), + .body(containsString("Statistics"), containsString(EVALUATION_HIT_IDS_FIELD_NAME), - containsString(elseElementId), - containsString(ruleId0), - containsString(ruleId3)) + containsString(rule0), + containsString(rule1), + containsString(rule2)) .extract() .asString(); JsonNode retrieved = MAPPER.readTree(response); - ArrayNode evaluationHitIdsNode = (ArrayNode) retrieved.get(EVALUATION_HIT_IDS_FIELD_NAME); - Assertions.assertThat(evaluationHitIdsNode).hasSize(3) - .anyMatch(node -> node.asText().equals(elseElementId)) - .anyMatch(node -> node.asText().equals(ruleId0)) - .anyMatch(node -> node.asText().equals(ruleId3)); + ObjectNode evaluationHitIdsNode = (ObjectNode) retrieved.get(EVALUATION_HIT_IDS_FIELD_NAME); + Assertions.assertThat(evaluationHitIdsNode).hasSize(3); + final Map expectedEvaluationHitIds = Map.of(rule0, 3, rule1, 2, rule2, 1); + evaluationHitIdsNode.fields().forEachRemaining(entry -> Assertions.assertThat(expectedEvaluationHitIds).containsEntry(entry.getKey(), entry.getValue().asInt())); } @Test void testjitExplainabilityEndpoint() { - JITDMNPayload jitdmnpayload = new JITDMNPayload(model, buildContext()); + JITDMNPayload jitdmnpayload = new JITDMNPayload(invalidModel, buildContext()); given() .contentType(ContentType.JSON) .body(jitdmnpayload) @@ -142,13 +143,6 @@ void testjitdmnWithExtensionElements() { .body(containsString("m"), containsString("n"), containsString("sum")); } - private Map buildRiskScoreContext() { - Map context = new HashMap<>(); - context.put("Credit Score", "Poor"); - context.put("DTI", 33); - return context; - } - private Map buildContext() { Map context = new HashMap<>(); context.put("FICO Score", 800); @@ -156,4 +150,14 @@ private Map buildContext() { context.put("PITI Ratio", .1); return context; } + + private Map buildMultipleHitContext() { + final List numbers = new ArrayList<>(); + numbers.add(BigDecimal.valueOf(10)); + numbers.add(BigDecimal.valueOf(2)); + numbers.add(BigDecimal.valueOf(1)); + final Map context = new HashMap<>(); + context.put("Numbers", numbers); + return context; + } } diff --git a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/BaseTimerJobScheduler.java b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/BaseTimerJobScheduler.java index ac080cdb82..49e777ba8c 100644 --- a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/BaseTimerJobScheduler.java +++ b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/BaseTimerJobScheduler.java @@ -343,7 +343,8 @@ private PublisherBuilder handleRetry(CompletionStage fut .build()) .map(jobRepository::save) .flatMapCompletionStage(p -> p)) - .peek(job -> LOGGER.debug("Retry executed {}", job)); + .peek(job -> LOGGER.debug("Retry executed {}", job)) + .onError(errorHandler -> LOGGER.error("Failed to retrieve job due to {}", errorHandler.getMessage())); } private PointInTimeTrigger getRetryTrigger() { diff --git a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java index b0bd05feac..2211c3aeef 100644 --- a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java +++ b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/JobSchedulerManager.java @@ -118,6 +118,9 @@ enum LoadJobErrorStrategy { } private void startJobsLoadingFromRepositoryTask() { + LOGGER.info( + "Starting with configuration: schedulerChunkInMinutes={}, loadJobIntervalInMinutes={}, loadJobFromCurrentTimeIntervalInMinutes={}, loadJobRetries={}, loadJobErrorStrategy={}", + schedulerChunkInMinutes, loadJobIntervalInMinutes, loadJobFromCurrentTimeIntervalInMinutes, loadJobRetries, loadJobErrorStrategy); //guarantee it starts the task just in case it is not already active initialLoading.set(true); if (periodicTimerIdForLoadJobs.get() < 0) { @@ -129,6 +132,13 @@ private void startJobsLoadingFromRepositoryTask() { schedulerChunkInMinutes); loadJobIntervalInMinutes = schedulerChunkInMinutes; } + if (loadJobFromCurrentTimeIntervalInMinutes < loadJobIntervalInMinutes) { + LOGGER.warn("The loadJobFromCurrentTimeIntervalInMinutes value ({}) is smaller than loadJobIntervalInMinutes ({}). " + + "This can potentially lead to overdue timers not getting rescheduled during the periodic job loading.", + loadJobFromCurrentTimeIntervalInMinutes, + loadJobIntervalInMinutes); + + } //first execution vertx.runOnContext(this::loadJobDetails); //next executions to run periodically @@ -198,6 +208,15 @@ private boolean isNotScheduled(JobDetails jobDetails) { Date triggerFireTime = jobDetails.getTrigger().hasNextFireTime(); ZonedDateTime nextFireTime = triggerFireTime != null ? DateUtil.instantToZonedDateTime(triggerFireTime.toInstant()) : null; boolean scheduled = scheduler.scheduled(jobDetails.getId()).isPresent(); + // cancel an overdue timer to have it rescheduled + if (!initialLoading.get() && nextFireTime != null && nextFireTime.isBefore(DateUtil.now())) { + LOGGER.debug("Job found, id: {}, nextFireTime: {}, created: {}, status: {} is overdue and will be rescheduled", jobDetails.getId(), + nextFireTime, + jobDetails.getCreated(), + jobDetails.getStatus()); + scheduler.cancel(jobDetails.getId()); + return true; + } LOGGER.debug("Job found, id: {}, nextFireTime: {}, created: {}, status: {}, already scheduled: {}", jobDetails.getId(), nextFireTime, jobDetails.getCreated(), diff --git a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/impl/TimerDelegateJobScheduler.java b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/impl/TimerDelegateJobScheduler.java index 6b30c30b0b..b64bd87b95 100644 --- a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/impl/TimerDelegateJobScheduler.java +++ b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/scheduler/impl/TimerDelegateJobScheduler.java @@ -62,6 +62,9 @@ public TimerDelegateJobScheduler(ReactiveJobRepository jobRepository, @ConfigProperty(name = "kogito.jobs-service.forceExecuteExpiredJobsOnServiceStart", defaultValue = "true") boolean forceExecuteExpiredJobsOnServiceStart, JobExecutorResolver jobExecutorResolver, VertxTimerServiceScheduler delegate) { super(jobRepository, backoffRetryMillis, maxIntervalLimitToRetryMillis, schedulerChunkInMinutes, forceExecuteExpiredJobs, forceExecuteExpiredJobsOnServiceStart); + LOGGER.info( + "Creating JobScheduler with backoffRetryMillis={}, maxIntervalLimitToRetryMillis={}, schedulerChunkInMinutes={}, forceExecuteExpiredJobs={}, forceExecuteExpiredJobsOnServiceStart={}", + backoffRetryMillis, maxIntervalLimitToRetryMillis, schedulerChunkInMinutes, forceExecuteExpiredJobs, forceExecuteExpiredJobsOnServiceStart); this.jobExecutorResolver = jobExecutorResolver; this.delegate = delegate; } diff --git a/jobs-service/jobs-service-storage-jpa/src/main/java/org/kie/kogito/jobs/service/repository/jpa/converter/JsonBinaryConverter.java b/jobs-service/jobs-service-storage-jpa/src/main/java/org/kie/kogito/jobs/service/repository/jpa/converter/JsonBinaryConverter.java index b269ab9eaf..924fae07fa 100644 --- a/jobs-service/jobs-service-storage-jpa/src/main/java/org/kie/kogito/jobs/service/repository/jpa/converter/JsonBinaryConverter.java +++ b/jobs-service/jobs-service-storage-jpa/src/main/java/org/kie/kogito/jobs/service/repository/jpa/converter/JsonBinaryConverter.java @@ -27,19 +27,19 @@ import jakarta.persistence.AttributeConverter; -public class JsonBinaryConverter implements AttributeConverter { +public class JsonBinaryConverter implements AttributeConverter { @Override - public byte[] convertToDatabaseColumn(ObjectNode attribute) { + public String convertToDatabaseColumn(ObjectNode attribute) { try { - return attribute == null ? null : ObjectMapperFactory.get().writeValueAsBytes(attribute); + return attribute == null ? null : ObjectMapperFactory.get().writeValueAsString(attribute); } catch (IOException e) { throw new UncheckedIOException(e); } } @Override - public ObjectNode convertToEntityAttribute(byte[] dbData) { + public ObjectNode convertToEntityAttribute(String dbData) { try { return dbData == null ? null : ObjectMapperFactory.get().readValue(dbData, ObjectNode.class); } catch (IOException e) { diff --git a/persistence-commons/persistence-commons-postgresql/src/main/resources/application.properties b/jobs-service/jobs-service-storage-jpa/src/main/resources/application.properties similarity index 100% rename from persistence-commons/persistence-commons-postgresql/src/main/resources/application.properties rename to jobs-service/jobs-service-storage-jpa/src/main/resources/application.properties diff --git a/jobs-service/jobs-service-storage-jpa/src/main/resources/kie-flyway/db/jobs-service/ansi/V2.0.0__Create_Tables.sql b/jobs-service/jobs-service-storage-jpa/src/main/resources/kie-flyway/db/jobs-service/ansi/V2.0.0__Create_Tables.sql index b48a32a95c..eaf988097c 100644 --- a/jobs-service/jobs-service-storage-jpa/src/main/resources/kie-flyway/db/jobs-service/ansi/V2.0.0__Create_Tables.sql +++ b/jobs-service/jobs-service-storage-jpa/src/main/resources/kie-flyway/db/jobs-service/ansi/V2.0.0__Create_Tables.sql @@ -27,8 +27,8 @@ create table job_details execution_counter integer, scheduled_id varchar(40), priority integer, - recipient varbinary(max), - trigger varbinary(max), + recipient varchar(max), + trigger varchar(max), fire_time timestamp, execution_timeout bigint, execution_timeout_unit varchar(40), diff --git a/jobs-service/kogito-addons-jobs-service/kogito-addons-quarkus-jobs/src/main/java/org/kie/kogito/jobs/embedded/EmbeddedJobExecutor.java b/jobs-service/kogito-addons-jobs-service/kogito-addons-quarkus-jobs/src/main/java/org/kie/kogito/jobs/embedded/EmbeddedJobExecutor.java index 347eedcb69..ead3bbf2a2 100644 --- a/jobs-service/kogito-addons-jobs-service/kogito-addons-quarkus-jobs/src/main/java/org/kie/kogito/jobs/embedded/EmbeddedJobExecutor.java +++ b/jobs-service/kogito-addons-jobs-service/kogito-addons-quarkus-jobs/src/main/java/org/kie/kogito/jobs/embedded/EmbeddedJobExecutor.java @@ -56,7 +56,15 @@ public Uni execute(JobDetails jobDetails) { InVMRecipient recipient = (InVMRecipient) recipientModel.getRecipient(); String timerId = recipient.getPayload().getData().timerId(); String processInstanceId = recipient.getPayload().getData().processInstanceId(); - Optional> process = processes.processByProcessInstanceId(processInstanceId); + Optional> process; + try { + process = processes.processByProcessInstanceId(processInstanceId); + } catch (Exception ex) { + return Uni.createFrom().failure( + new JobExecutionException(jobDetails.getId(), + "Unexpected error when executing Embedded request for job: " + jobDetails.getId() + ". " + ex.getMessage(), + ex)); + } if (process.isEmpty()) { return Uni.createFrom().item( JobExecutionResponse.builder() diff --git a/kogito-apps-build-parent/pom.xml b/kogito-apps-build-parent/pom.xml index c5093d2eb0..72c89cabf6 100644 --- a/kogito-apps-build-parent/pom.xml +++ b/kogito-apps-build-parent/pom.xml @@ -66,6 +66,7 @@ 2.3.2 1.10.0 2.2.0 + 20231013 1.5.5.Final 1.5.1 22.0 @@ -158,6 +159,17 @@ com.redislabs jredisearch ${version.org.jredisearch} + + + org.json + json + + + + + org.json + json + ${version.org.json} org.apache.commons @@ -190,6 +202,11 @@ hibernate-ant ${version.org.hibernate} + + com.graphql-java + graphql-java + ${version.com.graphql-java-extended-scalars} + com.graphql-java graphql-java-extended-scalars diff --git a/mvnw b/mvnw deleted file mode 100755 index 41c0f0c23d..0000000000 --- a/mvnw +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd deleted file mode 100644 index 86115719e5..0000000000 --- a/mvnw.cmd +++ /dev/null @@ -1,182 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/.mvn/wrapper/maven-wrapper.properties b/persistence-commons/persistence-commons-jpa-base/src/main/resources/application.properties similarity index 72% rename from .mvn/wrapper/maven-wrapper.properties rename to persistence-commons/persistence-commons-jpa-base/src/main/resources/application.properties index dc3affce3d..c4820ddf59 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/persistence-commons/persistence-commons-jpa-base/src/main/resources/application.properties @@ -1,3 +1,4 @@ +# # 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 @@ -6,7 +7,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# https://www.apache.org/licenses/LICENSE-2.0 +# 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 @@ -14,5 +15,6 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar +# + +quarkus.datasource.jdbc.additional-jdbc-properties.stringtype=unspecified diff --git a/persistence-commons/persistence-commons-jpa/src/main/resources/META-INF/kie-flyway.properties b/persistence-commons/persistence-commons-jpa/src/main/resources/META-INF/kie-flyway.properties new file mode 100644 index 0000000000..cf9d0ea888 --- /dev/null +++ b/persistence-commons/persistence-commons-jpa/src/main/resources/META-INF/kie-flyway.properties @@ -0,0 +1,23 @@ +# +# 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. +# + +module.name=persistence-commons + +module.locations.postgresql=classpath:kie-flyway/db/persistence-commons/postgresql +module.locations.default=classpath:kie-flyway/db/persistence-commons/ansi \ No newline at end of file diff --git a/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.0__kogito_apps_create_kogito_data_cache.sql b/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.0__kogito_apps_create_kogito_data_cache.sql index 3b6a41389d..bf660066aa 100644 --- a/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.0__kogito_apps_create_kogito_data_cache.sql +++ b/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.0__kogito_apps_create_kogito_data_cache.sql @@ -20,6 +20,6 @@ create table if not exists kogito_data_cache ( key varchar(255) not null, name varchar(255) not null, - json_value varbinary(max), + json_value varchar(max), primary key (key, name) ); \ No newline at end of file diff --git a/persistence-commons/persistence-commons-postgresql/src/main/resources/META-INF/kie-flyway.properties b/persistence-commons/persistence-commons-postgresql/src/main/resources/META-INF/kie-flyway.properties new file mode 100644 index 0000000000..4faa9f9836 --- /dev/null +++ b/persistence-commons/persistence-commons-postgresql/src/main/resources/META-INF/kie-flyway.properties @@ -0,0 +1,22 @@ +# +# 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. +# + +module.name=persistence-commons + +module.locations.postgresql=classpath:kie-flyway/db/persistence-commons/postgresql \ No newline at end of file diff --git a/persistence-commons/persistence-commons-redis/pom.xml b/persistence-commons/persistence-commons-redis/pom.xml index 5b0c0d6832..1a524df1d7 100644 --- a/persistence-commons/persistence-commons-redis/pom.xml +++ b/persistence-commons/persistence-commons-redis/pom.xml @@ -44,6 +44,16 @@ com.redislabs jredisearch + + + org.json + json + + + + + org.json + json io.quarkus