-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
212 additions
and
2 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
data-index/data-index-common/src/main/java/org/kie/kogito/index/api/ExecuteArgs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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.api; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
public record ExecuteArgs(JsonNode input, String businessKey, String referenceId) { | ||
|
||
public static ExecuteArgs of(JsonNode input) { | ||
return new Builder().withInput(input).build(); | ||
} | ||
|
||
public static Builder builder(JsonNode modelInput) { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
|
||
private JsonNode input; | ||
private String businessKey; | ||
private String referenceId; | ||
|
||
private Builder() { | ||
} | ||
|
||
public Builder withInput(JsonNode input) { | ||
this.input = input; | ||
return this; | ||
} | ||
|
||
public Builder withBusinessKey(String businessKey) { | ||
this.businessKey = businessKey; | ||
return this; | ||
} | ||
|
||
public Builder withReferenceId(String referenceId) { | ||
this.referenceId = referenceId; | ||
return this; | ||
} | ||
|
||
public ExecuteArgs build() { | ||
return new ExecuteArgs(input, businessKey, referenceId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...e-common/src/main/java/org/kie/kogito/index/service/graphql/GraphQLMutationsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.service.graphql; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.kie.kogito.index.graphql.AbstractGraphQLSchemaManager; | ||
|
||
import graphql.schema.DataFetcher; | ||
|
||
public interface GraphQLMutationsProvider { | ||
Map<String, DataFetcher<CompletableFuture<?>>> mutations(AbstractGraphQLSchemaManager schemaManager); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
data-index/data-index-service/data-index-service-shared-output/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.kie.kogito</groupId> | ||
<artifactId>data-index-service</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>data-index-service-shared-output</artifactId> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.kie.kogito</groupId> | ||
<artifactId>data-index-service-common</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<properties> | ||
<java.module.name>org.kie.kogito.index.service.mutations</java.module.name> | ||
</properties> | ||
</project> |
62 changes: 62 additions & 0 deletions
62
...t/src/main/java/org/kie/kogito/index/service/mutations/OutputGraphQLMutationProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* 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.service.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.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 com.fasterxml.jackson.databind.JsonNode; | ||
|
||
import graphql.schema.DataFetcher; | ||
import graphql.schema.DataFetchingEnvironment; | ||
|
||
public class OutputGraphQLMutationProvider implements GraphQLMutationsProvider { | ||
|
||
@Override | ||
public Map<String, DataFetcher<CompletableFuture<?>>> mutations(AbstractGraphQLSchemaManager schemaManager) { | ||
return Map.of("sharedOutput", env -> sharedOutput(schemaManager, env)); | ||
} | ||
|
||
private CompletableFuture<String> sharedOutput(AbstractGraphQLSchemaManager schemaManager, DataFetchingEnvironment env) { | ||
String assesmentId = env.getArgument("assesmentInstanceId"); | ||
String processId = env.getArgument("processId"); | ||
String processVersion = env.getArgument("processVersion"); | ||
DataIndexStorageService cacheService = schemaManager.getCacheService(); | ||
ProcessInstance processInstance = cacheService.getProcessInstanceStorage().get(assesmentId); | ||
JsonNode input = env.getArgument("input"); | ||
if (processInstance != null) { | ||
input = MergeUtils.merge(input, processInstance.getVariables()); | ||
} | ||
ProcessDefinition processDefinition = cacheService.getProcessDefinitionStorage().get(new ProcessDefinitionKey(processId, processVersion)); | ||
if (processDefinition != null) { | ||
return schemaManager.getDataIndexApiExecutor().executeProcessIntance(schemaManager.getServiceUrl(processDefinition.getEndpoint(), | ||
processDefinition.getId()), processDefinition, ExecuteArgs.of(input)); | ||
} | ||
return new CompletableFuture<>(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...resources/META-INF/services/org.kie.kogito.index.service.graphql.GraphQLMutationsProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.kie.kogito.index.service.mutations.OutputGraphQLMutationProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters