Improve error message when running transforms

This commit is contained in:
Grahame Grieve 2019-03-04 13:17:30 +11:00
parent 5691333e98
commit 5a1dfba236
9 changed files with 22 additions and 6 deletions

View File

@ -816,7 +816,7 @@ public class StructureMapUtilities {
for (UriType imp : map.getImport()) {
StructureMap impMap = library.get(imp.getValue());
if (impMap == null)
throw new FHIRException("Unable to find map "+imp.getValue());
throw new FHIRException("Unable to find map "+imp.getValue()+" (Known Maps = "+Utilities.listCanonicalUrls(library.keySet())+")");
for (StructureMapGroupComponent grp : impMap.getGroup()) {
if (grp.getName().equals(dependent.getName())) {
if (targetMap == null) {

View File

@ -109,7 +109,7 @@ public class Transformer {
Bundle bundle = new Bundle();
StructureMap map = scu.getLibrary().get(mapUri);
if (map == null)
throw new Error("Unable to find map "+mapUri);
throw new Error("Unable to find map "+mapUri+" (Known Maps = "+Utilities.listCanonicalUrls(scu.getLibrary().keySet())+")");
scu.transform(null, e, map, bundle);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(output), bundle);
return true;

View File

@ -91,7 +91,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
private Set<String> supportedCodeSystems = new HashSet<String>();
private Map<String, ValueSet> valueSets = new HashMap<String, ValueSet>();
private Map<String, ConceptMap> maps = new HashMap<String, ConceptMap>();
private Map<String, StructureMap> transforms = new HashMap<String, StructureMap>();
protected Map<String, StructureMap> transforms = new HashMap<String, StructureMap>();
private Map<String, StructureDefinition> structures = new HashMap<String, StructureDefinition>();
private Map<String, ImplementationGuide> guides = new HashMap<String, ImplementationGuide>();
private Map<String, SearchParameter> searchParameters = new HashMap<String, SearchParameter>();

View File

@ -601,6 +601,10 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
this.ignoreProfileErrors = ignoreProfileErrors;
}
public String listMapUrls() {
return Utilities.listCanonicalUrls(transforms.keySet());
}

View File

@ -91,7 +91,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
private Set<String> supportedCodeSystems = new HashSet<String>();
private Map<String, ValueSet> valueSets = new HashMap<String, ValueSet>();
private Map<String, ConceptMap> maps = new HashMap<String, ConceptMap>();
private Map<String, StructureMap> transforms = new HashMap<String, StructureMap>();
protected Map<String, StructureMap> transforms = new HashMap<String, StructureMap>();
private Map<String, StructureDefinition> structures = new HashMap<String, StructureDefinition>();
private Map<String, ImplementationGuide> guides = new HashMap<String, ImplementationGuide>();
private Map<String, SearchParameter> searchParameters = new HashMap<String, SearchParameter>();

View File

@ -601,6 +601,10 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
this.ignoreProfileErrors = ignoreProfileErrors;
}
public String listMapUrls() {
return Utilities.listCanonicalUrls(transforms.keySet());
}

View File

@ -66,6 +66,7 @@ import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import javax.sound.sampled.AudioFormat;
@ -1156,5 +1157,9 @@ public class Utilities {
}
public static String listCanonicalUrls(Set<String> keys) {
return keys.toString();
}
}

View File

@ -619,6 +619,8 @@ public class ValidationEngine {
return FhirFormat.TURTLE;
if (Utilities.existsInList(ext, "map"))
return FhirFormat.TEXT;
if (Utilities.existsInList(ext, "txt"))
return FhirFormat.TEXT;
return checkIsResource(new FileInputStream(path));
}
@ -656,6 +658,7 @@ public class ValidationEngine {
for (Entry<String, byte[]> t : source.entrySet()) {
String fn = t.getKey();
if (!exemptFile(fn)) {
System.out.print(" ..file: "+fn);
Resource r = null;
try {
if (version.equals("3.0.1") || version.equals("3.0.0")) {
@ -962,7 +965,7 @@ public class ValidationEngine {
org.hl7.fhir.r4.elementmodel.Element src = Manager.parse(context, new ByteArrayInputStream(source), cntType);
StructureMap map = context.getTransform(mapUri);
if (map == null)
throw new Error("Unable to find map "+mapUri);
throw new Error("Unable to find map "+mapUri+" (Known Maps = "+context.listMapUrls()+")");
scu.transform(null, src, map, null);
if (outputs.size() == 0)

View File

@ -972,7 +972,7 @@ public class ValidationEngine {
org.hl7.fhir.r5.elementmodel.Element src = Manager.parse(context, new ByteArrayInputStream(source), cntType);
StructureMap map = context.getTransform(mapUri);
if (map == null)
throw new Error("Unable to find map "+mapUri);
throw new Error("Unable to find map "+mapUri+" (Known Maps = "+context.listMapUrls()+")");
scu.transform(null, src, map, null);
if (outputs.size() == 0)