Skip to content

Commit

Permalink
EPMRPP-96262 fixed filter_target query (#1043)
Browse files Browse the repository at this point in the history
* EPMRPP-96262 fixed filter_target query
  • Loading branch information
grabsefx authored Oct 17, 2024
1 parent e9efb6f commit 082d205
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,11 @@ protected void addFrom(SelectQuery<? extends Record> query) {

@Override
protected void joinTables(QuerySupplier query) {
query.addJoin(PROJECT_USER, JoinType.LEFT_OUTER_JOIN, USERS.ID.eq(PROJECT_USER.USER_ID));
query.addJoin(ORGANIZATION_USER, JoinType.LEFT_OUTER_JOIN, ORGANIZATION_USER.USER_ID.eq(USERS.ID));
query.addJoin(ORGANIZATION, JoinType.LEFT_OUTER_JOIN, ORGANIZATION.ID.eq(ORGANIZATION_USER.ORGANIZATION_ID));

query.addJoin(PROJECT_USER, JoinType.LEFT_OUTER_JOIN, ORGANIZATION_USER.USER_ID.eq(PROJECT_USER.USER_ID));
query.addJoin(PROJECT, JoinType.LEFT_OUTER_JOIN, PROJECT_USER.PROJECT_ID.eq(PROJECT.ID));
query.addJoin(ORGANIZATION, JoinType.LEFT_OUTER_JOIN, ORGANIZATION.ID.eq(PROJECT.ORGANIZATION_ID));
query.addJoin(ORGANIZATION_USER, JoinType.LEFT_OUTER_JOIN,
ORGANIZATION_USER.ORGANIZATION_ID.eq(PROJECT.ORGANIZATION_ID).and(USERS.ID.eq(ORGANIZATION_USER.USER_ID)));
}

@Override
Expand Down Expand Up @@ -1624,6 +1624,8 @@ public QuerySupplier getQuery() {
USERS.CREATED_AT,
USERS.UPDATED_AT,
USERS.FULL_NAME,
USERS.EXTERNAL_ID,
USERS.UUID,
ORGANIZATION_USER.ORGANIZATION_ROLE);
QuerySupplier querySupplier = new QuerySupplier(query);
joinTables(querySupplier);
Expand All @@ -1641,6 +1643,8 @@ protected Collection<? extends SelectField> selectFields() {
USERS.CREATED_AT,
USERS.UPDATED_AT,
USERS.FULL_NAME,
USERS.EXTERNAL_ID,
USERS.UUID,
ORGANIZATION_USER.ORGANIZATION_ROLE
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private OrganizationMapper() {
organizationUserProfile.setAuthProvider(UserType.valueOf(row.get(USERS.TYPE)));
organizationUserProfile.setEmail(row.get(USERS.EMAIL));

Optional.ofNullable(row.field(USERS.METADATA))
Optional.ofNullable(row.get(USERS.METADATA))
.ifPresent(meta -> {
// TODO: refactor after switching to jooq 3.19 with jsonb processing support
JSONObject json = new JSONObject(row.get(USERS.METADATA).data());
Expand All @@ -109,13 +109,13 @@ private OrganizationMapper() {

});

Optional.ofNullable(row.field(ORGANIZATION.EXTERNAL_ID))
Optional.ofNullable(row.get(USERS.EXTERNAL_ID))
.ifPresent(
extId -> organizationUserProfile.setExternalId(row.get(ORGANIZATION.EXTERNAL_ID)));
extId -> organizationUserProfile.setExternalId(row.get(USERS.EXTERNAL_ID)));

Optional.ofNullable(row.field(ORGANIZATION.EXTERNAL_ID))
Optional.ofNullable(row.get(USERS.UUID))
.ifPresent(
extId -> organizationUserProfile.setUuid(row.get(ORGANIZATION.EXTERNAL_ID, UUID.class)));
extId -> organizationUserProfile.setUuid(row.get(USERS.UUID, UUID.class)));

organizationUserProfile.setProjectCount(row.get(PROJECTS_QUANTITY, Integer.class));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private ResultFetchers() {
} else {
user = users.get(id);
}
if (ofNullable(row.field(PROJECT_USER.PROJECT_ROLE)).isPresent()) {
if (ofNullable(row.get(PROJECT_USER.PROJECT_ROLE)).isPresent()) {
boolean isProjectAdded = user.getProjects().stream()
.map(ProjectUser::getProject)
.map(Project::getKey)
Expand All @@ -308,7 +308,7 @@ private ResultFetchers() {
}
}

if (ofNullable(row.field(ORGANIZATION_USER.ORGANIZATION_ROLE)).isPresent()) {
if (ofNullable(row.get(ORGANIZATION_USER.ORGANIZATION_ROLE)).isPresent()) {
boolean isOrgAdded = user.getOrganizationUsers().stream()
.map(OrganizationUser::getOrganization)
.map(Organization::getId)
Expand Down Expand Up @@ -432,7 +432,7 @@ private ResultFetchers() {

rows.forEach(
row ->
ofNullable(row.field(ORGANIZATION_USER.ORGANIZATION_ID))
ofNullable(row.get(ORGANIZATION_USER.ORGANIZATION_ID))
.ifPresent(orgId -> {
String orgName = row.get(ORGANIZATION.NAME, String.class);

Expand Down

0 comments on commit 082d205

Please sign in to comment.