generator-jhipster: import-jdl does not respect skipUserManagement cli params or jdl settings
Overview of the issue
The command stacktrace states that skipUserManagement can be used to enable relationships between a custom defined User entity and Company entity, however
JHipster jdl/import-jdl does not accept any form of the setting: neither the command line argument --skip-user-management, nor the alternative specifying // skip-user-management as first line of JDL file work.
According JHipster documentation --skip-user-management should be able to disable automatic generation of User and Authority entities so that those entities can be used in normal entity relationships.
INFO! Using JHipster version installed globally
INFO! Executing import-jdl test.jdl
INFO! The JDL is being parsed.
warn: In the One-to-Many relationship from Company to User, only bidirectionality is supported for a One-to-Many association. The other side will be automatically added.
Error: Relationships from the User entity is not supported in the declaration between 'User' and 'Company'. You can have this by using the 'skipUserManagement' option.
Error while parsing applications and entities from the JDL Error: Relationships from the User entity is not supported in the declaration between 'User' and 'Company'. You can have this by using the 'skipUserManagement' option.
Error: Relationships from the User entity is not supported in the declaration between 'User' and 'Company'. You can have this by using the 'skipUserManagement' option.
at checkForForbiddenUseOfUserAsSource (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/validators/relationship_validator.js:89:11)
at checkForInvalidUseOfTheUserEntity (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/validators/relationship_validator.js:83:3)
at RelationshipValidator.validate (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/validators/relationship_validator.js:37:5)
at /usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/validators/business_error_checker.js:158:17
at /usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/core/jdl_object.js:202:7
at /usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/core/jdl_relationships.js:90:7
at Array.forEach (<anonymous>)
at JDLRelationships.forEach (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/core/jdl_relationships.js:89:20)
at JDLObject.forEachRelationship (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/core/jdl_object.js:201:24)
at BusinessErrorChecker.checkForRelationshipErrors (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/validators/business_error_checker.js:157:20)
Error during import-jdl: Relationships from the User entity is not supported in the declaration between 'User' and 'Company'. You can have this by using the 'skipUserManagement' option.
Error: Relationships from the User entity is not supported in the declaration between 'User' and 'Company'. You can have this by using the 'skipUserManagement' option.
at checkForForbiddenUseOfUserAsSource (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/validators/relationship_validator.js:89:11)
at checkForInvalidUseOfTheUserEntity (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/validators/relationship_validator.js:83:3)
at RelationshipValidator.validate (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/validators/relationship_validator.js:37:5)
at /usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/validators/business_error_checker.js:158:17
at /usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/core/jdl_object.js:202:7
at /usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/core/jdl_relationships.js:90:7
at Array.forEach (<anonymous>)
at JDLRelationships.forEach (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/core/jdl_relationships.js:89:20)
at JDLObject.forEachRelationship (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/core/jdl_object.js:201:24)
at BusinessErrorChecker.checkForRelationshipErrors (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/node_modules/jhipster-core/lib/validators/business_error_checker.js:157:20)
Error: Error during import-jdl: Relationships from the User entity is not supported in the declaration between 'User' and 'Company'. You can have this by using the 'skipUserManagement' option.
at module.exports (/usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/cli/import-jdl.js:428:31)
at /usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/cli/jdl.js:93:51
at processTicksAndRejections (internal/process/task_queues.js:93:5)
I attempted to turn on debug logging level
DEBUG=generator-jhipster:* LOG_LEVEL=debug node --inspect /usr/local/Cellar/jhipster/6.10.1/libexec/lib/node_modules/generator-jhipster/cli/cli.js import-jdl test.jdl --skip-user-management --ignore-application
The command runs, but it does not change logging level… if someone could tell me the correct syntax, I would be happy to investigate it further to see if I can determine where the breakdown occurs.
Motivation for or Use Case
For the project I’m working on, I use OIDC/OAuth2 to handle user authentication and identity management, we still need a User representation within our database for data-ownership.
We need to be able to update entities and regenerate classes as the project evolves, currently this bug blocks us from being able to do that.
Reproduce the error
jhipster jdl test.jdl --skip-user-management
test.jdl is attached in JHipster configuration section
Related issues
Issue was first opened against JHipster core jhipster/jhipster-core#476, but it seems more suitable to be here as it may not be a problem with JHipster only rather how the classes are generated.
Suggest a Fix
Skip User Management doesn’t work through import jdl at all… Configuration is not being respected by lower level classes in generator-jhipster.
JHipster Version(s)
6.10.1
JHipster configuration
// skip-user-management
// application {
// config {
// packageName com.test.project.entities
// }
// entities *
// }
DEFAULT_MIN_LENGTH = 2
DEFAULT_MAX_LENGTH = 50
entity Company {
name String required unique minlength(DEFAULT_MIN_LENGTH)
abbreviation String required unique
config String required
entities String required
logo String
}
entity User {
name String required
email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
}
relationship OneToMany {
Company to User{company(name)}
}
relationship ManyToOne {
User to Company {user(name)}
}
Entity configuration(s) entityName.json files generated in the .jhipster directory
N/A
Browsers and Operating System
OSX 10.15
- Checking this box is mandatory (this is just to show you read everything)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (18 by maintainers)
Commits related to this issue
- Error msg -> skipUserManagement doesn't work for import - Fix for #12366 — committed to deftdawg/generator-jhipster by deftdawg 4 years ago
- JDL: fixed user management flag passing Removed the business error checker and split its previous role in two files: one for jdl objects with apps, one without. Copied the tests from the business err... — committed to MathieuAA/generator-jhipster by MathieuAA 4 years ago
- JDL: fixed user management flag passing Removed the business error checker and split its previous role in two files: one for jdl objects with apps, one without. Copied the tests from the business err... — committed to Tcharl/generator-jhipster by MathieuAA 4 years ago
Have you added
entities *?I am reopening since in my opinion there are some bugs here.
At current state custom User entity is completely broken using jdl. At least we should throw an error if entity User is found in the jdl.
It’s related to https://github.com/jhipster/jhipster-core/pull/278 and https://github.com/jhipster/generator-jhipster/issues/10425
Done.
I failed to provide a patch to fix this. Current jdl implementation is a black-box to me. So I will provide some findings here.
@MathieuAA should skipUserManagement be an unary option? There are reference to it, but the definition is missing: https://github.com/jhipster/generator-jhipster/blob/8a939555af2933247174b3c627d7409ac7327ee6/jdl/converters/json-to-jdl-option-converter.js#L22 https://github.com/jhipster/generator-jhipster/blob/8a939555af2933247174b3c627d7409ac7327ee6/jdl/readers/json-reader.js#L25 https://github.com/jhipster/generator-jhipster/blob/a7a6d20266d1a1e05d724158b2ced1872ba9eabb/jdl/jhipster/unary-options.js#L20-L27
There are some failures in tests: https://github.com/jhipster/generator-jhipster/blob/a7a6d20266d1a1e05d724158b2ced1872ba9eabb/test/jdl/converters/json-to-jdl-option-converter.spec.js#L45 should be
jdlObject = convertServerOptionsToJDL({ skipUserManagement: true });https://github.com/jhipster/generator-jhipster/blob/a7a6d20266d1a1e05d724158b2ced1872ba9eabb/test/jdl/converters/json-to-jdl-option-converter.spec.js#L49 should be
expect(jdlObject.getOptionsForName(SKIP_USER_MANAGEMENT)).not.to.be.empty;I have identified 3 cases that I think they are bugs:
and
This second example Company is generated with user relationship but User is missing.