mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-03-09 14:31:17 +00:00
suppress Json resourceType property in some logical models
This commit is contained in:
parent
fc8152c717
commit
4f99754e75
@ -788,8 +788,9 @@ public class JsonParser extends ParserBase {
|
||||
}
|
||||
checkComposeComments(e);
|
||||
json.beginObject();
|
||||
// if (!isSuppressResourceType())
|
||||
if (!isSuppressResourceType(e.getProperty())) {
|
||||
prop("resourceType", e.getType(), null);
|
||||
}
|
||||
Set<String> done = new HashSet<String>();
|
||||
for (Element child : e.getChildren()) {
|
||||
compose(e.getName(), e, done, child);
|
||||
@ -799,6 +800,15 @@ public class JsonParser extends ParserBase {
|
||||
osw.flush();
|
||||
}
|
||||
|
||||
private boolean isSuppressResourceType(Property property) {
|
||||
StructureDefinition sd = property.getStructure();
|
||||
if (sd != null && sd.hasExtension(ToolingExtensions.EXT_SUPPRESS_RESOURCE_TYPE)) {
|
||||
return ToolingExtensions.readBoolExtension(sd, ToolingExtensions.EXT_SUPPRESS_RESOURCE_TYPE);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkComposeComments(Element e) {
|
||||
for (String s : e.getComments()) {
|
||||
json.comment(s);
|
||||
@ -814,8 +824,9 @@ public class JsonParser extends ParserBase {
|
||||
checkComposeComments(e);
|
||||
json.beginObject();
|
||||
|
||||
// if (!isSuppressResourceType())
|
||||
if (!isSuppressResourceType(e.getProperty())) {
|
||||
prop("resourceType", e.getType(), linkResolver == null ? null : linkResolver.resolveProperty(e.getProperty()));
|
||||
}
|
||||
Set<String> done = new HashSet<String>();
|
||||
for (Element child : e.getChildren()) {
|
||||
compose(e.getName(), e, done, child);
|
||||
@ -931,7 +942,7 @@ public class JsonParser extends ParserBase {
|
||||
json.elide();
|
||||
else if (item.hasChildren()) {
|
||||
open(null,null);
|
||||
if (item.getProperty().isResource()) {
|
||||
if (item.getProperty().isResource() && !isSuppressResourceType(item.getProperty())) {
|
||||
prop("resourceType", item.getType(), linkResolver == null ? null : linkResolver.resolveType(item.getType()));
|
||||
}
|
||||
if (linkResolver != null && item.getProperty().isReference()) {
|
||||
@ -987,7 +998,7 @@ public class JsonParser extends ParserBase {
|
||||
}
|
||||
if (element.hasChildren()) {
|
||||
open(name, linkResolver == null ? null : linkResolver.resolveProperty(element.getProperty()));
|
||||
if (element.getProperty().isResource()) {
|
||||
if (element.getProperty().isResource() && !isSuppressResourceType(element.getProperty())) {
|
||||
prop("resourceType", element.getType(), linkResolver == null ? null : linkResolver.resolveType(element.getType()));
|
||||
}
|
||||
if (linkResolver != null && element.getProperty().isReference()) {
|
||||
|
@ -276,6 +276,7 @@ public class ToolingExtensions {
|
||||
public static final String EXT_TYPE_PARAMETER = "http://hl7.org/fhir/tools/StructureDefinition/type-parameter";
|
||||
public static final String EXT_ALTERNATE_CANONICAL = "http://hl7.org/fhir/StructureDefinition/alternate-canonical";
|
||||
public static final String EXT_SUPPRESSED = "http://hl7.org/fhir/StructureDefinition/elementdefinition-suppress";
|
||||
public static final String EXT_SUPPRESS_RESOURCE_TYPE = "http://hl7.org/fhir/tools/StructureDefinition/json-suppress-resourcetype";
|
||||
|
||||
// specific extension helpers
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user