-
Notifications
You must be signed in to change notification settings - Fork 3
MODFQMMGR-746 Use mod-settings instead of mod-config for locale settings #1146
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
Changes from all commits
adacf62
ada725b
ada3fe6
ada3f38
ada649d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package org.folio.fqm.client; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import feign.FeignException; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.log4j.Log4j2; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.cloud.openfeign.FeignClient; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
|
|
||
| import java.time.DateTimeException; | ||
| import java.time.ZoneId; | ||
|
|
||
| /** | ||
| * Client for the /locale API. | ||
| * | ||
| * @implNote This is a separate class from the internal LocaleClientRaw interface because Feign clients must be interfaces, disallowing any injection. | ||
| */ | ||
| @Log4j2 | ||
| @Component | ||
| @RequiredArgsConstructor(onConstructor_ = @Autowired) | ||
| public class LocaleClient { | ||
|
|
||
| private final ObjectMapper objectMapper; | ||
| private final LocaleClientRaw underlyingClient; | ||
|
|
||
| /** | ||
| * Provides raw access to the /locale API. | ||
| */ | ||
| @FeignClient(name = "locale") | ||
| interface LocaleClientRaw { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same basic idea as with SettingsClient and SettingsClientRaw, except I hid the raw version inside this one, to keep things a little simpler |
||
| @GetMapping("/locale") | ||
| String getLocaleSettings(); | ||
| } | ||
|
|
||
| public record LocaleSettings( | ||
| String locale, | ||
| String currency, | ||
| String timezone, | ||
| String numberingSystem | ||
| ) { | ||
| public ZoneId getZoneId() { | ||
| try { | ||
| return ZoneId.of(timezone); | ||
| } catch (DateTimeException e) { | ||
| log.error("Invalid timezone '{}', defaulting to UTC.", timezone, e); | ||
| return ZoneId.of("UTC"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public LocaleSettings getLocaleSettings() { | ||
| try { | ||
| String response = underlyingClient.getLocaleSettings(); | ||
| return objectMapper.readValue(response, LocaleSettings.class); | ||
| } catch (JsonProcessingException | FeignException | NullPointerException e) { | ||
| log.error("Failed to retrieve locale information. Defaulting to en-US, USD, UTC, latn.", e); | ||
| return new LocaleSettings("en-US", "USD", "UTC", "latn"); | ||
| } | ||
| } | ||
| } | ||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package org.folio.fqm.migration.strategies.impl; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.UUID; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.log4j.Log4j2; | ||
| import org.folio.fqm.migration.strategies.AbstractSimpleMigrationStrategy; | ||
| import org.folio.fqm.migration.warnings.FieldWarningFactory; | ||
| import org.folio.fqm.migration.warnings.RemovedFieldWarning; | ||
|
|
||
| /** | ||
| * Version 24, migrates from simple_invoice to composite_invoice entity type. | ||
| * All fields from simple_invoice get "invoice." prepended to their names. | ||
| * The (now non-existent) bill_to field is specifically migrated to bill_to.address. | ||
| * For other composites containing simple_invoice, a warning is issued for bill_to references. | ||
| */ | ||
| @Log4j2 | ||
| @RequiredArgsConstructor | ||
| public class V24InvoiceSimpleToCompositeMigration extends AbstractSimpleMigrationStrategy { | ||
|
|
||
| private static final UUID SIMPLE_INVOICE_ID = UUID.fromString("4d626ce1-1880-48d2-9d4c-81667fdc5dbb"); | ||
| private static final UUID COMPOSITE_INVOICE_ID = UUID.fromString("5c4cb0c9-c8bf-4fe5-b844-4de90ca445dc"); | ||
| private static final UUID COMPOSITE_INVOICE_LINE_ID = UUID.fromString("a2ea9d7a-3ed3-41c7-9cdd-f433e029ea0f"); | ||
| private static final UUID COMPOSITE_ORDER_INVOICE_ANALYTICS_ID = UUID.fromString("f3ccbf49-8e3e-4f5c-a60e-04ad80543a4a"); | ||
| private static final UUID COMPOSITE_INVOICE_VOUCHER_LINE_LEDGER_FUND_ORG_ID = UUID.fromString("8ddd1e32-5c85-46ab-8bf3-1ec9a76c18cf"); | ||
| private static final UUID COMPOSITE_INVOICE_VOUCHER_LINE_ORG_ID = UUID.fromString("2028a343-5603-4e86-99d5-c7de322c1709"); | ||
|
|
||
| @Override | ||
| public String getMaximumApplicableVersion() { | ||
| return "24"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getLabel() { | ||
| return "V24 Invoice simple to composite migration"; | ||
| } | ||
|
|
||
| @Override | ||
| public Map<UUID, Map<String, FieldWarningFactory>> getFieldWarnings() { | ||
| FieldWarningFactory billToWarning = RemovedFieldWarning.withoutAlternative(); | ||
| return Map.of( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need all of these enumerated anymore! Take a look at the new overridable method in the migration docs; specify the composite entity IDs and source aliases and it'll auto-resolve any composite parent changes |
||
| COMPOSITE_INVOICE_LINE_ID, | ||
| Map.of("invoice.bill_to", billToWarning), | ||
| COMPOSITE_ORDER_INVOICE_ANALYTICS_ID, | ||
| Map.of("invoice.bill_to", billToWarning), | ||
| COMPOSITE_INVOICE_VOUCHER_LINE_LEDGER_FUND_ORG_ID, | ||
| Map.of("invoice.bill_to", billToWarning), | ||
| COMPOSITE_INVOICE_VOUCHER_LINE_ORG_ID, | ||
| Map.of("invoice.bill_to", billToWarning) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<UUID, UUID> getEntityTypeChanges() { | ||
| return Map.of(SIMPLE_INVOICE_ID, COMPOSITE_INVOICE_ID); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<UUID, Map<String, String>> getFieldChanges() { | ||
| return Map.of( | ||
| SIMPLE_INVOICE_ID, | ||
| Map.of( | ||
| "*", "invoice.%s", | ||
| "bill_to", "bill_to.address" | ||
| ) | ||
| ); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.