This is an automated email from the ASF dual-hosted git repository.

tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 9fc9d1c5f5c kie-issues#1033: Fix sonataflow-quarkus-devui-extension to 
adapt it to the Quarkus 3.8 Dev UI (#2212)
9fc9d1c5f5c is described below

commit 9fc9d1c5f5cef4dc007c27950dbf2750702f92c9
Author: Paulo Martins <[email protected]>
AuthorDate: Wed Mar 27 16:43:55 2024 -0300

    kie-issues#1033: Fix sonataflow-quarkus-devui-extension to adapt it to the 
Quarkus 3.8 Dev UI (#2212)
---
 .../swf/tools/deployment/DevConsoleProcessor.java  | 106 ++++++++++++++-------
 .../src/main/resources/dev-templates/embedded.html |  53 -----------
 .../main/resources/dev-templates/monitoring.html   |  44 ---------
 .../resources/dev-templates/workflowInstances.html |  45 ---------
 .../dev-ui/qwc-sonataflow-quarkus-devui.js         |  65 +++++++++++++
 .../src/main/resources/static/index.html           |  45 ---------
 .../config/DevUIStaticArtifactsRecorder.java       |  44 +++++++++
 .../tools/runtime/dataindex/DataIndexClient.java   |  41 ++++++++
 .../dataindex/workflows/WorkflowInstance.java      |  45 +++++++++
 .../dataindex/workflows/WorkflowInstancesData.java |  45 +++++++++
 .../workflows/WorkflowInstancesResponse.java       |  40 ++++++++
 .../SonataFlowQuarkusExtensionJsonRPCService.java  |  54 +++++++++++
 .../src/main/resources/application.properties      |  20 ++++
 13 files changed, 424 insertions(+), 223 deletions(-)

diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/java/org/kie/sonataflow/swf/tools/deployment/DevConsoleProcessor.java
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/java/org/kie/sonataflow/swf/tools/deployment/DevConsoleProcessor.java
index 721a00c4e2e..a07fa93df69 100644
--- 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/java/org/kie/sonataflow/swf/tools/deployment/DevConsoleProcessor.java
+++ 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/java/org/kie/sonataflow/swf/tools/deployment/DevConsoleProcessor.java
@@ -19,9 +19,15 @@
 package org.kie.sonataflow.swf.tools.deployment;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
+import java.util.List;
+import java.util.Optional;
+
+import io.quarkus.deployment.Capabilities;
+import io.quarkus.devui.spi.JsonRPCProvidersBuildItem;
+import 
org.kie.sonataflow.swf.tools.runtime.config.DevUIStaticArtifactsRecorder;
 
 import io.quarkus.deployment.IsDevelopment;
 import io.quarkus.deployment.annotations.BuildProducer;
@@ -32,6 +38,7 @@ import io.quarkus.deployment.builditem.ConfigurationBuildItem;
 import io.quarkus.deployment.builditem.LaunchModeBuildItem;
 import io.quarkus.deployment.builditem.LiveReloadBuildItem;
 import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
+import io.quarkus.deployment.builditem.SystemPropertyBuildItem;
 import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
 import io.quarkus.deployment.util.WebJarUtil;
 import io.quarkus.devui.spi.page.CardPageBuildItem;
@@ -39,47 +46,17 @@ import io.quarkus.devui.spi.page.Page;
 import io.quarkus.maven.dependency.ResolvedDependency;
 import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
 import io.quarkus.vertx.http.deployment.RouteBuildItem;
-import io.quarkus.vertx.http.runtime.devmode.DevConsoleRecorder;
 import 
io.quarkus.vertx.http.runtime.management.ManagementInterfaceBuildTimeConfig;
+import 
org.kie.sonataflow.swf.tools.runtime.rpc.SonataFlowQuarkusExtensionJsonRPCService;
 
 public class DevConsoleProcessor {
 
     private static final String STATIC_RESOURCES_PATH = "dev-static/";
-    private static final String BASE_RELATIVE_URL = 
"/q/dev-v1/org.apache.kie.sonataflow.sonataflow-quarkus-devui-extension";
-
-    @BuildStep(onlyIf = IsDevelopment.class)
-    public CardPageBuildItem pages(NonApplicationRootPathBuildItem 
nonApplicationRootPathBuildItem,
-            ManagementInterfaceBuildTimeConfig 
managementInterfaceBuildTimeConfig,
-            LaunchModeBuildItem launchModeBuildItem,
-            ConfigurationBuildItem configurationBuildItem) throws 
UnsupportedEncodingException {
-
-        String uiPath = 
nonApplicationRootPathBuildItem.resolveManagementPath(BASE_RELATIVE_URL,
-                managementInterfaceBuildTimeConfig, launchModeBuildItem, true);
-
-        String devUIUrl = getProperty(configurationBuildItem, 
"kogito.dev-ui.url");
-        String devUIUrlQueryParam = devUIUrl != null ? "&devUIUrl=" + 
URLEncoder.encode(devUIUrl, "UTF-8") : "";
-
-        String dataIndexUrl = getProperty(configurationBuildItem, 
"kogito.data-index.url");
-        String dataIndexUrlQueryParam = dataIndexUrl != null ? 
"&dataIndexUrl=" + URLEncoder.encode(dataIndexUrl, "UTF-8") : "";
-
-        CardPageBuildItem cardPageBuildItem = new CardPageBuildItem();
-
-        cardPageBuildItem.addPage(Page.externalPageBuilder("Workflows")
-                .url(uiPath + "/index.html?page=Workflows" + 
devUIUrlQueryParam + dataIndexUrlQueryParam, uiPath)
-                .isHtmlContent()
-                .icon("font-awesome-solid:diagram-project"));
-
-        cardPageBuildItem.addPage(Page.externalPageBuilder("Monitoring")
-                .url(uiPath + "/index.html?page=Monitoring" + 
devUIUrlQueryParam + dataIndexUrlQueryParam, uiPath)
-                .isHtmlContent()
-                .icon("font-awesome-solid:gauge-high"));
-
-        return cardPageBuildItem;
-    }
+    private static final String BASE_RELATIVE_URL = 
"/q/dev-ui/org.apache.kie.sonataflow.sonataflow-quarkus-devui-extension";
 
     @BuildStep(onlyIf = IsDevelopment.class)
     @Record(ExecutionTime.RUNTIME_INIT)
-    public void deployStaticResources(final DevConsoleRecorder recorder,
+    public void deployStaticResources(final DevUIStaticArtifactsRecorder 
devUIStaticArtifactsRecorder,
             final CurateOutcomeBuildItem curateOutcomeBuildItem,
             final LiveReloadBuildItem liveReloadBuildItem,
             final LaunchModeBuildItem launchMode,
@@ -97,14 +74,65 @@ public class DevConsoleProcessor {
                 STATIC_RESOURCES_PATH,
                 true);
 
+        routeBuildItemBuildProducer.produce(new RouteBuildItem.Builder()
+                .route(BASE_RELATIVE_URL + "/resources/*")
+                
.handler(devUIStaticArtifactsRecorder.handler(devConsoleStaticResourcesDeploymentPath.toString(),
+                        shutdownContext))
+                .build());
+
         routeBuildItemBuildProducer.produce(new RouteBuildItem.Builder()
                 .route(BASE_RELATIVE_URL + "/*")
-                
.handler(recorder.devConsoleHandler(devConsoleStaticResourcesDeploymentPath.toString(),
+                
.handler(devUIStaticArtifactsRecorder.handler(devConsoleStaticResourcesDeploymentPath.toString(),
                         shutdownContext))
                 .build());
     }
 
+    @BuildStep(onlyIf = IsDevelopment.class)
+    public JsonRPCProvidersBuildItem createJsonRPCServiceForJBPMDevUi() {
+        return new 
JsonRPCProvidersBuildItem(SonataFlowQuarkusExtensionJsonRPCService.class);
+    }
+
+    @BuildStep(onlyIf = IsDevelopment.class)
+    public CardPageBuildItem pages(
+            final NonApplicationRootPathBuildItem 
nonApplicationRootPathBuildItem,
+            final ManagementInterfaceBuildTimeConfig 
managementInterfaceBuildTimeConfig,
+            final LaunchModeBuildItem launchModeBuildItem,
+            final ConfigurationBuildItem configurationBuildItem,
+            final List<SystemPropertyBuildItem> systemPropertyBuildItems,
+            final Capabilities capabilities) {
+
+        CardPageBuildItem cardPageBuildItem = new CardPageBuildItem();
+
+        String uiPath = 
nonApplicationRootPathBuildItem.resolveManagementPath(BASE_RELATIVE_URL,
+                                                                              
managementInterfaceBuildTimeConfig, launchModeBuildItem, true);
+
+        String openapiPath = getProperty(configurationBuildItem, 
systemPropertyBuildItems, "quarkus.smallrye-openapi.path");
+        String devUIUrl = getProperty(configurationBuildItem, 
systemPropertyBuildItems, "kogito.dev-ui.url");
+        String dataIndexUrl = getProperty(configurationBuildItem, 
systemPropertyBuildItems, "kogito.data-index.url");
+
+        cardPageBuildItem.addBuildTimeData("extensionBasePath", uiPath);
+        cardPageBuildItem.addBuildTimeData("openapiPath", openapiPath);
+        cardPageBuildItem.addBuildTimeData("devUIUrl", devUIUrl);
+        cardPageBuildItem.addBuildTimeData("dataIndexUrl", dataIndexUrl);
+
+        cardPageBuildItem.addPage(Page.webComponentPageBuilder()
+                                          
.componentLink("qwc-sonataflow-quarkus-devui.js")
+                                          .metadata("page", "Workflows")
+                                          .title("Workflows")
+                                          
.icon("font-awesome-solid:diagram-project")
+                                          
.dynamicLabelJsonRPCMethodName("queryWorkflowsCount"));
+
+        cardPageBuildItem.addPage(Page.webComponentPageBuilder()
+                                          
.componentLink("qwc-sonataflow-quarkus-devui.js")
+                                          .metadata("page", "Monitoring")
+                                          .title("Monitoring")
+                                          
.icon("font-awesome-solid:chart-simple"));
+
+        return cardPageBuildItem;
+    }
+
     private static String getProperty(ConfigurationBuildItem 
configurationBuildItem,
+            List<SystemPropertyBuildItem> systemPropertyBuildItems,
             String propertyKey) {
 
         String propertyValue = configurationBuildItem
@@ -128,6 +156,12 @@ public class DevConsoleProcessor {
                     .get(propertyKey);
         }
 
-        return propertyValue;
+        if (propertyValue != null) {
+            return propertyValue;
+        }
+
+        return systemPropertyBuildItems.stream().filter(property -> 
property.getKey().equals(propertyKey))
+                .findAny()
+                .map(SystemPropertyBuildItem::getValue).orElse(null);
     }
 }
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-templates/embedded.html
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-templates/embedded.html
deleted file mode 100644
index da2e7069430..00000000000
--- 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-templates/embedded.html
+++ /dev/null
@@ -1,53 +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.
-
--->
-<a href="{urlbase}/workflowInstances" class="badge badge-light">
-  <i class="fa fa-project-diagram fa-fw"></i>
-  Workflow Instances
-  <span id="workflowInstancesCount" class="badge badge-light" />
-</a>
-<a href="{urlbase}/monitoring" class="badge badge-light">
-  <i class="fa fa-tachometer fa-fw"></i>
-  Monitoring
-</a>
-<script>
-  const graphqlUrl = "{config:property('kogito.data-index.url') ?: 
''}/graphql";
-
-  {|
-      const fillCount = () => {
-          fetch(graphqlUrl, {
-              method: "POST",
-              headers: {
-                  "Content-Type": "application/json",
-                  Accept: "application/json",
-              },
-              body: JSON.stringify({query: "query getAllProcessesIds{  
ProcessInstances{ id } }"}),
-          })
-              .then(r => r.json())
-              .then(json => 
$("#workflowInstancesCount").text(json.data.ProcessInstances.length))
-              .catch(error => {
-                  console.log("Error while trying to fetch workflow instances 
count.");
-                  console.error(error);
-              });
-      };
-
-      fillCount();
-  |}
-</script>
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-templates/monitoring.html
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-templates/monitoring.html
deleted file mode 100644
index 2132fd4c35c..00000000000
--- 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-templates/monitoring.html
+++ /dev/null
@@ -1,44 +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.
-
--->
-{#include main fluid=true} {#style} .main-container { margin: 0; padding: 0; } 
#envelope-app { width: 100vw; height:
-calc(100vh - 98px); } {/style} {#title}Runtime UI{/title} {#body}
-<div id="envelope-app"></div>
-
-<script src="resources/webapp/standalone.js"></script>
-<script>
-  const devUIUrl= {#if 
config:property('kogito.dev-ui.url')}"{config:property('kogito.dev-ui.url')}"{#else}window.location.origin{/if};
-  const devUI = RuntimeToolsDevUI.open({
-      container: document.getElementById("envelope-app"),
-      isDataIndexAvailable: true,
-      dataIndexUrl: "{config:property('kogito.data-index.url') ?: ''}/graphql",
-      page: "Monitoring",
-      devUIUrl,
-      openApiBaseUrl: devUIUrl,
-      openApiPath: "q/openapi.json",
-      availablePages: ["Workflows", "Monitoring", "CustomDashboard"],
-      omittedWorkflowTimelineEvents: ["EmbeddedStart", "EmbeddedEnd", 
"Script"],
-      diagramPreviewSize: {
-          width: 1000,
-          height: 1000
-      }
-  })
-</script>
-{/body} {/include}
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-templates/workflowInstances.html
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-templates/workflowInstances.html
deleted file mode 100644
index 90370483336..00000000000
--- 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-templates/workflowInstances.html
+++ /dev/null
@@ -1,45 +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.
-
--->
-{#include main fluid=true} {#style} .main-container { margin: 0; padding: 0; } 
#envelope-app { width: 100vw; height:
-calc(100vh - 98px); } {/style} {#title}Runtime UI{/title} {#body}
-<div id="envelope-app"></div>
-
-<script src="resources/webapp/standalone.js"></script>
-<script>
-  const devUIUrl= {#if 
config:property('kogito.dev-ui.url')}"{config:property('kogito.dev-ui.url')}"{#else}window.location.origin{/if};
-
-  const devUI = RuntimeToolsDevUI.open({
-      container: document.getElementById("envelope-app"),
-      isDataIndexAvailable: true,
-      dataIndexUrl: "{config:property('kogito.data-index.url') ?: ''}/graphql",
-      devUIUrl,
-      page: "Workflows",
-      openApiBaseUrl: devUIUrl,
-      openApiPath: "q/openapi.json",
-      availablePages: ["Workflows", "Monitoring", "CustomDashboard"],
-      omittedWorkflowTimelineEvents: ["EmbeddedStart", "EmbeddedEnd", 
"Script"],
-      diagramPreviewSize: {
-          width: 1000,
-          height: 1000
-      }
-  })
-</script>
-{/body} {/include}
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-ui/qwc-sonataflow-quarkus-devui.js
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-ui/qwc-sonataflow-quarkus-devui.js
new file mode 100644
index 00000000000..2e9b530ea18
--- /dev/null
+++ 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/dev-ui/qwc-sonataflow-quarkus-devui.js
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2024 Red Hat, Inc. and/or its affiliates.
+ *
+ * Licensed 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.
+ */
+
+import { html, LitElement } from "lit";
+import { dataIndexUrl, devUIUrl, extensionBasePath, openapiPath } from 
"build-time-data";
+import { RouterController } from "router-controller";
+
+export class QwcSonataflowQuarkusDevui extends LitElement {
+  _routerController = new RouterController(this);
+
+  constructor() {
+    super();
+  }
+
+  render() {
+    return html` <div id="envelope-app" style="height: 100%"></div>`;
+  }
+
+  async connectedCallback() {
+    super.connectedCallback();
+    await this.updateComplete;
+    if (!document.querySelector("#sonataflow-devui-script")) {
+      const script = document.createElement("script");
+      script.setAttribute("async", "");
+      script.setAttribute("id", "sonataflow-devui-script");
+      script.setAttribute("src", 
`${extensionBasePath}/resources/webapp/standalone.js`);
+      script.addEventListener("load", () => {
+        this.initUI();
+      });
+      document.head.appendChild(script);
+    } else {
+      this.initUI();
+    }
+  }
+
+  initUI() {
+    const metadata = this._routerController.getCurrentMetaData();
+    const container = this.renderRoot.querySelector("#envelope-app");
+    RuntimeToolsDevUI.open({
+      container: container,
+      isDataIndexAvailable: true,
+      dataIndexUrl: `${dataIndexUrl ?? window.location.origin}/graphql`,
+      page: metadata.page ?? "Workflows",
+      devUIUrl: `${devUIUrl ?? window.location.origin}`,
+      openApiBaseUrl: `${devUIUrl ?? window.location.origin}`,
+      openApiPath: `${openapiPath ?? "q/openapi.json"}`,
+      availablePages: ["Workflows", "Monitoring", "CustomDashboard"],
+    });
+  }
+}
+
+customElements.define("qwc-sonataflow-quarkus-devui", 
QwcSonataflowQuarkusDevui);
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/static/index.html
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/static/index.html
deleted file mode 100644
index 8e850ece508..00000000000
--- 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension-deployment/src/main/resources/static/index.html
+++ /dev/null
@@ -1,45 +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.
-
--->
-<div id="envelope-app"></div>
-
-<script src="resources/webapp/standalone.js"></script>
-<script>
-  const urlParams = new URLSearchParams(window.location.search);
-  const page = urlParams.get("page");
-  const devUIUrl = urlParams.get("devUIUrl");
-  const dataIndexUrl = urlParams.get("dataIndexUrl");
-
-  const devUI = RuntimeToolsDevUI.open({
-    container: document.getElementById("envelope-app"),
-    isDataIndexAvailable: true,
-    dataIndexUrl: dataIndexUrl ? dataIndexUrl : "" + "/graphql",
-    page: page,
-    devUIUrl: devUIUrl ? devUIUrl : window.location.origin,
-    openApiBaseUrl: devUIUrl ? devUIUrl : window.location.origin,
-    openApiPath: "q/openapi.json",
-    availablePages: ["Workflows", "Monitoring", "CustomDashboard"],
-    omittedWorkflowTimelineEvents: ["EmbeddedStart", "EmbeddedEnd", "Script"],
-    diagramPreviewSize: {
-      width: 1000,
-      height: 1000,
-    },
-  });
-</script>
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/config/DevUIStaticArtifactsRecorder.java
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/config/DevUIStaticArtifactsRecorder.java
new file mode 100644
index 00000000000..f4588d1fb93
--- /dev/null
+++ 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/config/DevUIStaticArtifactsRecorder.java
@@ -0,0 +1,44 @@
+/*
+ * 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.sonataflow.swf.tools.runtime.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import io.quarkus.runtime.ShutdownContext;
+import io.quarkus.runtime.annotations.Recorder;
+import io.quarkus.vertx.http.runtime.devmode.FileSystemStaticHandler;
+import io.vertx.core.Handler;
+import io.vertx.ext.web.RoutingContext;
+
+@Recorder
+public class DevUIStaticArtifactsRecorder {
+    public Handler<RoutingContext> handler(String deploymentArtifactPath, 
ShutdownContext shutdownContext) {
+        List<FileSystemStaticHandler.StaticWebRootConfiguration> 
webRootConfigurations = new ArrayList<>();
+        webRootConfigurations.add(
+                new 
FileSystemStaticHandler.StaticWebRootConfiguration(deploymentArtifactPath, ""));
+
+        FileSystemStaticHandler fileSystemStaticHandler = new 
FileSystemStaticHandler(webRootConfigurations);
+
+        shutdownContext.addShutdownTask(new 
ShutdownContext.CloseRunnable(fileSystemStaticHandler));
+
+        return fileSystemStaticHandler;
+    }
+}
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/DataIndexClient.java
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/DataIndexClient.java
new file mode 100644
index 00000000000..f8d28872d4d
--- /dev/null
+++ 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/DataIndexClient.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.kie.sonataflow.swf.tools.runtime.dataindex;
+
+import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
+import 
org.kie.sonataflow.swf.tools.runtime.dataindex.workflows.WorkflowInstancesResponse;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.core.MediaType;
+
+@Path("/graphql")
+@RegisterRestClient(configKey = DataIndexClient.DATA_INDEX_CONFIG_KEY)
+@ApplicationScoped
+public interface DataIndexClient {
+
+    String DATA_INDEX_CONFIG_KEY = "kogito.data-index.url";
+
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    WorkflowInstancesResponse queryWorkflows(String query);
+}
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/workflows/WorkflowInstance.java
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/workflows/WorkflowInstance.java
new file mode 100644
index 00000000000..d20e872ace5
--- /dev/null
+++ 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/workflows/WorkflowInstance.java
@@ -0,0 +1,45 @@
+/*
+ * 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.sonataflow.swf.tools.runtime.dataindex.workflows;
+
+public class WorkflowInstance {
+
+    private String id;
+
+    public WorkflowInstance() {
+    }
+
+    public WorkflowInstance(final String id) {
+        this.id = id;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(final String id) {
+        this.id = id;
+    }
+
+    @Override
+    public String toString() {
+        return id;
+    }
+}
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/workflows/WorkflowInstancesData.java
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/workflows/WorkflowInstancesData.java
new file mode 100644
index 00000000000..df7f26ff8de
--- /dev/null
+++ 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/workflows/WorkflowInstancesData.java
@@ -0,0 +1,45 @@
+/*
+ * 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.sonataflow.swf.tools.runtime.dataindex.workflows;
+
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class WorkflowInstancesData {
+
+    @JsonProperty("ProcessInstances")
+    private List<WorkflowInstance> instances;
+
+    public WorkflowInstancesData() {
+    }
+
+    public WorkflowInstancesData(final List<WorkflowInstance> instances) {
+        this.instances = instances;
+    }
+
+    public List<WorkflowInstance> getWorkflows() {
+        return instances;
+    }
+
+    public void setWorkflowInstances(final List<WorkflowInstance> 
workflowInstancesList) {
+        this.instances = workflowInstancesList;
+    }
+}
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/workflows/WorkflowInstancesResponse.java
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/workflows/WorkflowInstancesResponse.java
new file mode 100644
index 00000000000..bfd36dfb6b6
--- /dev/null
+++ 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/dataindex/workflows/WorkflowInstancesResponse.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.sonataflow.swf.tools.runtime.dataindex.workflows;
+
+public class WorkflowInstancesResponse {
+
+    private WorkflowInstancesData data;
+
+    public WorkflowInstancesResponse() {
+    }
+
+    public WorkflowInstancesResponse(final WorkflowInstancesData data) {
+        this.data = data;
+    }
+
+    public WorkflowInstancesData getData() {
+        return data;
+    }
+
+    public void setData(final WorkflowInstancesData data) {
+        this.data = data;
+    }
+}
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/rpc/SonataFlowQuarkusExtensionJsonRPCService.java
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/rpc/SonataFlowQuarkusExtensionJsonRPCService.java
new file mode 100644
index 00000000000..cd5b2570edf
--- /dev/null
+++ 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/java/org/kie/sonataflow/swf/tools/runtime/rpc/SonataFlowQuarkusExtensionJsonRPCService.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2024 Red Hat, Inc. and/or its affiliates.
+ *
+ * Licensed 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.sonataflow.swf.tools.runtime.rpc;
+
+import java.util.function.Supplier;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.smallrye.common.annotation.NonBlocking;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import org.eclipse.microprofile.rest.client.inject.RestClient;
+import org.kie.sonataflow.swf.tools.runtime.dataindex.DataIndexClient;
+
+@ApplicationScoped
+public class SonataFlowQuarkusExtensionJsonRPCService {
+    public static final String ALL_WORKFLOWS_IDS_QUERY = "{ \"operationName\": 
\"getAllProcessesIds\", \"query\": \"query getAllProcessesIds{  
ProcessInstances{ id } }\" }";
+
+    private final ObjectMapper mapper;
+    private final DataIndexClient dataIndexClient;
+
+    @Inject
+    public SonataFlowQuarkusExtensionJsonRPCService(ObjectMapper mapper, 
@RestClient DataIndexClient dataIndexClient) {
+        this.mapper = mapper;
+        this.dataIndexClient = dataIndexClient;
+    }
+
+    @NonBlocking
+    public String queryWorkflowsCount() {
+        return doQuery(() -> 
this.dataIndexClient.queryWorkflows(ALL_WORKFLOWS_IDS_QUERY).getData().getWorkflows().size());
+    }
+
+    private String doQuery(Supplier<Integer> countSupplier) {
+        try {
+            return String.valueOf(countSupplier.get());
+        } catch (Exception ex) {
+            return "-";
+        }
+    }
+
+}
diff --git 
a/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/resources/application.properties
 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/resources/application.properties
new file mode 100644
index 00000000000..ff385055a76
--- /dev/null
+++ 
b/packages/sonataflow-quarkus-devui-extension/sonataflow-quarkus-devui-extension/src/main/resources/application.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+
+quarkus.rest-client."kogito.data-index.url".url=${kogito.data-index.url}/
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to