Skip to content

Commit

Permalink
Merge pull request #72 from Onlineberatung/DIAKONIE-352-merge-tenant-…
Browse files Browse the repository at this point in the history
…logic

chore: merge logic
  • Loading branch information
tkuzynow authored Jul 18, 2024
2 parents 185a5b6 + 9656891 commit 82ef075
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public class TenantUpdateService {

private static final int USER_PAGE_SIZE = 300;
private static final String TENANT_ID = "tenantId";
private static final String SUCCESSFULLY_SET_TENANT_ID_FOR_WITH_ID_TO = "Successfully set tenantId for {} with id {} to {}";
private static final String SUCCESSFULLY_SET_TENANT_ID_FOR_WITH_ID_TO =
"Successfully set tenantId for {} with id {} to {}";

private final KeycloakUserService keycloakUserService;

Expand Down Expand Up @@ -48,10 +49,7 @@ public void updateAdviceSeekersTenant(List<UserTenant> adviceSeekerToTargetTenan
adviceSeekerTenant.getTenantId());

keycloakUserService.updateUserCustomAttributeWithoutLogin(
TENANT_ID,
adviceSeekerTenant.getTenantId(),
adviceSeekerTenant.getUserId(),
httpHeaders);
TENANT_ID, adviceSeekerTenant.getTenantId(), adviceSeekerTenant.getUserId(), httpHeaders);

updateTables(adviceSeekerTenant);
log.info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void execute(Database database) {
var agencyServiceJdbcTemplate =
BeanAwareSpringLiquibase.getNamedBean("agencyServiceJdbcTemplate", JdbcTemplate.class);


this.keycloakLoginService =
BeanAwareSpringLiquibase.getNamedBean("keycloakLoginService", KeycloakLoginService.class);

Expand All @@ -57,7 +56,8 @@ public void execute(Database database) {
performMigrations(migrations, tenantMigrationService);
}

private void performMigrations(List<TenantMigrationConfiguration> migrations,
private void performMigrations(
List<TenantMigrationConfiguration> migrations,
TenantMigrationService tenantMigrationService) {
migrations.stream()
.forEach(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.vi.migrationtool.tenantservice;

import com.vi.migrationtool.keycloak.KeycloakUserService;
import com.vi.migrationtool.keycloak.TenantUpdateService;
import com.vi.migrationtool.keycloak.UserTenant;
import java.util.List;
Expand Down Expand Up @@ -51,7 +50,6 @@ private void updateAgencyServiceTenantId(TenantMigrationConfiguration migration)
migration.getSourceTenantId());

log.info(UPDATED + updatedRows + " rows in agency postcode range tables");

}

private void updateUserServiceTenantId(TenantMigrationConfiguration migration) {
Expand All @@ -68,8 +66,11 @@ private void deleteSourceTenant(TenantMigrationConfiguration migration) {

private void updateUsersInKeycloakAndDatabase(TenantMigrationConfiguration migration) {

log.info("Step: attempt to find and update adviceseekers in keycloak and database. "
+ SOURCE_TENANT_TARGET_TENANT, migration.getSourceTenantId(), migration.getTargetTenantId());
log.info(
"Step: attempt to find and update adviceseekers in keycloak and database. "
+ SOURCE_TENANT_TARGET_TENANT,
migration.getSourceTenantId(),
migration.getTargetTenantId());
List<UserTenant> adviceSeekerTargetTenants =
userServiceJdbcTemplate.query(
"select u.user_id \n"
Expand All @@ -83,9 +84,11 @@ private void updateUsersInKeycloakAndDatabase(TenantMigrationConfiguration migra

tenantUpdateService.updateAdviceSeekersTenant(adviceSeekerTargetTenants);


log.info("Step: attempt to find and update consultants in keycloak and database. "
+ SOURCE_TENANT_TARGET_TENANT, migration.getSourceTenantId(), migration.getTargetTenantId());
log.info(
"Step: attempt to find and update consultants in keycloak and database. "
+ SOURCE_TENANT_TARGET_TENANT,
migration.getSourceTenantId(),
migration.getTargetTenantId());
List<UserTenant> consultantTargetTenants =
userServiceJdbcTemplate.query(
"select consultant_id \n"
Expand All @@ -99,8 +102,11 @@ private void updateUsersInKeycloakAndDatabase(TenantMigrationConfiguration migra

tenantUpdateService.updateConsultantsTenant(consultantTargetTenants);

log.info("Step: attempt to find and update admins in keycloak and database. "
+ SOURCE_TENANT_TARGET_TENANT, migration.getSourceTenantId(), migration.getTargetTenantId());
log.info(
"Step: attempt to find and update admins in keycloak and database. "
+ SOURCE_TENANT_TARGET_TENANT,
migration.getSourceTenantId(),
migration.getTargetTenantId());
List<UserTenant> adminTargetTenants =
userServiceJdbcTemplate.query(
"select admin_id \n"
Expand Down

0 comments on commit 82ef075

Please sign in to comment.