jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.46k stars 4.02k forks source link

JHC - DevXP - Spike - generate entity.json patch instead of erasing the whole json #12417

Closed Tcharl closed 2 years ago

Tcharl commented 4 years ago
Overview of the feature request

We may be inspired by framework we're using in our generated code, for example liquibase in this particular case. Generating patch (commitid-entityname.json or timestamp-entityname.json) could bring some new cool capabilities to our end users

Motivation for or Use Case

What do you think about it?

pascalgrimaud commented 4 years ago

Not sure to understand well this ticket. It's probably related to what @mshima has already done with liquibase ?

Tcharl commented 4 years ago

Hi @pascalgrimaud , sorry for not being clear enough, let me take a concrete example so that it will illustrate what I have in mind.

In a first round, the end user will define a simple (sprint 0) jdl entity:

entity Article {
name String
}

Instead of generating an article.json in the .jhipster folder of a project, it would generate a <timetamp>-article.json file with the exact following content:

{
  "name": "Article",
  "action": "add"
  "fields": [
    {
      "fieldName": "title",
      "fieldType": "String",
      "action": "add"
    }]
 }

Then, in a second time, the user will improve his entity model, for example adding a new field:

entity Article {
name String
description String
}

While reimporting, instead of erasing the article.json file, it would generate another <timetamp2>-article.json file containing only the patch compared to the first generation

{
  "name": "Article",
  "action": "modify"
  "fields": [
    {
      "fieldName": "description",
      "fieldType": "String",
      "action": "add"
    }]
 }

Are the benefits expressed in the "motivation" section of the ticket now more clear?

pascalgrimaud commented 4 years ago

Ok I understand the feature, thanks.

Now, my next question is:

It there a specific usecase which is important for having this, for our end-users ?

My workflow on real JHipster projects:

In my workflow, I don't look into entity.json, having 1 or more, doesn't impact my work, but I'd like to understand the value of having xxxx-entity.json ?

Tcharl commented 4 years ago

Let me try to describe the potential value brought by this approach.

I use the exact same workflow as you hopefully, but I'm sometimes struggling with this, here are my pain points:

Sometimes, I added some 'hand crafted' logic on the generated entities. Concrete examples I've currently:

  1. added an @Field(type = FieldType.Keyword)on some of my entity's attributes, a @Secured(roleAllowed=...) on some serviceImpl, a specific @Setting on some entities, or even some inheritance on my entities (it's a 3 million-line microservice project, so there are for sure some edge cases).
  2. sometimes I do not want entities and only dto (a client serviceImpl calling another microservice Resource endpoint)
  3. I also overloaded some Mappers (adding some AfterMapping steps) so I should reference the overloaded versions in my serviceImpl instead of the generated one (otherwise Injection tells me that there are two candidate beans for injection).
  4. some angular entity-route.ts file that I tweeked manually, for example modifying for example the 'authorities'
  5. And finally, as I'm overload some serviceImpl methods using side-by-side pattern, I have tweaked some Integration test so that they are compatible with my custom business logic.

So usually, I unfortunately do a compare and cherry pick the regenerated changes at your step 2 instead of blindly accepting what jhipster regenerated for me: so loss of time, no really confident to deliver what has been modified and finally a not that enjoyable jhipster experience. However it works and jhipster fill my need: free stack update is a breeze so I'm really happy to be a hipster.

Pro-tip: I found another way process to mitigate that pain points for the second step:

Now, let see how patches could resolve or mitigate my pain points:

mshima commented 4 years ago

Ok then.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted. We are accepting PRs :smiley:. Comment or this will be closed in 7 days