Search in sources :

Example 1 with ProcessInstanceState

use of org.kie.kogito.index.model.ProcessInstanceState in project kogito-apps by kiegroup.

the class GraphQLSchemaManager method createSchema.

private GraphQLSchema createSchema() {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("schema.graphqls");
    SchemaParser schemaParser = new SchemaParser();
    TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(new InputStreamReader(stream));
    RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring().type("Query", builder -> {
        builder.dataFetcher("ProcessInstances", this::getProcessInstancesValues);
        builder.dataFetcher("UserTaskInstances", this::getUserTaskInstancesValues);
        builder.dataFetcher("Jobs", this::getJobsValues);
        return builder;
    }).type("Mutation", builder -> {
        builder.dataFetcher("ProcessInstanceAbort", this::abortProcessInstance);
        builder.dataFetcher("ProcessInstanceRetry", this::retryProcessInstance);
        builder.dataFetcher("ProcessInstanceSkip", this::skipProcessInstance);
        builder.dataFetcher("ProcessInstanceUpdateVariables", this::updateProcessInstanceVariables);
        builder.dataFetcher("NodeInstanceTrigger", this::triggerNodeInstance);
        builder.dataFetcher("NodeInstanceRetrigger", this::retriggerNodeInstance);
        builder.dataFetcher("NodeInstanceCancel", this::cancelNodeInstance);
        builder.dataFetcher("JobCancel", this::cancelJob);
        builder.dataFetcher("JobReschedule", this::rescheduleJob);
        builder.dataFetcher("UserTaskInstanceUpdate", this::updateUserTaskInstance);
        builder.dataFetcher("UserTaskInstanceCommentCreate", this::createTaskInstanceComment);
        builder.dataFetcher("UserTaskInstanceAttachmentCreate", this::createTaskInstanceAttachment);
        builder.dataFetcher("UserTaskInstanceCommentUpdate", this::updateUserTaskComment);
        builder.dataFetcher("UserTaskInstanceCommentDelete", this::deleteUserTaskComment);
        builder.dataFetcher("UserTaskInstanceAttachmentUpdate", this::updateUserTaskAttachment);
        builder.dataFetcher("UserTaskInstanceAttachmentDelete", this::deleteUserTaskAttachment);
        return builder;
    }).type("ProcessInstance", builder -> {
        builder.dataFetcher("parentProcessInstance", this::getParentProcessInstanceValue);
        builder.dataFetcher("childProcessInstances", this::getChildProcessInstancesValues);
        builder.dataFetcher("serviceUrl", this::getProcessInstanceServiceUrl);
        builder.dataFetcher("diagram", this::getProcessInstanceDiagram);
        builder.dataFetcher("nodeDefinitions", this::getProcessNodes);
        return builder;
    }).type("UserTaskInstance", builder -> {
        builder.dataFetcher("schema", this::getUserTaskInstanceSchema);
        return builder;
    }).type("ProcessInstanceMeta", builder -> {
        builder.dataFetcher("serviceUrl", this::getProcessInstanceJsonServiceUrl);
        return builder;
    }).type("ProcessInstanceState", builder -> {
        builder.enumValues(name -> ProcessInstanceState.valueOf(name).ordinal());
        return builder;
    }).type("Subscription", builder -> {
        builder.dataFetcher(PROCESS_INSTANCE_ADDED, getProcessInstanceAddedDataFetcher());
        builder.dataFetcher(PROCESS_INSTANCE_UPDATED, getProcessInstanceUpdatedDataFetcher());
        builder.dataFetcher(USER_TASK_INSTANCE_ADDED, getUserTaskInstanceAddedDataFetcher());
        builder.dataFetcher(USER_TASK_INSTANCE_UPDATED, getUserTaskInstanceUpdatedDataFetcher());
        builder.dataFetcher(JOB_ADDED, getJobAddedDataFetcher());
        builder.dataFetcher(JOB_UPDATED, getJobUpdatedDataFetcher());
        return builder;
    }).scalar(qlDateTimeScalarType).build();
    SchemaGenerator schemaGenerator = new SchemaGenerator();
    return schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
}
Also used : DataIndexStorageService(org.kie.kogito.index.DataIndexStorageService) DataFetchingEnvironment(graphql.schema.DataFetchingEnvironment) GraphQLNamedType(graphql.schema.GraphQLNamedType) ProcessInstanceState(org.kie.kogito.index.model.ProcessInstanceState) GraphQLInputObjectType(graphql.schema.GraphQLInputObjectType) ProcessInstance(org.kie.kogito.index.model.ProcessInstance) GraphQLScalarType(graphql.schema.GraphQLScalarType) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) Query(org.kie.kogito.persistence.api.query.Query) JsonUtils.getObjectMapper(org.kie.kogito.index.json.JsonUtils.getObjectMapper) Supplier(java.util.function.Supplier) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Collections.singletonList(java.util.Collections.singletonList) Inject(javax.inject.Inject) SchemaParser(graphql.schema.idl.SchemaParser) Map(java.util.Map) DataIndexParsingException(org.kie.kogito.index.json.DataIndexParsingException) DataFetcher(graphql.schema.DataFetcher) GraphQLSchema(graphql.schema.GraphQLSchema) GraphQLQueryParserRegistry(org.kie.kogito.index.graphql.query.GraphQLQueryParserRegistry) Storage(org.kie.kogito.persistence.api.Storage) JsonNode(com.fasterxml.jackson.databind.JsonNode) KogitoRuntimeClient(org.kie.kogito.index.api.KogitoRuntimeClient) DataIndexServiceException(org.kie.kogito.index.service.DataIndexServiceException) Logger(org.slf4j.Logger) Job(org.kie.kogito.index.model.Job) Collection(java.util.Collection) Publisher(org.reactivestreams.Publisher) QueryFilterFactory.equalTo(org.kie.kogito.persistence.api.query.QueryFilterFactory.equalTo) TypeDefinitionRegistry(graphql.schema.idl.TypeDefinitionRegistry) IOException(java.io.IOException) UserTaskInstance(org.kie.kogito.index.model.UserTaskInstance) InputStreamReader(java.io.InputStreamReader) String.format(java.lang.String.format) Objects(java.util.Objects) Consumer(java.util.function.Consumer) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) RuntimeWiring(graphql.schema.idl.RuntimeWiring) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) GraphQLQueryOrderByParser(org.kie.kogito.index.graphql.query.GraphQLQueryOrderByParser) SchemaGenerator(graphql.schema.idl.SchemaGenerator) Node(org.kie.kogito.index.model.Node) InputStream(java.io.InputStream) InputStreamReader(java.io.InputStreamReader) RuntimeWiring(graphql.schema.idl.RuntimeWiring) InputStream(java.io.InputStream) TypeDefinitionRegistry(graphql.schema.idl.TypeDefinitionRegistry) SchemaGenerator(graphql.schema.idl.SchemaGenerator) SchemaParser(graphql.schema.idl.SchemaParser)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 DataFetcher (graphql.schema.DataFetcher)1 DataFetchingEnvironment (graphql.schema.DataFetchingEnvironment)1 GraphQLInputObjectType (graphql.schema.GraphQLInputObjectType)1 GraphQLNamedType (graphql.schema.GraphQLNamedType)1 GraphQLScalarType (graphql.schema.GraphQLScalarType)1 GraphQLSchema (graphql.schema.GraphQLSchema)1 RuntimeWiring (graphql.schema.idl.RuntimeWiring)1 SchemaGenerator (graphql.schema.idl.SchemaGenerator)1 SchemaParser (graphql.schema.idl.SchemaParser)1 TypeDefinitionRegistry (graphql.schema.idl.TypeDefinitionRegistry)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 String.format (java.lang.String.format)1 Collection (java.util.Collection)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Map (java.util.Map)1