-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authority relationship #11158
Authority relationship #11158
Conversation
37fc261
to
81781fb
Compare
hey @jhipster/developers I have finished (IMHO) this feature and I was testing it against this JDL:
and this works fine... So I wanted to add some meaningful test to cover it, and I'm struggling with the yeoman helper and asking for some hint to make this work: in describe('with authority as relationship', () => {
before(done => {
helpers
.run(require.resolve('../generators/entity'))
.inTmpDir(dir => {
fse.copySync(path.join(__dirname, '../test/templates/default-ng2'), dir);
})
.withArguments(['foo'])
.withPrompts({
fieldAdd: false,
relationshipAdd: true,
otherEntityName: 'authority',
relationshipName: 'authority',
relationshipType: 'many-to-one',
ownerSide: true,
otherEntityRelationshipName: 'foo',
otherEntityField: 'name'
})
.withPrompts({
relationshipAdd: false,
dto: 'no',
service: 'no',
pagination: 'no'
})
.on('end', done);
});
it('creates expected default files', () => {
assert.file(expectedFiles.server);
assert.file(expectedFiles.clientNg2);
assert.file(expectedFiles.gatling);
assert.file(expectedFiles.fakeData);
});
it('creates correct entity files for authority', () => {
// entity related files exist
assert.file(`${CLIENT_MAIN_SRC_DIR}app/entities/foo/foo.module.ts`);
assert.file(`${CLIENT_MAIN_SRC_DIR}app/entities/foo/foo.component.html`);
assert.file('.jhipster/Foo.json');
assert.fileContent('.jhipster/Foo.json', 'many-to-one');
assert.fileContent('.jhipster/Foo.json', {
relationships: [
{
relationshipType: 'many-to-one',
otherEntityName: 'authority',
otherEntityRelationshipName: 'foo',
relationshipName: 'authority',
otherEntityField: 'name'
}
]
});
assert.fileContent(
`${CLIENT_MAIN_SRC_DIR}app/entities/foo/foo.component.html`,
"<a [routerLink]=\"['/authority', foo.authority?.name, 'view']\" >{{ foo.authority?.name }}</a>"
);
});
}); I try to generate an entity with a relationship. From my dumb perspective, this should be the correct usage of Yeomans test helper to answer the prompts. However, this ends up with an entity without a relationship. What am I doing wrong here? |
push, I still need some help with the test, then this PR could be merged |
I'll try to see what's wrong this morning |
thanks... I dunno what's wrong with the usage of the helper...and it's quite complex because the relationship question is a repeating one....if that's not possible, I'll try to define a |
@xetys it may be easier indeed |
generators/client/templates/angular/src/main/webapp/app/core/user/user.model.ts.ejs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add authority to warning:
generator-jhipster/generators/entity/index.js
Lines 545 to 551 in bbff366
if (relationship.otherEntityName !== 'user') { | |
this.warning( | |
`otherEntityRelationshipName is missing in .jhipster/${entityName}.json for relationship ${JSON.stringify( | |
relationship, | |
null, | |
4 | |
)}, using ${_.lowerFirst(entityName)} as fallback` |
...ver/templates/src/main/resources/config/liquibase/changelog/added_entity_constraints.xml.ejs
Outdated
Show resolved
Hide resolved
...s/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs
Outdated
Show resolved
Hide resolved
...s/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs
Outdated
Show resolved
Hide resolved
generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs
Outdated
Show resolved
Hide resolved
@xetys FYI... this PR has conflicts that need to be resolved. |
and ensures using the correct fields in generated files fix jhipster#11062
for authority relationship
6b135b2
to
8bb37b1
Compare
@mraible thx...I didn't forget this one now I fixed the test as well, and all stuff mentioned in Review (hopefully) May this PR finally be closed 🙏 |
...t/templates/angular/src/main/webapp/app/entities/entity-management-detail.component.html.ejs
Outdated
Show resolved
Hide resolved
...ent/templates/angular/src/main/webapp/app/entities/entity-management-update.component.ts.ejs
Show resolved
Hide resolved
...y-client/templates/angular/src/main/webapp/app/entities/entity-management.component.html.ejs
Outdated
Show resolved
Hide resolved
...y-client/templates/angular/src/main/webapp/app/entities/entity-management.component.html.ejs
Outdated
Show resolved
Hide resolved
generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs
Outdated
Show resolved
Hide resolved
generators/entity-server/templates/src/main/java/package/service/EntityQueryService.java.ejs
Outdated
Show resolved
Hide resolved
generators/entity-server/templates/src/main/java/package/service/EntityQueryService.java.ejs
Outdated
Show resolved
Hide resolved
generators/entity-server/templates/src/main/java/package/service/dto/EntityCriteria.java.ejs
Outdated
Show resolved
Hide resolved
...ver/templates/src/main/resources/config/liquibase/changelog/added_entity_constraints.xml.ejs
Outdated
Show resolved
Hide resolved
Co-authored-by: Marcelo Shima <marceloshima@gmail.com>
generators/entity-server/templates/src/main/java/package/service/EntityQueryService.java.ejs
Outdated
Show resolved
Hide resolved
Co-authored-by: Marcelo Shima <marceloshima@gmail.com>
@xetys have you noticed the failures are related to your PR? |
Yeah, it's now related to react. As I have no react experience I'll need some time to figure out how to fix this. Shouldn't be too hard but I'll need a bit of time for this |
still failing because oauth2 is an edge case....I see this is one of the nastiest $100 bug bounties in history :D I'll try to fix that one today >.< |
I don’t think it is required, just throw an exception at the generator when you detect oauth2. |
The only way I could find is to duplicate the sqlfull
@xetys it will be hard to add oauth2 support? |
@xetys Is this something you're still interested in adding? If so, please fix conflicts. |
Closing because this PR is stale. |
Any news about this? Since #1995 has been closed, I'm thinking to create a custom Authority. If this PR is rejected, then obviously I could do everything manually, but ideally, I would like to design the whole domain with JDL |
Closing because this PR has become stale. Please re-open if you're able to rebase. |
enables relationships to 'Authority' in entity-server and ensures using the correct fields in generated files
fix #11062
Please make sure the below checklist is followed for Pull Requests.
All continuous integration tests are green
Tests are added where necessary
Documentation is added/updated where necessary
Coding Rules & Commit Guidelines as per our CONTRIBUTING.md document are followed