generator-jhipster-elasticsearch-reindexer icon indicating copy to clipboard operation
generator-jhipster-elasticsearch-reindexer copied to clipboard

JHipster 5 compatibility

Open pascalgrimaud opened this issue 6 years ago • 14 comments

Hi @geraldhumphries,

Just to let you know that, with the release of JHipster 5, they can be some breaking changes.

You need to test if your module works well, and if it's the case, you need to add jhipster-5 in keywords: https://github.com/geraldhumphries/generator-jhipster-elasticsearch-reindexer/blob/master/package.json#L5-L8

With that, your module will be displayed at this question: ? Would you like to install other generators from the JHipster Marketplace? (y/N) See https://github.com/jhipster/generator-jhipster/pull/7408

Thank you for this module ;)

pascalgrimaud avatar Apr 08 '18 17:04 pascalgrimaud

The main changes that impact this module are:

Backend

  • Elasticsearch removed the embedded option, so you have to run an instance locally in dev.
  • Elasticsearch deprecated IndexAlreadyExistsException for ResourceAlreadyExistsException (release notes)
- import org.elasticsearch.indices.IndexAlreadyExistsException;
+ import org.elasticsearch.ResourceAlreadyExistsException;

-        } catch (IndexAlreadyExistsException e) {
+        } catch (ResourceAlreadyExistsException e) {

  • Spring Data changed method signatures for CrudRepository, saving lists is changed from save -> saveAll (related commit)
- elasticsearchRepository.save(results.getContent());
+ elasticsearchRepository.saveAll(results.getContent());

After those changes the backend works with JHipster 5 and Spring Boot 2

Frontend

  • Some files were moved from the shared folder to the core folder:
elasticsearch-reindex.route.ts
- import { UserRouteAccessService } from '../../shared';
+ import { UserRouteAccessService } from 'app/core';
  • JHipster's Angular Admin module is now lazy-loaded and it doesn't recognize the elasticsearch-reindex route, not sure how to fix this, but it probably requires changes toelasticsearch-reindex.route.ts
  • New JHipster React frontend option, I can help with this part if you want

ruddell avatar Apr 08 '18 19:04 ruddell

Thanks a lot for the summary. Do you know if bullet point 1 affects the module at all?

geraldhumphries avatar Apr 08 '18 20:04 geraldhumphries

It doesn't affect the module at all, just a note for when you test

ruddell avatar Apr 08 '18 20:04 ruddell

Some changes in PR #47

FireWolf2007 avatar May 16 '18 12:05 FireWolf2007

Any update on this? +1 for React support:)

kenhuang avatar Jun 21 '18 11:06 kenhuang

@kenhuang REST API is ready, but I'm not ready write full React template. If you can provide example page for React and service layer same as angular or angularjs I'll try to implement it.

FireWolf2007 avatar Jun 21 '18 16:06 FireWolf2007

Hi, to fix the lazy-loaded problem, I made this 2 changes:

In file navbar.component.html:

- <a class="dropdown-item" routerLink="elasticsearch-reindex" routerLinkActive="active" (click)="collapseNavbar()">
- <fa-icon [icon]="'fw fa-search'" [fixedWidth]="true"></fa-icon>&nbsp;
+ <a class="dropdown-item" routerLink="admin/elasticsearch-reindex" routerLinkActive="active" (click)="collapseNavbar()">
+ <fa-icon [icon]="'search'" [fixedWidth]="true"></fa-icon>&nbsp;

In file elasticsearch-reindex.module.ts

-        RouterModule.forRoot(ADMIN_ROUTES, { useHash: true })
+        RouterModule.forChild(ADMIN_ROUTES)

I attach the patch files.

patchs.tar.gz

eforza avatar Jul 18 '18 16:07 eforza

Any progress on this? Looks like there are other changes needed for JH 5.7.2

adnansenyurt avatar Jan 03 '19 21:01 adnansenyurt

For Jhipster 5.7.2:

