Don't access getBinaries directly in XVerExtensionManager (#864)
* Don't access getBinaries directly in XVerExtensionManager * Remove getBinaries() add getBinaryKeysAsSet() Co-authored-by: dotasek <david.otasek@smilecdr.com>
This commit is contained in:
parent
b855463aa7
commit
6b7ac47076
|
@ -115,14 +115,14 @@ public class ComparisonRenderer implements IEvaluationContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dumpBinaries() throws IOException {
|
private void dumpBinaries() throws IOException {
|
||||||
if (contextLeft != null && contextLeft.getBinaries() != null) {
|
if (contextLeft != null && contextLeft.getBinaryKeysAsSet() != null) {
|
||||||
for (String k : contextLeft.getBinaries().keySet()) {
|
for (String k : contextLeft.getBinaryKeysAsSet()) {
|
||||||
TextFile.bytesToFile(contextLeft.getBinaries().get(k), Utilities.path(folder, k));
|
TextFile.bytesToFile(contextLeft.getBinaryForKey(k), Utilities.path(folder, k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (contextRight != null && contextRight.getBinaries() != null) {
|
if (contextRight != null && contextRight.getBinaryKeysAsSet() != null) {
|
||||||
for (String k : contextRight.getBinaries().keySet()) {
|
for (String k : contextRight.getBinaryKeysAsSet()) {
|
||||||
TextFile.bytesToFile(contextRight.getBinaries().get(k), Utilities.path(folder, k));
|
TextFile.bytesToFile(contextRight.getBinaryForKey(k), Utilities.path(folder, k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2161,10 +2161,18 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, byte[]> getBinaries() {
|
public Set<String> getBinaryKeysAsSet() { return binaries.keySet(); }
|
||||||
return binaries;
|
|
||||||
|
@Override
|
||||||
|
public boolean hasBinaryKey(String binaryKey) {
|
||||||
|
return binaries.containsKey(binaryKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] getBinaryForKey(String binaryKey) {
|
||||||
|
return binaries.get(binaryKey);
|
||||||
|
}
|
||||||
|
|
||||||
public void finishLoading() {
|
public void finishLoading() {
|
||||||
for (StructureDefinition sd : listStructures()) {
|
for (StructureDefinition sd : listStructures()) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -833,7 +833,28 @@ public interface IWorkerContext {
|
||||||
public void setUcumService(UcumService ucumService);
|
public void setUcumService(UcumService ucumService);
|
||||||
|
|
||||||
public String getLinkForUrl(String corePath, String s);
|
public String getLinkForUrl(String corePath, String s);
|
||||||
public Map<String, byte[]> getBinaries();
|
|
||||||
|
/**
|
||||||
|
* Returns a set of keys that can be used to get binaries from this context.
|
||||||
|
*
|
||||||
|
* @return a set of binaries or null
|
||||||
|
*/
|
||||||
|
public Set<String> getBinaryKeysAsSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this worker context contains a binary for this key.
|
||||||
|
*
|
||||||
|
* @param binaryKey
|
||||||
|
* @return true if binary is available for this key
|
||||||
|
*/
|
||||||
|
public boolean hasBinaryKey(String binaryKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the binary for the key
|
||||||
|
* @param binaryKey
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public byte[] getBinaryForKey(String binaryKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load relevant resources of the appropriate types (as specified by the loader) from the nominated package
|
* Load relevant resources of the appropriate types (as specified by the loader) from the nominated package
|
||||||
|
|
|
@ -52,9 +52,9 @@ public class XVerExtensionManager {
|
||||||
String v = url.substring(20, 23);
|
String v = url.substring(20, 23);
|
||||||
String e = url.substring(54);
|
String e = url.substring(54);
|
||||||
if (!lists.containsKey(v)) {
|
if (!lists.containsKey(v)) {
|
||||||
if (context.getBinaries().containsKey("xver-paths-"+v+".json")) {
|
if (context.hasBinaryKey("xver-paths-"+v+".json")) {
|
||||||
try {
|
try {
|
||||||
lists.put(v, JsonTrackingParser.parseJson(context.getBinaries().get("xver-paths-"+v+".json")));
|
lists.put(v, JsonTrackingParser.parseJson(context.getBinaryForKey("xver-paths-"+v+".json")));
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
throw new FHIRException(e);
|
throw new FHIRException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,11 +67,11 @@ public class ComparisonService {
|
||||||
System.out.println("Generating output to " + dest + "...");
|
System.out.println("Generating output to " + dest + "...");
|
||||||
Utilities.createDirectory(dest);
|
Utilities.createDirectory(dest);
|
||||||
ComparisonRenderer cr = new ComparisonRenderer(validator.getContext(), validator.getContext(), dest, session);
|
ComparisonRenderer cr = new ComparisonRenderer(validator.getContext(), validator.getContext(), dest, session);
|
||||||
cr.getTemplates().put("CodeSystem", new String(validator.getContext().getBinaries().get("template-comparison-CodeSystem.html")));
|
cr.getTemplates().put("CodeSystem", new String(validator.getContext().getBinaryForKey("template-comparison-CodeSystem.html")));
|
||||||
cr.getTemplates().put("ValueSet", new String(validator.getContext().getBinaries().get("template-comparison-ValueSet.html")));
|
cr.getTemplates().put("ValueSet", new String(validator.getContext().getBinaryForKey("template-comparison-ValueSet.html")));
|
||||||
cr.getTemplates().put("Profile", new String(validator.getContext().getBinaries().get("template-comparison-Profile.html")));
|
cr.getTemplates().put("Profile", new String(validator.getContext().getBinaryForKey("template-comparison-Profile.html")));
|
||||||
cr.getTemplates().put("Index", new String(validator.getContext().getBinaries().get("template-comparison-index.html")));
|
cr.getTemplates().put("Index", new String(validator.getContext().getBinaryForKey("template-comparison-index.html")));
|
||||||
cr.getTemplates().put("CapabilityStatement", new String(validator.getContext().getBinaries().get("template-comparison-CapabilityStatement.html")));
|
cr.getTemplates().put("CapabilityStatement", new String(validator.getContext().getBinaryForKey("template-comparison-CapabilityStatement.html")));
|
||||||
File htmlFile = cr.render(left, right);
|
File htmlFile = cr.render(left, right);
|
||||||
Desktop.getDesktop().browse(htmlFile.toURI());
|
Desktop.getDesktop().browse(htmlFile.toURI());
|
||||||
System.out.println("Done");
|
System.out.println("Done");
|
||||||
|
|
Loading…
Reference in New Issue