use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeLibrary.
protected void composeLibrary(Complex parent, String parentType, String name, Library element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "Library", name, element, index);
if (element.hasModuleMetadata())
composeModuleMetadata(t, "Library", "moduleMetadata", element.getModuleMetadata(), -1);
for (int i = 0; i < element.getModel().size(); i++) composeLibraryLibraryModelComponent(t, "Library", "model", element.getModel().get(i), i);
for (int i = 0; i < element.getLibrary().size(); i++) composeLibraryLibraryLibraryComponent(t, "Library", "library", element.getLibrary().get(i), i);
for (int i = 0; i < element.getCodeSystem().size(); i++) composeLibraryLibraryCodeSystemComponent(t, "Library", "codeSystem", element.getCodeSystem().get(i), i);
for (int i = 0; i < element.getValueSet().size(); i++) composeLibraryLibraryValueSetComponent(t, "Library", "valueSet", element.getValueSet().get(i), i);
for (int i = 0; i < element.getParameter().size(); i++) composeParameterDefinition(t, "Library", "parameter", element.getParameter().get(i), i);
for (int i = 0; i < element.getDataRequirement().size(); i++) composeDataRequirement(t, "Library", "dataRequirement", element.getDataRequirement().get(i), i);
if (element.hasDocument())
composeAttachment(t, "Library", "document", element.getDocument(), -1);
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeModuleDefinitionModuleDefinitionLibraryComponent.
protected void composeModuleDefinitionModuleDefinitionLibraryComponent(Complex parent, String parentType, String name, ModuleDefinition.ModuleDefinitionLibraryComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "library", name, element, index);
if (element.hasNameElement())
composeString(t, "ModuleDefinition", "name", element.getNameElement(), -1);
if (element.hasIdentifierElement())
composeString(t, "ModuleDefinition", "identifier", element.getIdentifierElement(), -1);
if (element.hasVersionElement())
composeString(t, "ModuleDefinition", "version", element.getVersionElement(), -1);
if (element.hasDocument())
composeType(t, "ModuleDefinition", "document", element.getDocument(), -1);
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeRelatedArtifact.
protected void composeRelatedArtifact(Complex parent, String parentType, String name, RelatedArtifact element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeElement(t, "RelatedArtifact", name, element, index);
if (element.hasTypeElement())
composeEnum(t, "RelatedArtifact", "type", element.getTypeElement(), -1);
if (element.hasDisplayElement())
composeString(t, "RelatedArtifact", "display", element.getDisplayElement(), -1);
if (element.hasCitationElement())
composeString(t, "RelatedArtifact", "citation", element.getCitationElement(), -1);
if (element.hasUrlElement())
composeUri(t, "RelatedArtifact", "url", element.getUrlElement(), -1);
if (element.hasDocument())
composeAttachment(t, "RelatedArtifact", "document", element.getDocument(), -1);
if (element.hasResource())
composeReference(t, "RelatedArtifact", "resource", element.getResource(), -1);
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project org.hl7.fhir.core by hapifhir.
the class XmlParser method parse.
public Element parse(InputStream stream) throws FHIRFormatError, DefinitionException, FHIRException, IOException {
Document doc = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// xxe protection
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
factory.setXIncludeAware(false);
factory.setExpandEntityReferences(false);
factory.setNamespaceAware(true);
if (policy == ValidationPolicy.EVERYTHING) {
// use a slower parser that keeps location data
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer nullTransformer = transformerFactory.newTransformer();
DocumentBuilder docBuilder = factory.newDocumentBuilder();
doc = docBuilder.newDocument();
DOMResult domResult = new DOMResult(doc);
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(false);
// xxe protection
spf.setFeature("http://xml.org/sax/features/external-general-entities", false);
spf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
SAXParser saxParser = spf.newSAXParser();
XMLReader xmlReader = saxParser.getXMLReader();
// xxe protection
xmlReader.setFeature("http://xml.org/sax/features/external-general-entities", false);
xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
XmlLocationAnnotator locationAnnotator = new XmlLocationAnnotator(xmlReader, doc);
InputSource inputSource = new InputSource(stream);
SAXSource saxSource = new SAXSource(locationAnnotator, inputSource);
nullTransformer.transform(saxSource, domResult);
} else {
DocumentBuilder builder = factory.newDocumentBuilder();
doc = builder.parse(stream);
}
} catch (Exception e) {
logError(0, 0, "(syntax)", IssueType.INVALID, e.getMessage(), IssueSeverity.FATAL);
doc = null;
}
if (doc == null)
return null;
else
return parse(doc);
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project org.hl7.fhir.core by hapifhir.
the class JsonParser method parse.
@Override
public Element parse(InputStream stream) throws IOException, FHIRException {
// if we're parsing at this point, then we're going to use the custom parser
map = new IdentityHashMap<JsonElement, LocationData>();
String source = TextFile.streamToString(stream);
if (policy == ValidationPolicy.EVERYTHING) {
JsonObject obj = null;
try {
obj = JsonTrackingParser.parse(source, map);
} catch (Exception e) {
logError(-1, -1, "(document)", IssueType.INVALID, "Error parsing JSON: " + e.getMessage(), IssueSeverity.FATAL);
return null;
}
assert (map.containsKey(obj));
return parse(obj);
} else {
// (JsonObject) new com.google.gson.JsonParser().parse(source);
JsonObject obj = JsonTrackingParser.parse(source, null);
// assert (map.containsKey(obj));
return parse(obj);
}
}
Aggregations