In ElasticsearchIndexService.java :

  -   private final ElasticsearchTemplate elasticsearchTemplate


  -    TransactionStatusSearchRepository transactionStatusSearchRepository,
  -    ElasticsearchTemplate elasticsearchTemplate)  
  +   TransactionStatusSearchRepository transactionStatusSearchRepository)     


  -  this.elasticsearchTemplate = elasticsearchTemplate;


 -    elasticsearchTemplate.deleteIndex(entityClass);
 -     try {
 -         elasticsearchTemplate.createIndex(entityClass);
 -     } catch (ResourceAlreadyExistsException e) {
 -         // Do nothing. Index was already concurrently recreated by some other service.
 -     }
 -     elasticsearchTemplate.putMapping(entityClass);

In elasticsearch-reindex.module.ts :

   -   RouterModule.forChild(ADMIN_ROUTES)
   +  RouterModule.forChild(ADMIN_ROUTES)

merymer avatar Apr 17 '19 09:04 merymer

For Jhipster 5.7.2:

In ElasticsearchIndexService.java :

  -   private final ElasticsearchTemplate elasticsearchTemplate


  -    TransactionStatusSearchRepository transactionStatusSearchRepository,
  -    ElasticsearchTemplate elasticsearchTemplate)  
  +   TransactionStatusSearchRepository transactionStatusSearchRepository)     


  -  this.elasticsearchTemplate = elasticsearchTemplate;


 -    elasticsearchTemplate.deleteIndex(entityClass);
 -     try {
 -         elasticsearchTemplate.createIndex(entityClass);
 -     } catch (ResourceAlreadyExistsException e) {
 -         // Do nothing. Index was already concurrently recreated by some other service.
 -     }
 -     elasticsearchTemplate.putMapping(entityClass);

In elasticsearch-reindex.module.ts :

   -   RouterModule.forChild(ADMIN_ROUTES)
   +  RouterModule.forChild(ADMIN_ROUTES)

It worked! thanks a lot

adnansenyurt avatar Apr 17 '19 19:04 adnansenyurt

Hi all,

I did the above and it is working now for me. The problem I have now is that with removing the elasticsearchTemplate I removed also the delete/create index.

This means that I am left with orphan entries in elasticsearch indexes in some cases.

Any idea how to delete/create again the indexes?

Thank you.

lukianab avatar Apr 23 '19 19:04 lukianab

I'm getting the following compilation error. ElasticsearchIndexService.java:[107,32] cannot access com.sun.beans.introspect.PropertyInfo [ERROR] class file for com.sun.beans.introspect.PropertyInfo not found workaround here https://bugs.openjdk.java.net/browse/JDK-8212636

dean0bambin0 avatar Aug 29 '19 23:08 dean0bambin0

In elasticsearch-reindex.module.ts :

what is the change in In elasticsearch-reindex.module.ts ?

extraclassi avatar Nov 06 '20 11:11 extraclassi

The main changes that impact this module are:

Backend

  • Elasticsearch removed the embedded option, so you have to run an instance locally in dev.
  • Elasticsearch deprecated IndexAlreadyExistsException for ResourceAlreadyExistsException (release notes)
- import org.elasticsearch.indices.IndexAlreadyExistsException;
+ import org.elasticsearch.ResourceAlreadyExistsException;

-        } catch (IndexAlreadyExistsException e) {
+        } catch (ResourceAlreadyExistsException e) {
  • Spring Data changed method signatures for CrudRepository, saving lists is changed from save -> saveAll (related commit)
- elasticsearchRepository.save(results.getContent());
+ elasticsearchRepository.saveAll(results.getContent());

After those changes the backend works with JHipster 5 and Spring Boot 2

Frontend

  • Some files were moved from the shared folder to the core folder:
elasticsearch-reindex.route.ts
- import { UserRouteAccessService } from '../../shared';
+ import { UserRouteAccessService } from 'app/core';
  • JHipster's Angular Admin module is now lazy-loaded and it doesn't recognize the elasticsearch-reindex route, not sure how to fix this, but it probably requires changes toelasticsearch-reindex.route.ts
  • New JHipster React frontend option, I can help with this part if you want

Please how to use this module with React? I'm using JHipster 6.10.3

ArmelZy avatar Nov 26 '20 15:11 ArmelZy