diff --git a/pom.xml b/pom.xml index 4c16760..dc8e15a 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ 2.0.0-SNAPSHOT - 1.0.6-SNAPSHOT + 1.2.0-SNAPSHOT 4.9.3 diff --git a/src/main/java/eu/europa/ted/eforms/viewer/DependencyFactory.java b/src/main/java/eu/europa/ted/eforms/viewer/DependencyFactory.java index cbda144..910477a 100644 --- a/src/main/java/eu/europa/ted/eforms/viewer/DependencyFactory.java +++ b/src/main/java/eu/europa/ted/eforms/viewer/DependencyFactory.java @@ -13,19 +13,36 @@ import eu.europa.ted.efx.interfaces.TranslatorOptions; public class DependencyFactory implements TranslatorDependencyFactory { - private Path sdkRoot; - - @SuppressWarnings("unused") - private DependencyFactory() {} + final private Path sdkRoot; + final private boolean sdkSnapshotsAllowed; + /** + * Public constructor used by the EfxTranslator does not allow the use of + * SNAPSHOT versions of the SDK. + * + * @param sdkRoot The root directory where the SDK will be downloaded. + */ public DependencyFactory(Path sdkRoot) { + this(sdkRoot, false); + } + + /** + * Subclasses can use this constructor to allow the use of SNAPSHOT versions of + * the SDK. + * + * @param sdkRoot The root directory where the SDK will be downloaded. + * @param resolveSnapshots If true, SNAPSHOT versions of the SDK will be + * downloaded if needed. + */ + protected DependencyFactory(Path sdkRoot, boolean resolveSnapshots) { this.sdkRoot = sdkRoot; + this.sdkSnapshotsAllowed = resolveSnapshots; } @Override public SymbolResolver createSymbolResolver(String sdkVersion) { try { - SdkDownloader.downloadSdk(sdkVersion, sdkRoot); + SdkDownloader.downloadSdk(sdkVersion, sdkRoot, this.sdkSnapshotsAllowed); return ComponentFactory.getSymbolResolver(sdkVersion, sdkRoot); } catch (InstantiationException | IOException e) { diff --git a/src/main/resources/templates/xsl_markup/label_from_key.ftl b/src/main/resources/templates/xsl_markup/label_from_key.ftl index 4fe4f5e..70bfb2d 100644 --- a/src/main/resources/templates/xsl_markup/label_from_key.ftl +++ b/src/main/resources/templates/xsl_markup/label_from_key.ftl @@ -3,9 +3,10 @@ - key: The key to use for rendering - quantity: If pluralisation is required, then this contains the suffix that identifies the plural form of the label. --> + <#if quantity?has_content> - - + + <#else> - + \ No newline at end of file diff --git a/src/test/java/eu/europa/ted/eforms/viewer/DependencyFactoryForUnitTesting.java b/src/test/java/eu/europa/ted/eforms/viewer/DependencyFactoryForUnitTesting.java new file mode 100644 index 0000000..39d5815 --- /dev/null +++ b/src/test/java/eu/europa/ted/eforms/viewer/DependencyFactoryForUnitTesting.java @@ -0,0 +1,14 @@ +package eu.europa.ted.eforms.viewer; + +import java.nio.file.Path; + +/** + * Extends {@link DependencyFactory} to allow the use of SNAPSHOT versions when + * unit testing. + */ +public class DependencyFactoryForUnitTesting extends DependencyFactory { + + public DependencyFactoryForUnitTesting(Path sdkRoot) { + super(sdkRoot, true); + } +} \ No newline at end of file diff --git a/src/test/java/eu/europa/ted/eforms/viewer/NoticeViewerTest.java b/src/test/java/eu/europa/ted/eforms/viewer/NoticeViewerTest.java index b4841ba..00543bc 100644 --- a/src/test/java/eu/europa/ted/eforms/viewer/NoticeViewerTest.java +++ b/src/test/java/eu/europa/ted/eforms/viewer/NoticeViewerTest.java @@ -99,7 +99,7 @@ void testEfxToXsl(String sdkVersion) throws IOException, InstantiationException final String viewId = "X02"; final Path xsl = XslGenerator.Builder - .create(new DependencyFactory(SDK_ROOT_DIR)) + .create(new DependencyFactoryForUnitTesting(SDK_ROOT_DIR)) .build() .generateFile(sdkVersion, NoticeViewer.getEfxPath(sdkVersion, viewId, SDK_ROOT_DIR), NoticeViewerConstants.DEFAULT_TRANSLATOR_OPTIONS, true); @@ -145,7 +145,7 @@ private void testGenerateHtmlFromString(final String language, final String noti Files.readString(noticeXmlPath, NoticeViewerConstants.DEFAULT_CHARSET); final Path xslPath = XslGenerator.Builder - .create(new DependencyFactory(SDK_ROOT_DIR)) + .create(new DependencyFactoryForUnitTesting(SDK_ROOT_DIR)) .build() .generateFile(sdkVersion, NoticeViewer.getEfxPath(sdkVersion, viewId, SDK_ROOT_DIR), NoticeViewerConstants.DEFAULT_TRANSLATOR_OPTIONS, true);