Skip to content

Commit

Permalink
Merge pull request #49 from virtualidentityag/develop
Browse files Browse the repository at this point in the history
merge to staging
  • Loading branch information
tkuzynow authored May 9, 2024
2 parents 127e15b + 2c46d6b commit da160b7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@Slf4j
public class MigrateConsultingTypeDescriptionToTopicMigrationTask extends MigrationTasks {

private static final String DE_JSON = "{ \"de\": \"";
private final JdbcTemplate consultingTypeServiceJdbcTemplate;
private final JdbcTemplate agencyServiceJdbcTemplate;
private final TopicGroupMigrationService topicGroupMigrationService;
Expand Down Expand Up @@ -65,17 +66,17 @@ private void batchInsertTopicsWithIdEqualToConsultingTypeId(
new Object[] {
ct.getId(),
ct.getTenantId(),
"{ \"de\": \"" + ct.getTitles().getShort() + "\"}",
"{ \"de\": \"" + ct.getDescription() + "\"}",
DE_JSON + ct.getTitles().getShort() + "\"}",
DE_JSON + ct.getDescription() + "\"}",
"ACTIVE",
formattedCurrentDateTime,
formattedCurrentDateTime,
ct.getTitles().getShort(),
null,
ct.getUrls() != null ? ct.getUrls().getRegistrationPostcodeFallbackUrl() : "",
ct.getSendFurtherStepsMessage(),
"{ \"de\": \"" + ct.getTitles().getShort() + "\"}",
"{ \"de\": \"" + ct.getTitles().getLong() + "\"}",
DE_JSON + ct.getTitles().getShort() + "\"}",
DE_JSON + ct.getTitles().getLong() + "\"}",
ct.getTitles().getWelcome(),
ct.getTitles().getRegistrationDropdown(),
ct.getSlug()
Expand All @@ -99,14 +100,14 @@ private void addTopicGroupIfNeeded(ConsultingTypeEntity consultingTypeEntity) {
topicGroups.forEach(
topicGroup ->
topicGroupMigrationService
.insertTopicGroupIfNotExists(convertToTranslateableJson(topicGroup))
.insertTopicGroupIfNotExistsOrReturnExistingTopicGroup(convertToTranslateableJson(topicGroup))
.ifPresent(
topicGroupId ->
topicGroupMigrationService.createTopicGroupRelationIfNotExists(
topicGroupId, consultingTypeEntity.getId())));
}

private String convertToTranslateableJson(String topicGroup) {
return "{ \"de\": \"" + topicGroup + "\"}";
return DE_JSON + topicGroup + "\"}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class TopicGroupMigrationService {
"INSERT INTO topic_group (id, name) VALUES (NEXT VALUE FOR sequence_topic_group, ?)";
private JdbcTemplate consultingTypeJdbcTemplate;

public Optional<Integer> insertTopicGroupIfNotExists(String groupName) {
public Optional<Integer> insertTopicGroupIfNotExistsOrReturnExistingTopicGroup(String groupName) {
if (groupName == null) {
log.info("Could not migrate topic with group null");
return Optional.empty();
Expand All @@ -34,7 +34,9 @@ public Optional<Integer> insertTopicGroupIfNotExists(String groupName) {
log.info("Topic group inserted: " + groupName);
return Optional.of(consultingTypeJdbcTemplate.queryForObject(idQuery, Integer.class));
} else {
return Optional.empty();
String sql = "SELECT topic_group_id FROM topic_group WHERE name = ?";
Integer id = consultingTypeJdbcTemplate.queryForObject(sql, Integer.class, groupName);
return Optional.of(id);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/migrations/master-digi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
<include file="migrations/changeset/0017_migrate_agency_default_counselling_relations/0017_migrate_agency_default_counselling_relations.xml"/>
<include file="migrations/changeset/0019_add_counselling_relation_release_toggle/0019_add_counselling_relation_release_toggle.xml"/>
<include file="migrations/changeset/0023_create_jitsi_technical_user/0023_create_jitsi_technical_user.xml"/>
<!-- <include file="migrations/changeset/0024_create_weblate_project/0024_create_weblate_project.xml"/>-->
<include file="migrations/changeset/0024_create_weblate_project/0024_create_weblate_project.xml"/>

</databaseChangeLog>

0 comments on commit da160b7

Please sign in to comment.