generator-jhipster
generator-jhipster copied to clipboard
Enhance JDL to include built-in entities like User & Authority
Overview of the feature request
This is a feature request to allow the blue prints to have built in entities like User & Authority. In our use-case we are building a blueprint to generate a 'Questioner application' (like surveyMonkey). As part of the core framework of the application we need to create built in entities like User & Authority and let our users define relationship with those built in entities.
We are able to problematically create those built in entities (following the same logic as in the User - generators/bootstrap/index.js -> _createUserManagementEntities()) and are able to statically generate them in the server/client sub-generator.
When we try to model a relationship with these built-in entities (like we do with User), we are getting a validation error @jdl-with-application-validators.js->checkForAbsentEntities().
Currently there is no way to add an external exclusion for this check. It would be nice to have a method chained into the validator that could look at some external property for exclusions
modified sudo-code
if (!doesEntityExist(jdlRelationship.to) && (!isUserManagementEntity(jdlRelationship.to) || skippedUserManagementOption)
&& isSkippedByBlueprint(jdlRelationship.to)) {
absentEntities.push(jdlRelationship.to);
}
But I am not really sure how to get a Blueprint's entity skip configuration at this point coz this JDL parsing and validation happens earlier than the Blueprints lifecycle start (at least that's my understanding)
I know its more than just adding a validation exclusion to JDL parsing, I can contribute to this enhancement with some help from the team.
Motivation for or Use Case
With this feature blueprints can introduce their own built-in entities and be able to generate sophisticated applications
Related issues or PR
- [X] Checking this box is mandatory (this is just to show you read everything)
Currently I am loading my built-in entity(s) in the blueprint's app sub-generator (as this is the earliest in the run-queue that I can load from) and while writing mocha unit tests for the entity sub-generator (testing relationship with built-in entities) I realized that I cannot write tests targeting just the entity sub-generator as the built-in entities are loaded in the app sub-gen and so unfortunately I am forced to create tests including the app sub-gen.
jhipster's built-in entities are loaded from the bootstrap sub-gen that is auto composed from the baseGenerator and cannot be extended inside a blueprint.
This enhancement should also provide a spot (similar to bootstrap) for blueprints to load their built-in entities.
@dwarakaprasad Does local blueprint support solve this issue for you?
@dwarakaprasad Does local blueprint support solve this issue for you?
Thankyou @mraible for the response. I don't think the local blueprint would solve this issue.
The Current JDL feature does not support new configs defined by the blueprints i.e. lets say a blueprint introduces a new prompt called socialMediaLink that will be used in the template. The JDL parsing would fail if I add this socialMediaLink to the config section. So, unfortunately I will have to use a combination of .yo-rc.json & JDL to re-generate a project.
This is also required in my opinion to make blueprints independent and sophisticated.
Having spent sometime with this, it looks like a lot has to be changed. Like I said earlier, I am interested in contributing for this with some help.
We now require the following syntax for built in entities:
relationship OneToOne {
Foo to Bar with builtInEntity
}
The status for custom built in entities is unknown, may require adjusts to validations. Closing, please open a new issue if custom built in entities is not allowed.