diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGenerator.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGenerator.java index dd0c486ae2a..89a4da8c6e8 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGenerator.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGenerator.java @@ -58,7 +58,7 @@ public abstract class BaseThymeleafNarrativeGenerator extends ThymeleafNarrative List propFileName = getPropertyFile(); try { - NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileContents(propFileName); + NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation(propFileName); setManifest(manifest); } catch (IOException e) { throw new InternalErrorException(e); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative2/NarrativeTemplateManifest.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative2/NarrativeTemplateManifest.java index 84496ac7c13..8a6798e0f04 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative2/NarrativeTemplateManifest.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative2/NarrativeTemplateManifest.java @@ -92,6 +92,22 @@ public class NarrativeTemplateManifest implements INarrativeTemplateManifest { } } + public static NarrativeTemplateManifest forManifestFileLocation(String... thePropertyFilePaths) throws IOException { + return forManifestFileLocation(Arrays.asList(thePropertyFilePaths)); + } + + public static NarrativeTemplateManifest forManifestFileLocation(Collection thePropertyFilePaths) throws IOException { + ourLog.debug("Loading narrative properties file(s): {}", thePropertyFilePaths); + + List manifestFileContents = new ArrayList<>(thePropertyFilePaths.size()); + for (String next : thePropertyFilePaths) { + String resource = loadResource(next); + manifestFileContents.add(resource); + } + + return forManifestFileContents(manifestFileContents); + } + public static NarrativeTemplateManifest forManifestFileContents(String... theResources) throws IOException { return forManifestFileContents(Arrays.asList(theResources)); } diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/narrative2/ThymeleafNarrativeGeneratorTest.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/narrative2/ThymeleafNarrativeGeneratorTest.java index 1135b62fffa..38da5339b7d 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/narrative2/ThymeleafNarrativeGeneratorTest.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/narrative2/ThymeleafNarrativeGeneratorTest.java @@ -58,7 +58,7 @@ public class ThymeleafNarrativeGeneratorTest { ref.setReference("DiagnosticReport/1").setResource(dr1); sect.getEntry().add(ref); - NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileContents("classpath:narrative2/narratives.properties"); + NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation("classpath:narrative2/narratives.properties"); ThymeleafNarrativeGenerator gen = new ThymeleafNarrativeGenerator(); gen.setManifest(manifest); @@ -78,7 +78,7 @@ public class ThymeleafNarrativeGeneratorTest { @Test public void testTemplateCount() throws IOException { - NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileContents("classpath:narrative2/narratives.properties"); + NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation("classpath:narrative2/narratives.properties"); assertEquals(4, manifest.getNamedTemplateCount()); }