jhipster / jhipster-core

JHipster Domain Language, used by JHipster UML and JDL-Studio to generate entities
Apache License 2.0
346 stars 116 forks source link

Allows custom annotations for entities #349

Closed yelhouti closed 5 years ago

yelhouti commented 5 years ago

Removed checks for unknown options (kept them for built-in ones) Added related tests had to change how option useJPADerivedIdentifier is used internally, in the JDL it's just: jpaDerivedIdentifier which is a PITA. one of these should be deprecated, once json files are removed and we keep only JDL, remove all references of: useJPADerivedIdentifier

Fix #320

Please make sure the below checklist is followed for Pull Requests.

MathieuAA commented 5 years ago

What happened to the package-lock.json file? :)

MathieuAA commented 5 years ago

You forgot to export them in the JSON files, for that I suggest having something like that:

{
  "blueprintOptions": {
    "blueprintName": {
      "theAnswer": 42
    }
}

Why the blueprintName? because there could be more than one enabled blueprint in one project.

yelhouti commented 5 years ago

What happened to the package-lock.json file? :)

nothing on purpose XD

You forgot to export them in the JSON files, for that I suggest having something like that:

@MathieuAA Indeed I when I tried to use it with the generator this afternoon, I couldn't they don't get exported. working on it. I wouldn't even tell the blueprint, they can use whatever they want, I'll just add it like this:

{
    "name": "Customer",
    "fields": [
        {
            "fieldName": "name",
            "fieldType": "String",
            "fieldValidateRules": [
                "required"
            ],
            "id": true
        },
    ],
    "relationships": [
        {
            "relationshipType": "one-to-many",
            "otherEntityName": "task",
            "otherEntityRelationshipName": "customer",
            "relationshipName": "task",
            "id": true
        }
    ],
...
}
....

for a jdl like this:

entity Customer {
    @id
    name String required
}

relationship OneToMany {
    @id 
    Customer{task} to Task{customer(name) required}
}
...

@MathieuAA and BIG thank you for making multiple blueprints a thing, was going to be my next thing to do

EDIT: I guess I won't be able to store id next to the other options as doing so would make it VERY ugly to reconstruct jdl/jdl_entity... from the .json file, I will settle for "options": ["id": true]

yelhouti commented 5 years ago

@MathieuAA annotations today are suppose to be before the javadoc, do you mind me moving them after this is a BREAKING CHANGE

yelhouti commented 5 years ago

@MathieuAA you can review and merge if you have time, thanks a lot :)

deepu105 commented 5 years ago

Please don't introduce breaking changes. As we can't make a major release for generator

On Tue, 16 Jul 2019, 5:24 am yelhouti, notifications@github.com wrote:

@MathieuAA https://github.com/MathieuAA you can review and merge if you have time, thanks a lot :)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jhipster/jhipster-core/pull/349?email_source=notifications&email_token=AAIOKFZRFLRXSPIZBTPYWA3P7U5P5A5CNFSM4IDOYJ4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ7SOPA#issuecomment-511649596, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIOKF5WK2KEQ7DZJL7OYSDP7U5P5ANCNFSM4IDOYJ4A .

yelhouti commented 5 years ago

thanks for your ansewer @deepu105 , glad I didn't, maybe we can keep switching comments and annotations for another PR, if you (all of you) are ok with it.

MathieuAA commented 5 years ago

@yelhouti there's just one pending comment, and the jdl-core.min.js that needs an update

yelhouti commented 5 years ago

IMO this file should not even be versioned, it changes on each compilation, but I can recompile whenever you are ready

MathieuAA commented 5 years ago

It changes if the grammar changes, and is needed for web projects that depend on JCore (the JDL studio). If you think of a better workflow, I'd be more than happy to hear it!!

yelhouti commented 5 years ago

other porject having jdl-core as a dependency should be enough no?

MathieuAA commented 5 years ago

How so? I don't get your question

yelhouti commented 5 years ago

How so? I don't get your question

gitter?

MathieuAA commented 5 years ago

yep

murdos commented 5 years ago

Awesome!!! 👍 Thanks @yelhouti

clementdessoude commented 5 years ago

This seems really cool ! Would it be possible to update the docs to explain what can be done, and how to use this ?

yelhouti commented 5 years ago

@murdos my pleasure @clement26695 as soon as it is released, this mainly useful for blueprints, in my use case I used it for composite ids: https://www.npmjs.com/package/generator-jhipster-composite-key-server https://www.npmjs.com/package/generator-jhipster-primeng-blueprint