diff --git a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/devconsole/DevConsoleProcessor.java b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/devconsole/DevConsoleProcessor.java index 94d1c46300e91..a4e2f90932ed4 100644 --- a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/devconsole/DevConsoleProcessor.java +++ b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/devconsole/DevConsoleProcessor.java @@ -14,12 +14,12 @@ public class DevConsoleProcessor { @BuildStep(onlyIf = IsDevelopment.class) public DevConsoleRuntimeTemplateInfoBuildItem collectBeanInfo() { - return new DevConsoleRuntimeTemplateInfoBuildItem("entities", new HibernateSearchSupplier()); + return new DevConsoleRuntimeTemplateInfoBuildItem("entityTypes", new HibernateSearchSupplier()); } @BuildStep @Record(value = STATIC_INIT, optional = true) DevConsoleRouteBuildItem invokeEndpoint(HibernateSearchDevConsoleRecorder recorder) { - return new DevConsoleRouteBuildItem("entities", "POST", recorder.indexEntity()); + return new DevConsoleRouteBuildItem("entity-types", "POST", recorder.indexEntity()); } } diff --git a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/resources/dev-templates/embedded.html b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/resources/dev-templates/embedded.html index 192a385b27b1a..7f7027a3cb8cc 100644 --- a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/resources/dev-templates/embedded.html +++ b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/resources/dev-templates/embedded.html @@ -1,4 +1,4 @@ - + - Indexed entities {info:entities.size()} + Indexed entity types {info:entityTypes.size()}
diff --git a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/resources/dev-templates/entities.html b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/resources/dev-templates/entity-types.html similarity index 85% rename from extensions/hibernate-search-orm-elasticsearch/deployment/src/main/resources/dev-templates/entities.html rename to extensions/hibernate-search-orm-elasticsearch/deployment/src/main/resources/dev-templates/entity-types.html index 3f81b7ba4ba15..a257afacb8225 100644 --- a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/resources/dev-templates/entities.html +++ b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/resources/dev-templates/entity-types.html @@ -11,18 +11,18 @@ - Entity + Entity type - {#for entity in info:entities} + {#for entityType in info:entityTypes}
- +
- {entity} + {entityType} {/for} diff --git a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/devconsole/HibernateSearchDevConsoleRecorder.java b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/devconsole/HibernateSearchDevConsoleRecorder.java index cd49ef9553ef3..c472dac77e565 100644 --- a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/devconsole/HibernateSearchDevConsoleRecorder.java +++ b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/devconsole/HibernateSearchDevConsoleRecorder.java @@ -7,6 +7,7 @@ import org.hibernate.search.mapper.orm.mapping.SearchMapping; import io.quarkus.devconsole.runtime.spi.DevConsolePostHandler; +import io.quarkus.devconsole.runtime.spi.FlashScopeUtil; import io.quarkus.runtime.annotations.Recorder; import io.vertx.core.Handler; import io.vertx.core.MultiMap; @@ -22,9 +23,13 @@ protected void handlePostAsync(RoutingContext event, MultiMap form) throws Excep if (form.isEmpty()) { return; } - SearchMapping searchMapping = HibernateSearchSupplier.searchMapping(); - searchMapping.scope(Object.class, - searchMapping.allIndexedEntities().stream() + SearchMapping mapping = HibernateSearchSupplier.searchMapping(); + if (mapping == null) { + flashMessage(event, "There aren't any indexed entity types!", FlashScopeUtil.FlashMessageStatus.ERROR); + return; + } + mapping.scope(Object.class, + mapping.allIndexedEntities().stream() .map(SearchIndexedEntity::jpaName) .filter(form::contains) .collect(Collectors.toList())) diff --git a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/devconsole/HibernateSearchSupplier.java b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/devconsole/HibernateSearchSupplier.java index 4666a20a0f97f..1f6cb8579a691 100644 --- a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/devconsole/HibernateSearchSupplier.java +++ b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/devconsole/HibernateSearchSupplier.java @@ -1,5 +1,6 @@ package io.quarkus.hibernate.search.orm.elasticsearch.runtime.devconsole; +import java.util.Collections; import java.util.List; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -12,7 +13,11 @@ public class HibernateSearchSupplier implements Supplier> { @Override public List get() { - return searchMapping().allIndexedEntities().stream().map(SearchIndexedEntity::jpaName).sorted() + SearchMapping mapping = searchMapping(); + if (mapping == null) { + return Collections.emptyList(); + } + return mapping.allIndexedEntities().stream().map(SearchIndexedEntity::jpaName).sorted() .collect(Collectors.toList()); }