Skip to content

Commit

Permalink
Merge pull request #17769 from gsmet/dev-ui-hibernate-search
Browse files Browse the repository at this point in the history
Fix a few things in the Hibernate Search Dev UI
  • Loading branch information
geoand authored Jun 9, 2021
2 parents f70b74e + 2f88c9b commit 2dc3fa6
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class HibernateSearchElasticsearchDevConsoleProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
public DevConsoleRuntimeTemplateInfoBuildItem collectBeanInfo() {
return new DevConsoleRuntimeTemplateInfoBuildItem("entityTypes", new HibernateSearchSupplier());
return new DevConsoleRuntimeTemplateInfoBuildItem("indexedEntityTypes", new HibernateSearchSupplier());
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="{urlbase}/entity-types" class="badge badge-light">
<i class="fa fa-search fa-fw"></i>
Indexed entity types <span class="badge badge-light">{info:entityTypes.size()}</span></a>
Indexed entity types <span class="badge badge-light">{info:indexedEntityTypes.size()}</span></a>
<br>
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,32 @@
<form method="post" enctype="application/x-www-form-urlencoded">
<input id="index" type="submit" class="btn btn-primary mb-2" value="Reindex Entities" >
<table id="table" class="table table-striped">
<colgroup>
<col span="1" style="width: 5%;">
<col span="1" style="width: 30%;">
<col span="1" style="width: 65%;">
</colgroup>
<thead class="thead-dark">
<tr>
<th scope="col">
<div class="custom-control">
<input type="checkbox" class="form-check-input" id="check-all">
</div>
</th>
<th scope="col">Entity name</th>
<th scope="col">Entity type</th>
</tr>
</thead>
<tbody>
{#for entityType in info:entityTypes}
{#for indexedEntityType in info:indexedEntityTypes}
<tr>
<td>
<div class="custom-control">
<input type="checkbox" class="form-check-input checkbox" name="{entityType}" id="{entityType}">
<input type="checkbox" class="form-check-input checkbox" name="{indexedEntityType.jpaName}" id="{indexedEntityType.jpaName}">
</div>
</td>
<td>{entityType}</td>
<td>{indexedEntityType.jpaName}</td>
<td>{indexedEntityType.javaClass}</td>
</tr>
{/for}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected void handlePostAsync(RoutingContext event, MultiMap form) throws Excep
}
SearchMapping mapping = HibernateSearchSupplier.searchMapping();
if (mapping == null) {
flashMessage(event, "There aren't any indexed entity types!", FlashScopeUtil.FlashMessageStatus.ERROR);
flashMessage(event, "There are no indexed entity types.", FlashScopeUtil.FlashMessageStatus.ERROR);
return;
}
mapping.scope(Object.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,37 @@
import org.hibernate.search.mapper.orm.mapping.SearchMapping;

import io.quarkus.arc.Arc;
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.devconsole.HibernateSearchSupplier.DevUiIndexedEntity;

public class HibernateSearchSupplier implements Supplier<List<DevUiIndexedEntity>> {

public class HibernateSearchSupplier implements Supplier<List<String>> {
@Override
public List<String> get() {
public List<DevUiIndexedEntity> get() {
SearchMapping mapping = searchMapping();
if (mapping == null) {
return Collections.emptyList();
}
return mapping.allIndexedEntities().stream().map(SearchIndexedEntity::jpaName).sorted()
return mapping.allIndexedEntities().stream().map(DevUiIndexedEntity::new).sorted()
.collect(Collectors.toList());

}

public static SearchMapping searchMapping() {
return Arc.container().instance(SearchMapping.class).get();
}

public static class DevUiIndexedEntity implements Comparable<DevUiIndexedEntity> {

public final String jpaName;
public final String javaClass;

DevUiIndexedEntity(SearchIndexedEntity<?> searchIndexedEntity) {
this.jpaName = searchIndexedEntity.jpaName();
this.javaClass = searchIndexedEntity.javaClass().getName();
}

@Override
public int compareTo(DevUiIndexedEntity o) {
return this.jpaName.compareTo(o.jpaName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
{#insert style/}
</style>

<script src="{devRootAppend}/resources/js/jquery.min.js"></script>
<script src="{devRootAppend}/resources/js/bootstrap.bundle.min.js"></script>
<script src="{devRootAppend}/resources/js/dev-console.js"></script>

<title>
{#if currentExtensionName && currentExtensionName != 'Eclipse Vert.x - HTTP'}
{currentExtensionName} ›
Expand Down Expand Up @@ -100,10 +104,7 @@

{#include logmanagerModals}{/include}
{#include testsModals}{/include}

<script src="{devRootAppend}/resources/js/jquery.min.js"></script>
<script src="{devRootAppend}/resources/js/bootstrap.bundle.min.js"></script>
<script src="{devRootAppend}/resources/js/dev-console.js"></script>

<script src="{devRootAppend}/resources/js/logstream.js"></script>
<script src="{devRootAppend}/resources/js/tests.js"></script>

Expand Down

0 comments on commit 2dc3fa6

Please sign in to comment.