Search in sources :

Example 11 with ShExGenerator

use of org.hl7.fhir.r5.conformance.ShExGenerator in project org.hl7.fhir.core by hapifhir.

the class ShexGeneratorTests method doTest.

private void doTest(String name) throws IOException, FHIRException {
    // FileSystems.getDefault().getPath(System.getProperty("user.dir"), "data").toString();
    String workingDirectory = "C:\\work\\org.hl7.fhir.2016May\\build\\publish";
    if (TestingUtilities.context == null) {
        // For the time being, put the validation entry in org/hl7/fhir/dstu3/data
        Path path = FileSystems.getDefault().getPath(workingDirectory, "validation-min.xml.zip");
        TestingUtilities.context = SimpleWorkerContext.fromPack(path.toString());
    }
    StructureDefinition sd = TestingUtilities.context.fetchTypeDefinition(name);
    if (sd == null) {
        throw new FHIRException("StructuredDefinition for " + name + "was null");
    }
    Path outPath = FileSystems.getDefault().getPath(workingDirectory, name + ".shex");
    TextFile.stringToFile(new ShExGenerator(TestingUtilities.context).generate(HTMLLinkPolicy.NONE, sd), outPath.toString());
}
Also used : Path(java.nio.file.Path) StructureDefinition(org.hl7.fhir.dstu2016may.model.StructureDefinition) FHIRException(org.hl7.fhir.exceptions.FHIRException) ShExGenerator(org.hl7.fhir.dstu2016may.utils.ShExGenerator)

Example 12 with ShExGenerator

use of org.hl7.fhir.r5.conformance.ShExGenerator in project org.hl7.fhir.core by hapifhir.

the class ShexGeneratorTests method doTest.

private void doTest(String name) throws FileNotFoundException, IOException, FHIRException {
    // FileSystems.getDefault().getPath(System.getProperty("user.dir"), "data").toString();
    String workingDirectory = "C:\\work\\org.hl7.fhir.2016May\\build\\publish";
    // String workingDirectory = FileSystems.getDefault().getPath(System.getProperty("user.dir"), "..", "..", "..", "publish").toString();
    if (TestingUtilities.context == null) {
        // For the time being, put the validation entry in org/hl7/fhir/dstu3/data
        Path path = FileSystems.getDefault().getPath(workingDirectory, "validation-min.xml.zip");
        TestingUtilities.context = SimpleWorkerContext.fromPack(path.toString());
    }
    StructureDefinition sd = TestingUtilities.context.fetchTypeDefinition(name);
    if (sd == null) {
        throw new FHIRException("StructuredDefinition for " + name + "was null");
    }
    Path outPath = FileSystems.getDefault().getPath(workingDirectory, name.toLowerCase() + ".shex");
    TextFile.stringToFile(new ShExGenerator(TestingUtilities.context).generate(HTMLLinkPolicy.NONE, sd), outPath.toString());
}
Also used : Path(java.nio.file.Path) StructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition) FHIRException(org.hl7.fhir.exceptions.FHIRException) ShExGenerator(org.hl7.fhir.dstu3.conformance.ShExGenerator)

Aggregations

FileOutputStream (java.io.FileOutputStream)7 ShExGenerator (org.hl7.fhir.r5.conformance.ShExGenerator)7 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)7 FHIRException (org.hl7.fhir.exceptions.FHIRException)6 JsonParser (org.hl7.fhir.r5.formats.JsonParser)6 XmlParser (org.hl7.fhir.r5.formats.XmlParser)6 CSFile (org.hl7.fhir.utilities.CSFile)6 Path (java.nio.file.Path)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 TransformerException (javax.xml.transform.TransformerException)1 JsonSpecGenerator (org.hl7.fhir.definitions.generators.specification.JsonSpecGenerator)1 ReviewSpreadsheetGenerator (org.hl7.fhir.definitions.generators.specification.ReviewSpreadsheetGenerator)1