Load context from classpath allowing duplicates

Added ability to specify whether to allow duplicates when loading context from classpath. In similar fashion to loading from package.
This commit is contained in:
azizjonh 2020-12-01 11:05:57 -06:00 committed by GitHub
parent 2dff99e99b
commit c4139ae9a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -243,10 +243,14 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
} }
public static SimpleWorkerContext fromClassPath(String name) throws IOException, FHIRException { public static SimpleWorkerContext fromClassPath(String name) throws IOException, FHIRException {
InputStream s = SimpleWorkerContext.class.getResourceAsStream("/"+name); return fromClassPath(name, false);
SimpleWorkerContext res = new SimpleWorkerContext(); }
public static SimpleWorkerContext fromClassPath(String name, boolean allowDuplicates) throws IOException, FHIRException {
InputStream s = SimpleWorkerContext.class.getResourceAsStream("/" + name);
SimpleWorkerContext res = new SimpleWorkerContext();
res.setAllowLoadingDuplicates(allowDuplicates);
res.loadFromStream(s, null); res.loadFromStream(s, null);
return res; return res;
} }
// public static SimpleWorkerContext fromDefinitions(Map<String, byte[]> source) throws IOException, FHIRException { // public static SimpleWorkerContext fromDefinitions(Map<String, byte[]> source) throws IOException, FHIRException {