Skip to content

Commit

Permalink
incubator-kie-issues#1283: Fix Kogito Addons Quarkus Data Index `DevM…
Browse files Browse the repository at this point in the history
…ode`

- Verify that the GraphQL UI can be added into the Quarkus `devui` before adding it.
  • Loading branch information
pefernan committed May 30, 2024
1 parent bfb00fd commit 0eb9677
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand All @@ -36,6 +37,8 @@
import io.quarkus.devui.spi.page.CardPageBuildItem;
import io.quarkus.devui.spi.page.Page;

import static org.kie.kogito.quarkus.workflow.devservices.DataIndexEventPublisher.KOGITO_DATA_INDEX;

/**
* Starts a Data Index as dev service if needed.
*/
Expand All @@ -49,16 +52,25 @@ public void logger(BuildProducer<AdditionalBeanBuildItem> additionalBean, Launch
}

@BuildStep(onlyIf = { GlobalDevServicesConfig.Enabled.class, IsDevelopment.class })
CardPageBuildItem createDevUILink(List<SystemPropertyBuildItem> systemPropertyBuildItems) {
Optional<String> dataindex_url_prop = getProperty(systemPropertyBuildItems, "kogito.data-index.url");
if (dataindex_url_prop.isPresent()) {
CardPageBuildItem cardPageBuildItem = new CardPageBuildItem();
cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI")
.url(dataindex_url_prop.get() + "/q/graphql-ui/")
.isHtmlContent()
.icon("font-awesome-solid:signs-post"));
return cardPageBuildItem;
CardPageBuildItem createDataIndexDevUILink(Capabilities capabilities,
KogitoWorkflowBuildTimeConfig kogitoBuildTimeConfig,
List<SystemPropertyBuildItem> systemPropertyBuildItems) {

Optional<String> dataIndexUrlProp = getProperty(systemPropertyBuildItems, KOGITO_DATA_INDEX);

if (capabilities.isPresent(DATA_INDEX_CAPABILITY) || !areDevServicesEnabled(kogitoBuildTimeConfig) || dataIndexUrlProp.isEmpty()) {
return null;
}
return null;

CardPageBuildItem cardPageBuildItem = new CardPageBuildItem();
cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI")
.url(dataIndexUrlProp.get() + "/q/graphql-ui/")
.isHtmlContent()
.icon("font-awesome-solid:signs-post"));
return cardPageBuildItem;
}

private boolean areDevServicesEnabled(KogitoWorkflowBuildTimeConfig kogitoBuildTimeConfig) {
return kogitoBuildTimeConfig.devservices.enabled.orElse(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand All @@ -36,6 +37,8 @@
import io.quarkus.devui.spi.page.CardPageBuildItem;
import io.quarkus.devui.spi.page.Page;

import static org.kie.kogito.quarkus.workflow.devservices.DataIndexEventPublisher.KOGITO_DATA_INDEX;

public class ServerlessWorkflowDevServicesProcessor extends AbstractDevServicesProcessor {
@BuildStep
public void logger(BuildProducer<AdditionalBeanBuildItem> additionalBean, LaunchModeBuildItem launchMode, KogitoWorkflowBuildTimeConfig config) {
Expand All @@ -45,16 +48,25 @@ public void logger(BuildProducer<AdditionalBeanBuildItem> additionalBean, Launch
}

@BuildStep(onlyIf = { GlobalDevServicesConfig.Enabled.class, IsDevelopment.class })
CardPageBuildItem createDevUILink(List<SystemPropertyBuildItem> systemPropertyBuildItems) {
Optional<String> dataindex_url_prop = getProperty(systemPropertyBuildItems, "kogito.data-index.url");
if (dataindex_url_prop.isPresent()) {
CardPageBuildItem cardPageBuildItem = new CardPageBuildItem();
cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI")
.url(dataindex_url_prop.get() + "/q/graphql-ui/")
.isHtmlContent()
.icon("font-awesome-solid:signs-post"));
return cardPageBuildItem;
CardPageBuildItem createDataIndexDevUILink(Capabilities capabilities,
KogitoWorkflowBuildTimeConfig kogitoBuildTimeConfig,
List<SystemPropertyBuildItem> systemPropertyBuildItems) {

Optional<String> dataIndexUrlProp = getProperty(systemPropertyBuildItems, KOGITO_DATA_INDEX);

if (capabilities.isPresent(DATA_INDEX_CAPABILITY) || !areDevServicesEnabled(kogitoBuildTimeConfig) || dataIndexUrlProp.isEmpty()) {
return null;
}
return null;

CardPageBuildItem cardPageBuildItem = new CardPageBuildItem();
cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI")
.url(dataIndexUrlProp.get() + "/q/graphql-ui/")
.isHtmlContent()
.icon("font-awesome-solid:signs-post"));
return cardPageBuildItem;
}

private boolean areDevServicesEnabled(KogitoWorkflowBuildTimeConfig kogitoBuildTimeConfig) {
return kogitoBuildTimeConfig.devservices.enabled.orElse(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public abstract class AbstractDevServicesProcessor {

private static final Logger LOGGER = LoggerFactory.getLogger(AbstractDevServicesProcessor.class);
private static final ContainerLocator LOCATOR = new ContainerLocator(DataIndexInMemoryContainer.DEV_SERVICE_LABEL, DataIndexInMemoryContainer.PORT);
private static final String DATA_INDEX_CAPABILITY = "org.kie.kogito.data-index";
protected static final String DATA_INDEX_CAPABILITY = "org.kie.kogito.data-index";
static Closeable closeable;
static DataIndexDevServiceConfig cfg;
static volatile boolean first = true;
Expand Down

0 comments on commit 0eb9677

Please sign in to comment.