Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@
<!-- Versions - eForms -->
<version.eforms-sdk-1>1.13.0</version.eforms-sdk-1>
<version.eforms-sdk-2>2.0.0-SNAPSHOT</version.eforms-sdk-2>
<version.eforms-core>1.5.0</version.eforms-core>
<version.eforms-core>1.6.0-SNAPSHOT</version.eforms-core>

<!-- Versions - Third-party libraries -->
<version.antlr4>4.13.1</version.antlr4>
<version.commons-lang3>3.18.0</version.commons-lang3>
<version.freemarker>2.3.31</version.freemarker>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version dates back to 2021. The latest version is 2.3.34, from 2024, and its requirements are the same. So it would be better to use that version.

<version.logback>1.5.18</version.logback>
<version.jackson>2.18.3</version.jackson>
<version.jackson-databind>2.18.3</version.jackson-databind>
Expand Down Expand Up @@ -121,6 +122,11 @@
<artifactId>antlr4-runtime</artifactId>
<version>${version.antlr4}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${version.freemarker}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -146,6 +152,10 @@
<artifactId>antlr4-runtime</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/eu/europa/ted/eforms/sdk/ComponentFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import eu.europa.ted.efx.interfaces.ScriptGenerator;
import eu.europa.ted.efx.interfaces.SymbolResolver;
import eu.europa.ted.efx.interfaces.TranslatorOptions;
import eu.europa.ted.efx.interfaces.ValidatorGenerator;

