From 085335bca5437dfb5750ea95490464a98ec057c9 Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Thu, 24 Aug 2023 16:42:40 +0200 Subject: [PATCH 1/8] pom: Bump version to 1.10.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 99c1a8b..290ab14 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ eu.europa.ted.eforms eforms-sdk-analyzer - 1.9.0-SNAPSHOT + 1.10.0-SNAPSHOT kjar eforms-sdk-analyzer From 052d04e2d9708f8e3983a88df0515dbf2d8f8264 Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Fri, 6 Oct 2023 11:23:59 +0200 Subject: [PATCH 2/8] Load and use the new translations index file (TEDEFO-2706) Instead of loading all XML files, load the translations.json, and then load the files listed there. Adapt test data to add translations.json everywhere it is needed. --- .../ted/eforms/sdk/analysis/FactsLoader.java | 13 +- .../ted/eforms/sdk/analysis/SdkLoader.java | 43 ++++--- .../analysis/domain/{ => label}/Label.java | 2 +- .../domain/label/LanguageFileInfo.java | 25 ++++ .../domain/label/TranslationLanguage.java | 46 +++++++ .../domain/label/TranslationsIndex.java | 21 ++++ .../eforms/sdk/analysis/fact/LabelFact.java | 2 +- .../analysis/fact/TranslationsIndexFact.java | 28 +++++ .../sdk/analysis/validator/TextValidator.java | 2 +- .../invalid/translations/translations.json | 105 ++++++++++++++++ .../valid/translations/translations.json | 105 ++++++++++++++++ .../invalid/translations/translations.json | 105 ++++++++++++++++ .../valid/translations/translations.json | 105 ++++++++++++++++ .../invalid/translations/translations.json | 105 ++++++++++++++++ .../valid/translations/translations.json | 105 ++++++++++++++++ .../invalid/translations/translations.json | 110 +++++++++++++++++ .../valid/translations/translations.json | 115 ++++++++++++++++++ .../invalid/translations/translations.json | 115 ++++++++++++++++++ .../valid/translations/translations.json | 115 ++++++++++++++++++ .../invalid/translations/translations.json | 105 ++++++++++++++++ .../valid/translations/translations.json | 105 ++++++++++++++++ 21 files changed, 1454 insertions(+), 23 deletions(-) rename src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/{ => label}/Label.java (93%) create mode 100644 src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/label/LanguageFileInfo.java create mode 100644 src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/label/TranslationLanguage.java create mode 100644 src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/label/TranslationsIndex.java create mode 100644 src/main/java/eu/europa/ted/eforms/sdk/analysis/fact/TranslationsIndexFact.java create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1395/invalid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1395/valid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1795/invalid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1795/valid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1810/invalid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1810/valid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1815/invalid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1815/valid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1819/invalid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1819/valid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1871/invalid/translations/translations.json create mode 100644 src/test/resources/eforms-sdk-tests/tedefo-1871/valid/translations/translations.json diff --git a/src/main/java/eu/europa/ted/eforms/sdk/analysis/FactsLoader.java b/src/main/java/eu/europa/ted/eforms/sdk/analysis/FactsLoader.java index 9b2092a..9a1d1a9 100644 --- a/src/main/java/eu/europa/ted/eforms/sdk/analysis/FactsLoader.java +++ b/src/main/java/eu/europa/ted/eforms/sdk/analysis/FactsLoader.java @@ -11,12 +11,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; -import eu.europa.ted.eforms.sdk.analysis.domain.Label; + import eu.europa.ted.eforms.sdk.analysis.domain.SvrlReport; import eu.europa.ted.eforms.sdk.analysis.domain.XmlNotice; import eu.europa.ted.eforms.sdk.analysis.domain.codelist.Codelist; import eu.europa.ted.eforms.sdk.analysis.domain.field.Field; import eu.europa.ted.eforms.sdk.analysis.domain.field.XmlStructureNode; +import eu.europa.ted.eforms.sdk.analysis.domain.label.Label; import eu.europa.ted.eforms.sdk.analysis.domain.noticetype.DocumentType; import eu.europa.ted.eforms.sdk.analysis.domain.noticetype.NoticeType; import eu.europa.ted.eforms.sdk.analysis.domain.view.index.TedefoViewTemplateIndex; @@ -31,6 +32,7 @@ import eu.europa.ted.eforms.sdk.analysis.fact.NoticeTypeFact; import eu.europa.ted.eforms.sdk.analysis.fact.NoticeTypesIndexFact; import eu.europa.ted.eforms.sdk.analysis.fact.SvrlReportFact; +import eu.europa.ted.eforms.sdk.analysis.fact.TranslationsIndexFact; import eu.europa.ted.eforms.sdk.analysis.fact.ViewTemplateFact; import eu.europa.ted.eforms.sdk.analysis.fact.XmlNoticeFact; @@ -98,6 +100,15 @@ public DataStore loadNoticeTypesIndex() throws IOException return datastore; } + public DataStore loadTranslationsIndex() throws IOException { + logger.debug("Creating facts datastore for translations index"); + + final DataStore datastore = DataSource.createStore(); + datastore.add(new TranslationsIndexFact(sdkLoader.getTranslationsIndex())); + + return datastore; + } + public DataStore loadLabels() throws IOException, JAXBException, SAXException, ParserConfigurationException { logger.debug("Creating facts datastore for labels"); diff --git a/src/main/java/eu/europa/ted/eforms/sdk/analysis/SdkLoader.java b/src/main/java/eu/europa/ted/eforms/sdk/analysis/SdkLoader.java index 5210fe7..bc5ada3 100644 --- a/src/main/java/eu/europa/ted/eforms/sdk/analysis/SdkLoader.java +++ b/src/main/java/eu/europa/ted/eforms/sdk/analysis/SdkLoader.java @@ -27,7 +27,6 @@ import com.fasterxml.jackson.databind.SerializationFeature; import eu.europa.ted.eforms.sdk.SdkConstants.SdkResource; import eu.europa.ted.eforms.sdk.analysis.domain.EFormsTrackableEntity; -import eu.europa.ted.eforms.sdk.analysis.domain.Label; import eu.europa.ted.eforms.sdk.analysis.domain.SvrlReport; import eu.europa.ted.eforms.sdk.analysis.domain.XmlNotice; import eu.europa.ted.eforms.sdk.analysis.domain.codelist.Codelist; @@ -36,6 +35,9 @@ import eu.europa.ted.eforms.sdk.analysis.domain.field.Field; import eu.europa.ted.eforms.sdk.analysis.domain.field.FieldsAndNodes; import eu.europa.ted.eforms.sdk.analysis.domain.field.XmlStructureNode; +import eu.europa.ted.eforms.sdk.analysis.domain.label.Label; +import eu.europa.ted.eforms.sdk.analysis.domain.label.LanguageFileInfo; +import eu.europa.ted.eforms.sdk.analysis.domain.label.TranslationsIndex; import eu.europa.ted.eforms.sdk.analysis.domain.noticetype.NoticeSubTypeForIndex; import eu.europa.ted.eforms.sdk.analysis.domain.noticetype.NoticeType; import eu.europa.ted.eforms.sdk.analysis.domain.noticetype.NoticeTypeSdk; @@ -57,6 +59,9 @@ public class SdkLoader { public static final Path EXAMPLE_NOTICES = Path.of("examples", "notices"); public static final Path EXAMPLE_REPORTS = Path.of("examples", "reports"); + // TODO: Use constant from SdkResource in ECL when it is available (TEDEFO-2707) + public static final Path TRANSLATIONS_JSON = Path.of("translations", "translations.json"); + private final Path sdkRoot; private final ObjectMapper objectMapper; @@ -176,33 +181,33 @@ public NoticeTypeSdk getNoticeTypeSdk(String noticeId, Path sdkRoot) throws IOEx SdkResource.NOTICE_TYPES.getPath().toString(), MessageFormat.format("{0}.json", noticeId))); } + public TranslationsIndex getTranslationsIndex() throws IOException { + return loadJsonFile(TranslationsIndex.class, + Path.of(sdkRoot.toString(), TRANSLATIONS_JSON.toString())); + } + public Set