diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/api/ExecuteArgs.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/api/ExecuteArgs.java
index 6049104c2b..1e8c3a3656 100644
--- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/api/ExecuteArgs.java
+++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/api/ExecuteArgs.java
@@ -23,10 +23,10 @@
public record ExecuteArgs(JsonNode input, String businessKey, String referenceId) {
public static ExecuteArgs of(JsonNode input) {
- return new Builder().withInput(input).build();
+ return builder().withInput(input).build();
}
- public static Builder builder(JsonNode modelInput) {
+ public static Builder builder() {
return new Builder();
}
diff --git a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/AbstractGraphQLSchemaManager.java b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/AbstractGraphQLSchemaManager.java
index 960496d4da..f1cb5604d4 100644
--- a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/AbstractGraphQLSchemaManager.java
+++ b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/AbstractGraphQLSchemaManager.java
@@ -25,8 +25,11 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.ServiceLoader;
+import java.util.ServiceLoader.Provider;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
+import java.util.stream.Collectors;
import org.kie.kogito.index.CommonUtils;
import org.kie.kogito.index.api.KogitoRuntimeClient;
@@ -42,8 +45,6 @@
import org.kie.kogito.index.storage.DataIndexStorageService;
import org.kie.kogito.persistence.api.StorageFetcher;
import org.kie.kogito.persistence.api.query.Query;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.GraphQLInputObjectType;
@@ -52,6 +53,7 @@
import graphql.schema.GraphQLSchema;
import graphql.schema.idl.SchemaParser;
import graphql.schema.idl.TypeDefinitionRegistry;
+import graphql.schema.idl.TypeRuntimeWiring.Builder;
import jakarta.annotation.PostConstruct;
import jakarta.inject.Inject;
@@ -70,8 +72,6 @@ public abstract class AbstractGraphQLSchemaManager implements GraphQLSchemaManag
private static final String UNABLE_TO_FIND_ERROR_MSG = "Unable to find the instance with %s %s";
- private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGraphQLSchemaManager.class);
-
@Inject
DataIndexStorageService cacheService;
@@ -93,6 +93,11 @@ public void setup() {
(GraphQLInputObjectType) schema.getType("JobArgument"));
}
+ protected final void loadAdditionalMutations(Builder builder) {
+ ServiceLoader.load(GraphQLMutationsProvider.class).stream().map(Provider::get).map(m -> m.mutations(this)).flatMap(map -> map.entrySet().stream())
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (v1, v2) -> v2)).forEach(builder::dataFetcher);
+ }
+
protected TypeDefinitionRegistry loadSchemaDefinitionFile(String fileName) {
SchemaParser schemaParser = new SchemaParser();
try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
diff --git a/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/graphql/GraphQLMutationsProvider.java b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLMutationsProvider.java
similarity index 90%
rename from data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/graphql/GraphQLMutationsProvider.java
rename to data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLMutationsProvider.java
index cda1b2ce7f..c4b30c186d 100644
--- a/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/graphql/GraphQLMutationsProvider.java
+++ b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLMutationsProvider.java
@@ -16,13 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.kie.kogito.index.service.graphql;
+package org.kie.kogito.index.graphql;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
-import org.kie.kogito.index.graphql.AbstractGraphQLSchemaManager;
-
import graphql.schema.DataFetcher;
public interface GraphQLMutationsProvider {
diff --git a/data-index/data-index-service/data-index-service-shared-output/pom.xml b/data-index/data-index-mutations/data-index-shared-output-mutation/pom.xml
similarity index 89%
rename from data-index/data-index-service/data-index-service-shared-output/pom.xml
rename to data-index/data-index-mutations/data-index-shared-output-mutation/pom.xml
index a97483374a..9f73334975 100644
--- a/data-index/data-index-service/data-index-service-shared-output/pom.xml
+++ b/data-index/data-index-mutations/data-index-shared-output-mutation/pom.xml
@@ -22,14 +22,14 @@
4.0.0
org.kie.kogito
- data-index-service
+ data-index-mutations
999-SNAPSHOT
- data-index-service-shared-output
+ data-index-shared-output-mutation
org.kie.kogito
- data-index-service-common
+ data-index-graphql
diff --git a/data-index/data-index-service/data-index-service-shared-output/src/main/java/org/kie/kogito/index/service/mutations/OutputGraphQLMutationProvider.java b/data-index/data-index-mutations/data-index-shared-output-mutation/src/main/java/org/kie/kogito/index/mutations/OutputGraphQLMutationProvider.java
similarity index 95%
rename from data-index/data-index-service/data-index-service-shared-output/src/main/java/org/kie/kogito/index/service/mutations/OutputGraphQLMutationProvider.java
rename to data-index/data-index-mutations/data-index-shared-output-mutation/src/main/java/org/kie/kogito/index/mutations/OutputGraphQLMutationProvider.java
index b865775cba..43289c96d5 100644
--- a/data-index/data-index-service/data-index-service-shared-output/src/main/java/org/kie/kogito/index/service/mutations/OutputGraphQLMutationProvider.java
+++ b/data-index/data-index-mutations/data-index-shared-output-mutation/src/main/java/org/kie/kogito/index/mutations/OutputGraphQLMutationProvider.java
@@ -16,17 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.kie.kogito.index.service.mutations;
+package org.kie.kogito.index.mutations;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import org.kie.kogito.index.api.ExecuteArgs;
import org.kie.kogito.index.graphql.AbstractGraphQLSchemaManager;
+import org.kie.kogito.index.graphql.GraphQLMutationsProvider;
import org.kie.kogito.index.model.ProcessDefinition;
import org.kie.kogito.index.model.ProcessDefinitionKey;
import org.kie.kogito.index.model.ProcessInstance;
-import org.kie.kogito.index.service.graphql.GraphQLMutationsProvider;
import org.kie.kogito.index.storage.DataIndexStorageService;
import org.kie.kogito.jackson.utils.MergeUtils;
import org.slf4j.Logger;
@@ -44,7 +44,7 @@ public class OutputGraphQLMutationProvider implements GraphQLMutationsProvider {
@Override
public Map>> mutations(AbstractGraphQLSchemaManager schemaManager) {
- return Map.of("sharedOutput", env -> sharedOutput(schemaManager, env));
+ return Map.of("ExecuteAfter", env -> sharedOutput(schemaManager, env));
}
private CompletableFuture sharedOutput(AbstractGraphQLSchemaManager schemaManager, DataFetchingEnvironment env) {
diff --git a/data-index/data-index-mutations/data-index-shared-output-mutation/src/main/resources/META-INF/services/org.kie.kogito.index.graphql.GraphQLMutationsProvider b/data-index/data-index-mutations/data-index-shared-output-mutation/src/main/resources/META-INF/services/org.kie.kogito.index.graphql.GraphQLMutationsProvider
new file mode 100644
index 0000000000..96f1728b24
--- /dev/null
+++ b/data-index/data-index-mutations/data-index-shared-output-mutation/src/main/resources/META-INF/services/org.kie.kogito.index.graphql.GraphQLMutationsProvider
@@ -0,0 +1 @@
+org.kie.kogito.index.mutations.OutputGraphQLMutationProvider
\ No newline at end of file
diff --git a/data-index/data-index-mutations/pom.xml b/data-index/data-index-mutations/pom.xml
new file mode 100644
index 0000000000..4e7eed80c1
--- /dev/null
+++ b/data-index/data-index-mutations/pom.xml
@@ -0,0 +1,33 @@
+
+
+ 4.0.0
+
+ org.kie.kogito
+ data-index
+ 999-SNAPSHOT
+
+ data-index-mutations
+ pom
+
+ data-index-shared-output-mutation
+
+
\ No newline at end of file
diff --git a/data-index/data-index-service/data-index-service-common/pom.xml b/data-index/data-index-service/data-index-service-common/pom.xml
index 4abb945f17..7b8d09c534 100644
--- a/data-index/data-index-service/data-index-service-common/pom.xml
+++ b/data-index/data-index-service/data-index-service-common/pom.xml
@@ -91,6 +91,10 @@
io.quarkus
quarkus-rest-client-reactive-jackson
+
+ org.kie.kogito
+ data-index-shared-output-mutation
+
io.quarkus
quarkus-smallrye-graphql-client
diff --git a/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/graphql/GraphQLSchemaManagerImpl.java b/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/graphql/GraphQLSchemaManagerImpl.java
index 7d7de3de9b..3320ede2e6 100644
--- a/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/graphql/GraphQLSchemaManagerImpl.java
+++ b/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/graphql/GraphQLSchemaManagerImpl.java
@@ -21,12 +21,8 @@
import java.io.IOException;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
-import java.util.ServiceLoader;
-import java.util.ServiceLoader.Provider;
import java.util.function.Supplier;
-import java.util.stream.Collectors;
import org.kie.kogito.index.graphql.AbstractGraphQLSchemaManager;
import org.kie.kogito.index.graphql.query.GraphQLQueryParserRegistry;
@@ -105,8 +101,7 @@ public GraphQLSchema createSchema() {
builder.dataFetcher("UserTaskInstanceCommentDelete", this::deleteUserTaskComment);
builder.dataFetcher("UserTaskInstanceAttachmentUpdate", this::updateUserTaskAttachment);
builder.dataFetcher("UserTaskInstanceAttachmentDelete", this::deleteUserTaskAttachment);
- ServiceLoader.load(GraphQLMutationsProvider.class).stream().map(Provider::get).map(m -> m.mutations(this)).flatMap(map -> map.entrySet().stream())
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (v1, v2) -> v2)).forEach(builder::dataFetcher);
+ loadAdditionalMutations(builder);
return builder;
})
.type("ProcessDefinition", builder -> {
diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/AbstractGraphQLRuntimesQueriesIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/AbstractGraphQLRuntimesQueriesIT.java
index 04df4542e4..eed2b8cd8a 100644
--- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/AbstractGraphQLRuntimesQueriesIT.java
+++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/AbstractGraphQLRuntimesQueriesIT.java
@@ -27,17 +27,24 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.kie.kogito.event.process.ProcessDefinitionDataEvent;
import org.kie.kogito.event.process.ProcessInstanceStateDataEvent;
+import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent;
+import org.kie.kogito.event.process.ProcessInstanceVariableEventBody;
import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentDataEvent;
import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentEventBody;
import org.kie.kogito.event.usertask.UserTaskInstanceCommentDataEvent;
import org.kie.kogito.event.usertask.UserTaskInstanceCommentEventBody;
import org.kie.kogito.event.usertask.UserTaskInstanceStateDataEvent;
+import org.kie.kogito.index.api.ExecuteArgs;
import org.kie.kogito.index.api.KogitoRuntimeClient;
import org.kie.kogito.index.event.KogitoJobCloudEvent;
+import org.kie.kogito.index.model.ProcessDefinition;
import org.kie.kogito.index.model.UserTaskInstance;
import org.kie.kogito.index.service.AbstractIndexingIT;
import org.kie.kogito.index.service.graphql.GraphQLSchemaManagerImpl;
+import org.kie.kogito.index.test.TestUtils;
+import org.kie.kogito.jackson.utils.ObjectMapperFactory;
import org.kie.kogito.persistence.protobuf.ProtobufService;
import org.mockito.ArgumentCaptor;
import org.mockito.junit.jupiter.MockitoExtension;
@@ -96,6 +103,41 @@ void testProcessInstanceAbort() {
eq(getProcessInstance(processId, processInstanceId, 1, null, null)));
}
+ @Test
+ void testProcessExecuteInstance() {
+ String assesmentInstanceId = UUID.randomUUID().toString();
+ ProcessInstanceStateDataEvent assesmentEvent = getProcessCloudEvent(processId, assesmentInstanceId, ACTIVE, null, null, null, "currentUser");
+ indexProcessCloudEvent(assesmentEvent);
+ final String assesmentVarName = "assesmentVar";
+ final String assesmentVarValue = "assesmentValue";
+ final String infraVarName = "clientVar";
+ final String infraVarValue = "clientValue";
+ ProcessInstanceVariableDataEvent variableEvent = new ProcessInstanceVariableDataEvent();
+ variableEvent.setKogitoProcessId(processId);
+ variableEvent.setKogitoProcessInstanceId(assesmentInstanceId);
+ variableEvent.setData(ProcessInstanceVariableEventBody.create().processId(processId).processInstanceId(assesmentInstanceId)
+ .variableName(assesmentVarName).variableValue(assesmentVarValue).build());
+ indexProcessCloudEvent(variableEvent);
+ final String infraProcessId = "infra";
+ ProcessDefinitionDataEvent definitionEvent = TestUtils.getProcessDefinitionDataEvent(infraProcessId);
+ indexProcessCloudEvent(definitionEvent);
+ checkOkResponse("{ \"query\" : \"mutation{ ExecuteAfter ( " + fragment("completedProcessId", assesmentInstanceId) + "," + fragment("processId", infraProcessId) +
+ "," + fragment("processVersion", TestUtils.PROCESS_VERSION) + "," + "input: {" + fragment(assesmentVarName, assesmentVarValue) + "})}\"}");
+ verify(dataIndexApiClient).executeProcessIntance(getProcessDefinition(infraProcessId), ExecuteArgs.of(ObjectMapperFactory.get().createObjectNode().put(assesmentVarName, assesmentVarValue)
+ .put(infraVarName,infraVarValue)));
+ }
+
+ private String fragment(String name, String value) {
+ return name + ": \\\"" + value + "\\\"";
+ }
+
+ private ProcessDefinition getProcessDefinition(String processId) {
+ ProcessDefinition def = new ProcessDefinition();
+ def.setId(processId);
+ def.setVersion(TestUtils.PROCESS_VERSION);
+ return def;
+ }
+
@Test
void testProcessInstanceRetry() {
String processInstanceId = UUID.randomUUID().toString();
diff --git a/data-index/data-index-service/data-index-service-shared-output/src/main/resources/META-INF/services/org.kie.kogito.index.service.graphql.GraphQLMutationsProvider b/data-index/data-index-service/data-index-service-shared-output/src/main/resources/META-INF/services/org.kie.kogito.index.service.graphql.GraphQLMutationsProvider
deleted file mode 100644
index a06562efb8..0000000000
--- a/data-index/data-index-service/data-index-service-shared-output/src/main/resources/META-INF/services/org.kie.kogito.index.service.graphql.GraphQLMutationsProvider
+++ /dev/null
@@ -1,19 +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.
-#
-org.kie.kogito.index.service.mutations.OutputGraphQLMutationProvider
\ No newline at end of file
diff --git a/data-index/data-index-service/pom.xml b/data-index/data-index-service/pom.xml
index 236e069267..cdc2c04d47 100644
--- a/data-index/data-index-service/pom.xml
+++ b/data-index/data-index-service/pom.xml
@@ -37,7 +37,6 @@
data-index-service-postgresql
data-index-service-infinispan
data-index-service-mongodb
- data-index-service-shared-output
diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/api/KogitoAddonRuntimeClientImpl.java b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/api/KogitoAddonRuntimeClientImpl.java
index 22a394f18b..f681f39d18 100644
--- a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/api/KogitoAddonRuntimeClientImpl.java
+++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/api/KogitoAddonRuntimeClientImpl.java
@@ -289,6 +289,6 @@ public CompletableFuture executeProcessIntance(ProcessDefinition definit
org.kie.kogito.process.ProcessInstance extends Model> pi = process.createInstance(m);
pi.start();
return CompletableFuture.completedFuture(
- String.format(SUCCESSFULLY_OPERATION_MESSAGE, "Started ProcessInstance with id: " + pi.id()));
+ String.format(SUCCESSFULLY_OPERATION_MESSAGE, "Started Process Instance with id: " + pi.id()));
}
}
diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/main/java/org/kie/kogito/index/addon/graphql/GraphQLAddonSchemaManagerImpl.java b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/main/java/org/kie/kogito/index/addon/graphql/GraphQLAddonSchemaManagerImpl.java
index d9c853bbd8..4f44a1b5ec 100644
--- a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/main/java/org/kie/kogito/index/addon/graphql/GraphQLAddonSchemaManagerImpl.java
+++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/main/java/org/kie/kogito/index/addon/graphql/GraphQLAddonSchemaManagerImpl.java
@@ -53,6 +53,7 @@ public GraphQLSchema createSchema() {
builder.dataFetcher("NodeInstanceCancel", this::cancelNodeInstance);
builder.dataFetcher("JobCancel", this::cancelJob);
builder.dataFetcher("JobReschedule", this::rescheduleJob);
+ loadAdditionalMutations(builder);
return builder;
})
.type("ProcessDefinition", builder -> {
diff --git a/data-index/pom.xml b/data-index/pom.xml
index 4b2801bbd9..0de3d898b3 100644
--- a/data-index/pom.xml
+++ b/data-index/pom.xml
@@ -42,6 +42,7 @@
data-index-service
kogito-addons-quarkus-data-index-persistence
kogito-addons-quarkus-data-index
+ data-index-mutations
diff --git a/kogito-apps-bom/pom.xml b/kogito-apps-bom/pom.xml
index 37e90676fa..e28ce31371 100644
--- a/kogito-apps-bom/pom.xml
+++ b/kogito-apps-bom/pom.xml
@@ -252,7 +252,7 @@
org.kie.kogito
- data-index-service-shared-output
+ data-index-shared-output-mutation
${project.version}