public class ComponentFactory extends SdkComponentFactory {
public static final ComponentFactory INSTANCE = new ComponentFactory();
Expand Down Expand Up @@ -96,7 +97,7 @@ public static synchronized SymbolResolver getSymbolResolver(final String sdkVers
// Create new instance (this can throw InstantiationException)
SymbolResolver newInstance = ComponentFactory.INSTANCE.getComponentImpl(sdkVersion,
SdkComponentType.SYMBOL_RESOLVER, qualifier, SymbolResolver.class, sdkVersion, sdkRootPath);

// Store and return
instances.put(key, newInstance);
return newInstance;
Expand All @@ -113,6 +114,18 @@ public static MarkupGenerator getMarkupGenerator(final String sdkVersion, final
SdkComponentType.MARKUP_GENERATOR, qualifier, MarkupGenerator.class, options);
}

public static ValidatorGenerator getValidatorGenerator(final String sdkVersion,
TranslatorOptions options) throws InstantiationException {
return getValidatorGenerator(sdkVersion, "", options);
}

public static ValidatorGenerator getValidatorGenerator(final String sdkVersion,
final String qualifier, TranslatorOptions options) throws InstantiationException {
return ComponentFactory.INSTANCE.getComponentImpl(sdkVersion,
SdkComponentType.VALIDATOR_GENERATOR, qualifier, ValidatorGenerator.class,
options);
}

public static ScriptGenerator getScriptGenerator(final String sdkVersion, TranslatorOptions options)
throws InstantiationException {
return getScriptGenerator(sdkVersion, "", options);
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/eu/europa/ted/eforms/sdk/SdkSymbolResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import eu.europa.ted.eforms.sdk.entity.SdkCodelist;
import eu.europa.ted.eforms.sdk.entity.SdkField;
import eu.europa.ted.eforms.sdk.entity.SdkNode;
import eu.europa.ted.eforms.sdk.entity.SdkNoticeSubtype;
import eu.europa.ted.eforms.sdk.repository.SdkCodelistRepository;
import eu.europa.ted.eforms.sdk.repository.SdkFieldRepository;
import eu.europa.ted.eforms.sdk.repository.SdkNodeRepository;
import eu.europa.ted.eforms.sdk.repository.SdkNoticeTypeRepository;
import eu.europa.ted.eforms.sdk.resource.SdkResourceLoader;
import eu.europa.ted.eforms.xpath.XPathInfo;
import eu.europa.ted.eforms.xpath.XPathProcessor;
Expand All @@ -41,6 +43,8 @@ public class SdkSymbolResolver implements SymbolResolver {

protected Map<String, SdkCodelist> codelistById;

protected Map<String, SdkNoticeSubtype> noticeTypesById;

/**
* Builds EFX list from the passed codelist reference. This will lazily compute
* and cache the
Expand Down Expand Up @@ -77,12 +81,15 @@ protected void loadMapData(final String sdkVersion, final Path sdkRootPath)
SdkConstants.SdkResource.FIELDS_JSON, sdkRootPath);
Path codelistsPath = SdkResourceLoader.getResourceAsPath(sdkVersion,
SdkConstants.SdkResource.CODELISTS, sdkRootPath);
Path noticeTypesPath = SdkResourceLoader.getResourceAsPath(sdkVersion,
SdkConstants.SdkResource.NOTICE_TYPES_JSON, sdkRootPath);

this.fieldById = new SdkFieldRepository(sdkVersion, jsonPath);
this.fieldByAlias = indexFieldsByAlias();
this.nodeById = new SdkNodeRepository(sdkVersion, jsonPath);
this.nodeByAlias = indexNodesByAlias();
this.codelistById = new SdkCodelistRepository(sdkVersion, codelistsPath);
this.noticeTypesById = new SdkNoticeTypeRepository(sdkVersion, noticeTypesPath);
}

/**
Expand Down Expand Up @@ -227,6 +234,10 @@ public String getNodeIdFromAlias(String alias) {
return null;
}

@Override
public List<String> getAllNoticeSubtypeIds() {
return noticeTypesById.keySet().stream().map(String::toUpperCase).sorted().toList();
}

private HashMap<String, SdkField> indexFieldsByAlias() {
return this.fieldById.values().stream()
Expand Down Expand Up @@ -268,8 +279,8 @@ private void cacheAdditionalFieldInfo(final String fieldId) {
}
XPathInfo xpathInfo = XPathProcessor.parse(this.getAbsolutePathOfField(fieldId).getScript());
additionalFieldInfoMap.put(fieldId, xpathInfo);
}
}

// #endregion Temporary helpers ------------------------------------------------

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2022 European Union
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copyright year should be 2025 or 2026.
I guess the same applies to all added copyright headers.

*
* Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European
* Commission – subsequent versions of the EUPL (the "Licence"); You may not use this work except in
* compliance with the Licence. You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence
* is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence for the specific language governing permissions and limitations under
* the Licence.
*/
package eu.europa.ted.eforms.sdk.schematron;

import eu.europa.ted.efx.model.Context;
import eu.europa.ted.efx.model.rules.ValidationRule;

/**
* Represents a Schematron &lt;assert&gt; element.
* Fires when the test expression evaluates to false.
*/
public class SchematronAssert extends SchematronTest {

public SchematronAssert(ValidationRule rule, Context ruleContext) {
super(rule, ruleContext);
}

@Override
public String getElementName() {
return "assert";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2022 European Union
*
* Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European
* Commission – subsequent versions of the EUPL (the "Licence"); You may not use this work except in
* compliance with the Licence. You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence
* is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the Licence for the specific language governing permissions and limitations under
* the Licence.
*/
package eu.europa.ted.eforms.sdk.schematron;

import eu.europa.ted.eforms.xpath.XPathProcessor;
import eu.europa.ted.efx.model.Context;

/**
* Represents a Schematron &lt;diagnostic&gt; element.
* Used in the &lt;diagnostics&gt; section of complete-validation.sch.
* Format: &lt;diagnostic id="..." see="field:..."&gt;xpath&lt;/diagnostic&gt;
*/
public class SchematronDiagnostic {

private final String id;
private final String seeAttribute;
private final String xpath;

private static String sanitize(String identifier) {
return identifier.replace("(", "_").replace(")", "_");
}

public SchematronDiagnostic(Context subject, Context ruleContext) {
this.xpath = XPathProcessor.contextualize(
ruleContext.absolutePath().getScript(), subject.absolutePath().getScript());
this.id = sanitize(ruleContext.symbol()) + "_" + sanitize(subject.symbol());
String prefix = subject.isFieldContext() ? "field:" : "node:";
this.seeAttribute = prefix + subject.symbol();
}

/** Used by pattern.ftl and complete-validation.ftl */
public String getId() {
return this.id;
}

/** Used by complete-validation.ftl */
public String getSeeAttribute() {
return this.seeAttribute;
}

/** Used by complete-validation.ftl */
public String getXpath() {
return this.xpath;
}
}
Loading
Loading