Closed michelfigueiredojava closed 8 months ago
Not sure, but IT passed https://github.com/mshima/generator-jhipster-tenantview/blob/master/.github/workflows/integration.yml.
It uses jhipster import-jdl *.jdl --blueprints tenantview --relation-tenant-aware --tenant-name Company
I am pretty focused at jhipster 7 now, not sure when I will have time to look at this.
Thank you Marcelo. I've generated the project with that command line, it worked without any error message. But in a quick test on which I logged in as company_admin, I can see all bank accounts, not just the bank account of that user's company.
I can see BankAccountAspect is there and there is a method to filter it properly, sounds like it is not even called.
Maybe I am using a wrong version of the blueprint ? But I remember I installed 1.0.0.
Another strange thing is that the following code was generated commented out in class UserAspect:
/**
* Run method if User service getUserWithAuthorities is hit.
* Adds filtering to prevent display of information from another tenant
*/
/*
@Before(value = "execution(* io.github.jhipster.sample.service.UserService.getUserWithAuthorities(..)) && args(id, ..)")
public void onGetUserWithAuthorities(JoinPoint joinPoint, Long id) throws Exception {
Optional<String> currentLogin = SecurityUtils.getCurrentUserLogin();
if(currentLogin.isPresent()) {
User loggedInUser = userRepository.findOneByLogin(currentLogin.get()).get();
if (loggedInUser.getCompany() != null) {
User user = userRepository.findOneWithAuthoritiesById(id).get();
if(!user.getCompany().equals(loggedInUser.getCompany())){
throw new NoSuchElementException();
}
}
}
}
*/
Excelente work, congratulations. I managed to make it work, but it is not working anymore, I am trying to find out what I am doing wrong.
Jhipster 6.9.0.
I downloaded your example "https://raw.githubusercontent.com/mshima/generator-jhipster-tenantview/master/test-integration/samples/jdl-definition/app.jdl"
Then I generated the project with:
jhipster --blueprints tenantview import-jdl -f ./app.jdl
However, the class User doesn't have any relationship with Company, it means the tenancy logic was not applied. So I executed just the blueprint with:
jhipster --blueprints tenantview
Then I can see the expected relationship was created in User.java:
@ManyToOne @JsonIgnoreProperties("users") private Company company;
However, now the project is broken, with the following errors:
[INFO] ERROR Failed to compile with 1 errors22:08:37 [INFO] [INFO] error [INFO] [INFO] src/main/webapp/app/core/user/user.model.ts:1:25 - error TS2307: Cannot find module '../../shared/admin/company.model'. [INFO] [INFO] 1 import { Company } from '../../shared/admin/company.model'; [INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [INFO] src/main/webapp/app/admin/user-management/user-management-update.component.ts:10:26 - error TS2307: Cannot find module '../../shared/admin/company.model'. [INFO] [INFO] 10 import { ICompany } from '../../shared/admin/company.model'; [INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [INFO] src/main/webapp/app/admin/user-management/user-management-update.component.ts:11:32 - error TS2307: Cannot find module '../../admin/company/company.service'. [INFO] [INFO] 11 import { CompanyService } from '../../admin/company/company.service'; [INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [INFO] [INFO] [INFO] 5 modules [INFO] [INFO] ERROR in src/main/webapp/app/core/user/user.model.ts:1:25 - error TS2307: Cannot find module '../../shared/admin/company.model'. [INFO] [INFO] 1 import { Company } from '../../shared/admin/company.model'; [INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [INFO] src/main/webapp/app/admin/user-management/user-management-update.component.ts:10:26 - error TS2307: Cannot find module '../../shared/admin/company.model'. [INFO] [INFO] 10 import { ICompany } from '../../shared/admin/company.model'; [INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [INFO] src/main/webapp/app/admin/user-management/user-management-update.component.ts:11:32 - error TS2307: Cannot find module '../../admin/company/company.service'. [INFO] [INFO] 11 import { CompanyService } from '../../admin/company/company.service';
Btw, have you ever tried to combine your blueprint with this one https://www.jhipster.tech/modules/marketplace/#/details/generator-jhipster-primeng-blueprint ?