forked from apache/incubator-kie-tools
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from fantonangeli/sync-main
Sync main branch with Apache main branch
- Loading branch information
Showing
94 changed files
with
2,333 additions
and
241 deletions.
There are no files selected for viewing
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
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
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
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
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
87 changes: 87 additions & 0 deletions
87
...rkus-devui-runtime/src/main/java/org/jbpm/quarkus/devui/runtime/rpc/DataIndexCounter.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,87 @@ | ||
/* | ||
* 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.jbpm.quarkus.devui.runtime.rpc; | ||
|
||
import io.smallrye.mutiny.Multi; | ||
import io.smallrye.mutiny.operators.multi.MultiCacheOp; | ||
import io.smallrye.mutiny.operators.multi.processors.BroadcastProcessor; | ||
import io.vertx.core.Vertx; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.ext.web.client.WebClient; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class DataIndexCounter { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(DataIndexCounter.class); | ||
|
||
private final Vertx vertx; | ||
private final MultiCacheOp<String> multi; | ||
private final WebClient dataIndexWebClient; | ||
private final String path; | ||
|
||
private final String query; | ||
private final String field; | ||
|
||
public DataIndexCounter(String query, String graphField, String path, Vertx vertx, WebClient dataIndexWebClient) { | ||
if (dataIndexWebClient == null) { | ||
throw new IllegalArgumentException("dataIndexWebClient is null"); | ||
} | ||
this.query = query; | ||
this.field = graphField; | ||
this.path = path; | ||
|
||
this.vertx = vertx; | ||
this.dataIndexWebClient = dataIndexWebClient; | ||
|
||
this.multi = new MultiCacheOp<>(BroadcastProcessor.create()); | ||
|
||
refreshCount(); | ||
} | ||
|
||
public void refresh() { | ||
vertx.setTimer(1000, id -> { | ||
refreshCount(); | ||
}); | ||
} | ||
|
||
public void stop() { | ||
multi.onComplete(); | ||
} | ||
|
||
private void refreshCount() { | ||
LOGGER.debug("Refreshing data for query: {}", query); | ||
|
||
this.dataIndexWebClient.post(path + "/graphql") | ||
.putHeader("content-type", "application/json") | ||
.sendJson(new JsonObject(query)) | ||
.map(response -> { | ||
if (response.statusCode() == 200) { | ||
JsonObject responseData = response.bodyAsJsonObject().getJsonObject("data"); | ||
return String.valueOf(responseData.getJsonArray(field).size()); | ||
} | ||
return "0"; | ||
}) | ||
.onComplete(count -> this.multi.onNext(count.result())); | ||
} | ||
|
||
public Multi<String> getMulti() { | ||
return multi; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...vui-runtime/src/main/java/org/jbpm/quarkus/devui/runtime/rpc/JBPMDevUIEventPublisher.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,79 @@ | ||
/* | ||
* 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.jbpm.quarkus.devui.runtime.rpc; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.inject.Default; | ||
|
||
import org.kie.kogito.event.DataEvent; | ||
import org.kie.kogito.event.EventPublisher; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.quarkus.arc.profile.IfBuildProfile; | ||
|
||
import java.util.Collection; | ||
import java.util.Objects; | ||
@ApplicationScoped | ||
@IfBuildProfile("dev") | ||
public class JBPMDevUIEventPublisher implements EventPublisher { | ||
|
||
private Runnable onProcessEvent; | ||
private Runnable onTaskEvent; | ||
private Runnable onJobEvent; | ||
|
||
@Override | ||
public void publish(DataEvent<?> event) { | ||
switch (event.getType()) { | ||
case "ProcessInstanceStateDataEvent": | ||
maybeRun(onProcessEvent); | ||
break; | ||
case "UserTaskInstanceStateDataEvent": | ||
maybeRun(onTaskEvent); | ||
break; | ||
case "JobEvent": | ||
maybeRun(onJobEvent); | ||
break; | ||
} | ||
} | ||
|
||
@Override | ||
public void publish(Collection<DataEvent<?>> events) { | ||
events.forEach(this::publish); | ||
} | ||
|
||
private void maybeRun(Runnable runnable) { | ||
if (Objects.nonNull(runnable)) { | ||
runnable.run(); | ||
} | ||
} | ||
|
||
public void setOnProcessEventListener(Runnable onProcessEvent) { | ||
this.onProcessEvent = onProcessEvent; | ||
} | ||
|
||
public void setOnTaskEventListener(Runnable onTaskEvent) { | ||
this.onTaskEvent = onTaskEvent; | ||
} | ||
|
||
public void setOnJobEventListener(Runnable onJobEvent) { | ||
this.onJobEvent = onJobEvent; | ||
} | ||
} |
Oops, something went wrong.