Output type triples for value[x] nodes. Use simple property names.

This commit is contained in:
Jim Balhoff 2023-01-27 17:35:36 -05:00
parent 00d1ab3517
commit 890971d110
1 changed files with 14 additions and 24 deletions

View File

@ -413,6 +413,9 @@ public class TurtleParser extends ParserBase {
} else { } else {
t = ctxt.linkedPredicate("fhir:"+en, linkResolver == null ? null : linkResolver.resolveProperty(element.getProperty()), comment); t = ctxt.linkedPredicate("fhir:"+en, linkResolver == null ? null : linkResolver.resolveProperty(element.getProperty()), comment);
} }
if (element.getProperty().getName().endsWith("[x]") && !element.hasValue()) {
t.linkedPredicate("a", "fhir:" + element.fhirType(), linkResolver == null ? null : linkResolver.resolveType(element.fhirType()), null);
}
if (element.getSpecial() != null) if (element.getSpecial() != null)
t.linkedPredicate("a", "fhir:"+element.fhirType(), linkResolver == null ? null : linkResolver.resolveType(element.fhirType()), null); t.linkedPredicate("a", "fhir:"+element.fhirType(), linkResolver == null ? null : linkResolver.resolveType(element.fhirType()), null);
if (element.hasValue()) if (element.hasValue())
@ -456,37 +459,24 @@ public class TurtleParser extends ParserBase {
private String getFormalName(Element element) { private String getFormalName(Element element) {
String en = null; String en = null;
if (element.getSpecial() == null) { if (element.getSpecial() == null)
if (element.getProperty().getDefinition().hasBase()) en = element.getProperty().getName();
en = element.getProperty().getDefinition().getBase().getPath();
}
else if (element.getSpecial() == SpecialElement.BUNDLE_ENTRY) else if (element.getSpecial() == SpecialElement.BUNDLE_ENTRY)
en = "Bundle.entry.resource"; en = "resource";
else if (element.getSpecial() == SpecialElement.BUNDLE_OUTCOME) else if (element.getSpecial() == SpecialElement.BUNDLE_OUTCOME)
en = "Bundle.entry.response.outcome"; en = "outcome";
else if (element.getSpecial() == SpecialElement.PARAMETER) else if (element.getSpecial() == SpecialElement.PARAMETER)
en = element.getElementProperty().getDefinition().getPath(); en = element.getElementProperty().getDefinition().getPath();
else // CONTAINED else // CONTAINED
en = "DomainResource.contained"; en = "contained";
if (en == null) if (en == null)
en = element.getProperty().getDefinition().getPath(); en = element.getProperty().getName();
boolean doType = false;
if (en.endsWith("[x]")) {
en = en.substring(0, en.length()-3);
doType = true;
}
if (doType || (element.getProperty().getDefinition().getType().size() > 1 && !allReference(element.getProperty().getDefinition().getType())))
en = en + Utilities.capitalize(element.getType());
return en;
}
private boolean allReference(List<TypeRefComponent> types) { if (en.endsWith("[x]"))
for (TypeRefComponent t : types) { en = en.substring(0, en.length()-3);
if (!t.getCode().equals("Reference"))
return false; return en;
}
return true;
} }
static public String ttlLiteral(String value, String type) { static public String ttlLiteral(String value, String type) {