diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d964a08..dad947d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,7 +28,7 @@ jobs: with: java-version: '11' distribution: 'adopt' - server-id: ossrh + server-id: central server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD - name: Publish to the Maven Central Repository diff --git a/pom.xml b/pom.xml index 86038dd..9ba78f1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ eu.europa.ted.eforms eforms-sdk-analyzer - 1.13.1 + 1.14.0 kjar eForms SDK Analyzer @@ -36,22 +36,9 @@ https://github.com/OP-TED/eforms-sdk-analyzer - - - ossrh - https://${sonatype.server.url}/content/repositories/snapshots - - - ossrh - https://${sonatype.server.url}/service/local/staging/deploy/maven2/ - - - UTF-8 - 2025-03-03T15:39:33Z - - s01.oss.sonatype.org + 2025-11-28T08:07:06Z 11 @@ -64,16 +51,16 @@ 4.4 - 3.12.0 + 3.19.0 7.11.1 8.44.2.Final 3.0.11 - 2.14.1 + 2.19.0 4.0.0 4.0.4 1.37 5.9.2 - 1.4.14 + 1.5.21 3.9.1 4.6.3 8.0.3 @@ -89,7 +76,7 @@ 3.10.0 3.3.1 3.2.5 - 1.6.14 + 0.8.0 @@ -399,9 +386,9 @@ - oss-snapshots - OSS Snapshots repository - https://s01.oss.sonatype.org/content/repositories/snapshots + central-snapshots + Central Snapshots repository + https://central.sonatype.com/repository/maven-snapshots false @@ -453,9 +440,9 @@ ${version.drools} - org.sonatype.plugins - nexus-staging-maven-plugin - ${version.nexus-staging.plugin} + org.sonatype.central + central-publishing-maven-plugin + ${version.central-publishing.plugin} @@ -593,16 +580,15 @@ - - org.sonatype.plugins - nexus-staging-maven-plugin - true - - ossrh - https://${sonatype.server.url}/ - true - - + + org.sonatype.central + central-publishing-maven-plugin + true + + central + true + + 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 6b185d1..146b44b 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 @@ -37,6 +37,7 @@ 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.ViewTemplatesIndexFact; import eu.europa.ted.eforms.sdk.analysis.fact.XmlNoticeFact; public class FactsLoader { @@ -147,6 +148,17 @@ public DataStore loadViewTemplates() throws IOException { return datastore; } + public DataStore loadViewTemplatesIndex() throws IOException { + logger.debug("Creating facts datastore for view templates index"); + + TedefoViewTemplatesIndex viewTemplatesIndex = sdkLoader.getViewTemplatesIndex(); + + final DataStore datastore = DataSource.createStore(); + datastore.add(new ViewTemplatesIndexFact(viewTemplatesIndex)); + + return datastore; + } + public DataStore loadDocumentTypes() throws IOException { logger.debug("Creating facts datastore for document types"); diff --git a/src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/field/Field.java b/src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/field/Field.java index b4271f1..ed854e2 100644 --- a/src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/field/Field.java +++ b/src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/field/Field.java @@ -23,7 +23,7 @@ "attributeName", "attributeOf", "attributes", "presetValue", "businessEntityId", "idSchemes", "idScheme", "schemeName", "referencedBusinessEntityIds", "legalType", "maxLength", "description", - "privacy", "repeatable", "forbidden", "mandatory", "pattern", "rangeNumeric", "codeList", + "privacy", "repeatable", "forbidden", "mandatory", "pattern", "numericRange", "codeList", "inChangeNotice", "inContinueProcedure", "assert"}) public class Field implements Serializable { private static final long serialVersionUID = -1387933500392516298L; @@ -68,7 +68,7 @@ public class Field implements Serializable { private BooleanProperty mandatory; private StringProperty pattern; - private RangeNumericProperty rangeNumeric; + private RangeNumericProperty numericRange; private CodeListProperty codeList; private ChangeableOrCpProperty inChangeNotice; @@ -181,8 +181,8 @@ public StringProperty getPattern() { return pattern; } - public RangeNumericProperty getRangeNumeric() { - return rangeNumeric; + public RangeNumericProperty getNumericRange() { + return numericRange; } public CodeListProperty getCodeList() { diff --git a/src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/mdd/enums/NoticeLegalBasis.java b/src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/mdd/enums/NoticeLegalBasis.java index 8acd69e..4b903ae 100644 --- a/src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/mdd/enums/NoticeLegalBasis.java +++ b/src/main/java/eu/europa/ted/eforms/sdk/analysis/domain/mdd/enums/NoticeLegalBasis.java @@ -17,13 +17,9 @@ public enum NoticeLegalBasis implements ILiteral { _31985R2137("31985R2137"), - _32018R1046("32018R1046"), - _32024R2509("32024R2509"), - OTHER("other"), - - UNKNOWN("unknown"); + OTHER("other"); private final String literal; diff --git a/src/main/java/eu/europa/ted/eforms/sdk/analysis/drools/SdkUnit.java b/src/main/java/eu/europa/ted/eforms/sdk/analysis/drools/SdkUnit.java index bbf9d44..547162f 100644 --- a/src/main/java/eu/europa/ted/eforms/sdk/analysis/drools/SdkUnit.java +++ b/src/main/java/eu/europa/ted/eforms/sdk/analysis/drools/SdkUnit.java @@ -21,6 +21,7 @@ import eu.europa.ted.eforms.sdk.analysis.fact.SchematronFileFact; import eu.europa.ted.eforms.sdk.analysis.fact.SvrlReportFact; import eu.europa.ted.eforms.sdk.analysis.fact.ViewTemplateFact; +import eu.europa.ted.eforms.sdk.analysis.fact.ViewTemplatesIndexFact; import eu.europa.ted.eforms.sdk.analysis.fact.XmlNoticeFact; import eu.europa.ted.eforms.sdk.analysis.vo.SdkMetadata; import eu.europa.ted.eforms.sdk.analysis.vo.ValidationResult; @@ -39,6 +40,7 @@ public class SdkUnit implements RuleUnit { private DataStore nodes; private DataStore noticeTypesIndex; private DataStore noticeTypes; + private DataStore viewTemplatesIndex; private DataStore viewTemplates; private DataStore svrlReports; private DataStore schematrons; @@ -153,6 +155,15 @@ public SdkUnit setNoticeTypes(DataStore noticeTypes) { return this; } + public DataStore getViewTemplatesIndex() { + return viewTemplatesIndex; + } + + public SdkUnit setViewTemplatesIndex(DataStore viewTemplatesIndex) { + this.viewTemplatesIndex = viewTemplatesIndex; + return this; + } + public DataStore getViewTemplates() { return viewTemplates; } diff --git a/src/main/java/eu/europa/ted/eforms/sdk/analysis/fact/FieldFact.java b/src/main/java/eu/europa/ted/eforms/sdk/analysis/fact/FieldFact.java index 32d68be..844d968 100644 --- a/src/main/java/eu/europa/ted/eforms/sdk/analysis/fact/FieldFact.java +++ b/src/main/java/eu/europa/ted/eforms/sdk/analysis/fact/FieldFact.java @@ -185,7 +185,7 @@ public String getBusinessEntityId() { */ private Stream, ?>> getDynamicProperties() { return Stream.of(field.getRepeatable(), field.getForbidden(), field.getMandatory(), - field.getCodeList(), field.getPattern(), field.getRangeNumeric(), field.getAssertion(), + field.getCodeList(), field.getPattern(), field.getNumericRange(), field.getAssertion(), field.getInChangeNotice(), field.getInContinueProcedure()); } diff --git a/src/main/java/eu/europa/ted/eforms/sdk/analysis/fact/ViewTemplatesIndexFact.java b/src/main/java/eu/europa/ted/eforms/sdk/analysis/fact/ViewTemplatesIndexFact.java new file mode 100644 index 0000000..9e672bf --- /dev/null +++ b/src/main/java/eu/europa/ted/eforms/sdk/analysis/fact/ViewTemplatesIndexFact.java @@ -0,0 +1,34 @@ +package eu.europa.ted.eforms.sdk.analysis.fact; + +import java.util.Set; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.StringUtils; + +import eu.europa.ted.eforms.sdk.analysis.domain.view.index.TedefoViewTemplateIndex; +import eu.europa.ted.eforms.sdk.analysis.domain.view.index.TedefoViewTemplatesIndex; + +public class ViewTemplatesIndexFact implements SdkComponentFact { + + private final TedefoViewTemplatesIndex viewTemplatesIndex; + + public ViewTemplatesIndexFact(TedefoViewTemplatesIndex viewTemplatesIndex) { + this.viewTemplatesIndex = viewTemplatesIndex; + } + + public Set getLabelIds() { + return viewTemplatesIndex.getViewTemplates().stream() + .map(TedefoViewTemplateIndex::getLabelId) + .collect(Collectors.toSet()); + } + + @Override + public String getId() { + return StringUtils.EMPTY; + } + + @Override + public String getTypeName() { + return "viewTemplatesIndex"; + } +} diff --git a/src/main/java/eu/europa/ted/eforms/sdk/analysis/validator/SdkValidator.java b/src/main/java/eu/europa/ted/eforms/sdk/analysis/validator/SdkValidator.java index ef712d4..f17652d 100644 --- a/src/main/java/eu/europa/ted/eforms/sdk/analysis/validator/SdkValidator.java +++ b/src/main/java/eu/europa/ted/eforms/sdk/analysis/validator/SdkValidator.java @@ -60,6 +60,7 @@ public Validator validate() throws Exception { .setNoticeTypesIndex(factsLoader.loadNoticeTypesIndex()) .setLabels(factsLoader.loadLabels()) .setViewTemplates(factsLoader.loadViewTemplates()) + .setViewTemplatesIndex(factsLoader.loadViewTemplatesIndex()) .setXmlNotices(factsLoader.loadXmlNotices()) .setSvrlReports(factsLoader.loadSvrlReports()) .setSchematrons(factsLoader.loadSchematrons()); diff --git a/src/main/resources/eu/europa/ted/eforms/sdk/analysis/drools/viewTemplatesRules.drl b/src/main/resources/eu/europa/ted/eforms/sdk/analysis/drools/viewTemplatesRules.drl new file mode 100644 index 0000000..a5a4465 --- /dev/null +++ b/src/main/resources/eu/europa/ted/eforms/sdk/analysis/drools/viewTemplatesRules.drl @@ -0,0 +1,11 @@ +package eu.europa.ted.eforms.sdk.analysis.drools; + +unit SdkUnit; + +rule "View templates index references existing labels" +when + $labelId : /viewTemplatesIndex[ $v: this ]/labelIds + not (exists /labels[ id == $labelId ]) +then + results.add(new ValidationResult($v, "Referenced label " + $labelId + " does not exist", ValidationStatusEnum.ERROR)); +end diff --git a/src/test/java/eu/europa/ted/eforms/sdk/analysis/cucumber/SdkValidationSteps.java b/src/test/java/eu/europa/ted/eforms/sdk/analysis/cucumber/SdkValidationSteps.java index ed7d5c3..6c4e7b8 100644 --- a/src/test/java/eu/europa/ted/eforms/sdk/analysis/cucumber/SdkValidationSteps.java +++ b/src/test/java/eu/europa/ted/eforms/sdk/analysis/cucumber/SdkValidationSteps.java @@ -90,6 +90,12 @@ public void i_load_all_labels() @When("I load the view templates index") public void i_load_the_view_templates_index() throws IOException, JAXBException, SAXException, ParserConfigurationException { + sdkValidator.getSdkUnit().setViewTemplatesIndex(new FactsLoader(testsFolder).loadViewTemplatesIndex()); + } + + @When("I load the view templates") + public void i_load_the_view_templates() + throws IOException, JAXBException, SAXException, ParserConfigurationException { sdkValidator.getSdkUnit().setViewTemplates(new FactsLoader(testsFolder).loadViewTemplates()); } diff --git a/src/test/resources/eforms-sdk-tests/tedefo-2206/invalid/notice-types/notice-types.json b/src/test/resources/eforms-sdk-tests/tedefo-2206/invalid/notice-types/notice-types.json index a9576ac..eb573e5 100644 --- a/src/test/resources/eforms-sdk-tests/tedefo-2206/invalid/notice-types/notice-types.json +++ b/src/test/resources/eforms-sdk-tests/tedefo-2206/invalid/notice-types/notice-types.json @@ -367,7 +367,7 @@ "viewTemplateIds" : [ "40", "summary" ] }, { "documentType" : "PIN", - "legalBasis" : "32018R1046", + "legalBasis" : "32024R2509", "formType" : "competition", "type" : "pin-cfc-standard", "description" : "Call for expressions of interest", diff --git a/src/test/resources/eforms-sdk-tests/tedefo-2206/valid/notice-types/notice-types.json b/src/test/resources/eforms-sdk-tests/tedefo-2206/valid/notice-types/notice-types.json index a9576ac..eb573e5 100644 --- a/src/test/resources/eforms-sdk-tests/tedefo-2206/valid/notice-types/notice-types.json +++ b/src/test/resources/eforms-sdk-tests/tedefo-2206/valid/notice-types/notice-types.json @@ -367,7 +367,7 @@ "viewTemplateIds" : [ "40", "summary" ] }, { "documentType" : "PIN", - "legalBasis" : "32018R1046", + "legalBasis" : "32024R2509", "formType" : "competition", "type" : "pin-cfc-standard", "description" : "Call for expressions of interest", diff --git a/src/test/resources/eforms-sdk-tests/tedefo-2578/invalid/notice-types/notice-types.json b/src/test/resources/eforms-sdk-tests/tedefo-2578/invalid/notice-types/notice-types.json index a176514..81a29b3 100644 --- a/src/test/resources/eforms-sdk-tests/tedefo-2578/invalid/notice-types/notice-types.json +++ b/src/test/resources/eforms-sdk-tests/tedefo-2578/invalid/notice-types/notice-types.json @@ -358,7 +358,7 @@ "viewTemplateIds" : [ "40", "summary" ] }, { "documentType" : "PIN", - "legalBasis" : "32018R1046", + "legalBasis" : "32024R2509", "formType" : "competition", "type" : "pin-cfc-standard", "description" : "Call for expressions of interest", diff --git a/src/test/resources/eforms-sdk-tests/tedefo-2578/valid/notice-types/notice-types.json b/src/test/resources/eforms-sdk-tests/tedefo-2578/valid/notice-types/notice-types.json index c5b38d6..aadbb9d 100644 --- a/src/test/resources/eforms-sdk-tests/tedefo-2578/valid/notice-types/notice-types.json +++ b/src/test/resources/eforms-sdk-tests/tedefo-2578/valid/notice-types/notice-types.json @@ -367,7 +367,7 @@ "viewTemplateIds" : [ "40", "summary" ] }, { "documentType" : "PIN", - "legalBasis" : "32018R1046", + "legalBasis" : "32024R2509", "formType" : "competition", "type" : "pin-cfc-standard", "description" : "Call for expressions of interest", diff --git a/src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/translations/translations.json b/src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/translations/translations.json new file mode 100644 index 0000000..1316883 --- /dev/null +++ b/src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/translations/translations.json @@ -0,0 +1,13 @@ +{ + "files" : [ { + "assetType" : "view", + "twoLetterCode" : "en", + "threeLetterCode" : "eng", + "filename" : "view_en.xml" + } ], + "languages" : [ { + "description" : "English", + "twoLetterCode" : "en", + "threeLetterCode" : "eng" + } ] +} \ No newline at end of file diff --git a/src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/translations/view_en.xml b/src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/translations/view_en.xml new file mode 100644 index 0000000..3d97b73 --- /dev/null +++ b/src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/translations/view_en.xml @@ -0,0 +1,8 @@ + + + +view in English. File generated from metadata database. +View template for notice subtype 1 +View template for notice subtype 2 +View template for notice summary + diff --git a/src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/view-templates/view-templates.json b/src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/view-templates/view-templates.json new file mode 100644 index 0000000..41f5577 --- /dev/null +++ b/src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/view-templates/view-templates.json @@ -0,0 +1,33 @@ +{ + "ublVersion" : "2.3", + "sdkVersion" : "1.6.0", + "metadataDatabase" : { + "version" : "1.5.29", + "createdOn" : "2023-01-24T11:03:12" + }, + "viewTemplates" : [ { + "id" : "1", + "filename" : "1.efx", + "description" : "Default", + "_noticeSubtypeIds" : [ "1" ], + "_label" : "view|name|1" + }, { + "id" : "2", + "filename" : "2.efx", + "description" : "Default", + "_noticeSubtypeIds" : [ "2" ], + "_label" : "view|name|2BAD" + }, { + "id" : "3", + "filename" : "3.efx", + "description" : "Default", + "_noticeSubtypeIds" : [ "3" ], + "_label" : "view|name|3" + } , { + "id" : "summary", + "filename" : "summary.efx", + "description" : "The summary view works for all notices", + "_noticeSubtypeIds" : [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "CEI", "T01", "T02", "X01", "X02" ], + "_label" : "view|name|summary" + } ] +} \ No newline at end of file diff --git a/src/test/resources/eforms-sdk-tests/tedefo-3877/valid/translations/translations.json b/src/test/resources/eforms-sdk-tests/tedefo-3877/valid/translations/translations.json new file mode 100644 index 0000000..1316883 --- /dev/null +++ b/src/test/resources/eforms-sdk-tests/tedefo-3877/valid/translations/translations.json @@ -0,0 +1,13 @@ +{ + "files" : [ { + "assetType" : "view", + "twoLetterCode" : "en", + "threeLetterCode" : "eng", + "filename" : "view_en.xml" + } ], + "languages" : [ { + "description" : "English", + "twoLetterCode" : "en", + "threeLetterCode" : "eng" + } ] +} \ No newline at end of file diff --git a/src/test/resources/eforms-sdk-tests/tedefo-3877/valid/translations/view_en.xml b/src/test/resources/eforms-sdk-tests/tedefo-3877/valid/translations/view_en.xml new file mode 100644 index 0000000..ab7845f --- /dev/null +++ b/src/test/resources/eforms-sdk-tests/tedefo-3877/valid/translations/view_en.xml @@ -0,0 +1,9 @@ + + + +view in English. File generated from metadata database. +View template for notice subtype 1 +View template for notice subtype 2 +View template for notice subtype 3 +View template for notice summary + diff --git a/src/test/resources/eforms-sdk-tests/tedefo-3877/valid/view-templates/view-templates.json b/src/test/resources/eforms-sdk-tests/tedefo-3877/valid/view-templates/view-templates.json new file mode 100644 index 0000000..ded28cc --- /dev/null +++ b/src/test/resources/eforms-sdk-tests/tedefo-3877/valid/view-templates/view-templates.json @@ -0,0 +1,33 @@ +{ + "ublVersion" : "2.3", + "sdkVersion" : "1.6.0", + "metadataDatabase" : { + "version" : "1.5.29", + "createdOn" : "2023-01-24T11:03:12" + }, + "viewTemplates" : [ { + "id" : "1", + "filename" : "1.efx", + "description" : "Default", + "_noticeSubtypeIds" : [ "1" ], + "_label" : "view|name|1" + }, { + "id" : "2", + "filename" : "2.efx", + "description" : "Default", + "_noticeSubtypeIds" : [ "2" ], + "_label" : "view|name|2" + }, { + "id" : "3", + "filename" : "3.efx", + "description" : "Default", + "_noticeSubtypeIds" : [ "3" ], + "_label" : "view|name|3" + } , { + "id" : "summary", + "filename" : "summary.efx", + "description" : "The summary view works for all notices", + "_noticeSubtypeIds" : [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "CEI", "T01", "T02", "X01", "X02" ], + "_label" : "view|name|summary" + } ] +} \ No newline at end of file diff --git a/src/test/resources/eu/europa/ted/eforms/sdk/analysis/cucumber/tedefo-1816.feature b/src/test/resources/eu/europa/ted/eforms/sdk/analysis/cucumber/tedefo-1816.feature index b3cda8c..db89caa 100644 --- a/src/test/resources/eu/europa/ted/eforms/sdk/analysis/cucumber/tedefo-1816.feature +++ b/src/test/resources/eu/europa/ted/eforms/sdk/analysis/cucumber/tedefo-1816.feature @@ -10,14 +10,14 @@ Feature: Notice Types Index - View templates validation Scenario: All referenced view templates exist Given A "tedefo-1816" folder with "valid" files When I load the notice types index - And I load the view templates index + And I load the view templates And I execute validation Then I should get 0 SDK validation errors Scenario Outline: Some referenced view templates do not exist Given A "tedefo-1816" folder with "invalid" files When I load the notice types index - And I load the view templates index + And I load the view templates And I execute validation Then Rule "" should have been fired Then I should get 2 SDK validation errors diff --git a/src/test/resources/eu/europa/ted/eforms/sdk/analysis/cucumber/tedefo-3877.feature b/src/test/resources/eu/europa/ted/eforms/sdk/analysis/cucumber/tedefo-3877.feature new file mode 100644 index 0000000..e2e6baa --- /dev/null +++ b/src/test/resources/eu/europa/ted/eforms/sdk/analysis/cucumber/tedefo-3877.feature @@ -0,0 +1,27 @@ +@tedefo-3877 +Feature: View Templates Index - Labels validation + TEDEFO-3877: Τhe labels referenced in the view-templates.json file should exist + Test files under under "src/test/resources/eforms-sdk-tests/tedefo-3877" + + Background: + Given The following rules + | View templates index references existing labels | + + Scenario: All referenced labels exist + Given A "tedefo-3877" folder with "valid" files + When I load the view templates index + And I load all labels + And I execute validation + Then I should get 0 SDK validation errors + + Scenario Outline: Some referenced labels do not exist + Given A "tedefo-3877" folder with "invalid" files + When I load the view templates index + And I load all labels + And I execute validation + Then Rule "" should have been fired + Then I should get 2 SDK validation errors + + Examples: + | expected rule | + | View templates index references existing labels |