Search in sources :

Example 1 with Round

use of org.hl7.elm.r1.Round in project kindling by HL7.

the class PageProcessor method getResourceSummary.

private ResourceSummary getResourceSummary(String n) throws IOException {
    ResourceSummary rs = new ResourceSummary();
    JsonObject r = r3r4Outcomes.getAsJsonObject(n);
    if (r != null && (new File(Utilities.path(folders.rootDir, "implementations", "r3maps", "R4toR3", n + ".map")).exists())) {
        rs.setMapped(true);
        for (Entry<String, JsonElement> e : r.entrySet()) {
            JsonObject el = (JsonObject) e.getValue();
            rs.testCount++;
            JsonPrimitive p = el.getAsJsonPrimitive("execution");
            if (p != null && !p.isBoolean())
                rs.executeFailCount++;
            if (el.has("r4.errors")) {
                rs.r4ValidationFailCount++;
                if (el.getAsJsonArray("r3.errors") != null)
                    rs.r4ValidationErrors = rs.r4ValidationErrors + el.getAsJsonArray("r3.errors").size();
                else
                    rs.r4ValidationErrors = rs.r4ValidationErrors;
            }
            if (el.has("round-trip"))
                rs.roundTripFailCount++;
        }
    } else
        rs.setMapped(false);
    return rs;
}
Also used : JsonPrimitive(com.google.gson.JsonPrimitive) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile)

Example 2 with Round

use of org.hl7.elm.r1.Round in project org.hl7.fhir.core by hapifhir.

the class ToolsHelper method testRoundTrip.

public void testRoundTrip(String rootDir, String tmpDir, Collection<String> names) throws Throwable {
    try {
        System.err.println("Round trip from " + rootDir + " to " + tmpDir + ":" + Integer.toString(names.size()) + " files");
        for (String n : names) {
            System.err.print("  " + n);
            String source = rootDir + n + ".xml";
            // String tmpJson = tmpDir + n + ".json";
            String tmp = tmpDir + n.replace(File.separator, "-") + ".tmp";
            String dest = tmpDir + n.replace(File.separator, "-") + ".java.xml";
            FileInputStream in = new FileInputStream(source);
            XmlParser xp = new XmlParser();
            Resource r = xp.parse(in);
            System.err.print(".");
            JsonParser jp = new JsonParser();
            FileOutputStream out = new FileOutputStream(tmp);
            jp.setOutputStyle(OutputStyle.PRETTY);
            jp.compose(out, r);
            out.close();
            r = null;
            System.err.print(".");
            in = new FileInputStream(tmp);
            System.err.print(",");
            r = jp.parse(in);
            System.err.print(".");
            out = new FileOutputStream(dest);
            new XmlParser().compose(out, r, true);
            System.err.println("!");
            out.close();
            r = null;
            System.gc();
        }
    } catch (Throwable e) {
        System.err.println("Error: " + e.getMessage());
        throw e;
    }
}
Also used : XmlParser(org.hl7.fhir.dstu2.formats.XmlParser) FileOutputStream(java.io.FileOutputStream) Resource(org.hl7.fhir.dstu2.model.Resource) FileInputStream(java.io.FileInputStream) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream) JsonParser(org.hl7.fhir.dstu2.formats.JsonParser)

Example 3 with Round

use of org.hl7.elm.r1.Round in project org.hl7.fhir.core by hapifhir.

the class ToolsHelper method testRoundTrip.

public void testRoundTrip(String rootDir, String tmpDir, Collection<String> names) throws Throwable {
    try {
        System.err.println("Round trip from " + rootDir + " to " + tmpDir + ":" + Integer.toString(names.size()) + " files");
        for (String n : names) {
            System.err.print("  " + n);
            String source = rootDir + n + ".xml";
            // String tmpJson = tmpDir + n + ".json";
            String tmp = tmpDir + n.replace(File.separator, "-") + ".tmp";
            String dest = tmpDir + n.replace(File.separator, "-") + ".java.xml";
            FileInputStream in = new FileInputStream(source);
            XmlParser xp = new XmlParser();
            Resource r = xp.parse(in);
            System.err.print(".");
            JsonParser jp = new JsonParser();
            FileOutputStream out = new FileOutputStream(tmp);
            jp.setOutputStyle(OutputStyle.PRETTY);
            jp.compose(out, r);
            out.close();
            r = null;
            System.err.print(".");
            in = new FileInputStream(tmp);
            System.err.print(",");
            r = jp.parse(in);
            System.err.print(".");
            out = new FileOutputStream(dest);
            new XmlParser().compose(out, r, true);
            System.err.println("!");
            out.close();
            r = null;
            System.gc();
        }
    } catch (Throwable e) {
        System.err.println("Error: " + e.getMessage());
        throw e;
    }
}
Also used : XmlParser(org.hl7.fhir.dstu2016may.formats.XmlParser) FileOutputStream(java.io.FileOutputStream) Resource(org.hl7.fhir.dstu2016may.model.Resource) FileInputStream(java.io.FileInputStream) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream) JsonParser(org.hl7.fhir.dstu2016may.formats.JsonParser)

Example 4 with Round

use of org.hl7.elm.r1.Round in project org.hl7.fhir.core by hapifhir.

the class ToolsHelper method testRoundTrip.

public void testRoundTrip(String rootDir, String tmpDir, Collection<String> names) throws Throwable {
    try {
        System.err.println("Round trip from " + rootDir + " to " + tmpDir + ":" + Integer.toString(names.size()) + " files");
        for (String n : names) {
            System.err.print("  " + n);
            String source = rootDir + n + ".xml";
            // String tmpJson = tmpDir + n + ".json";
            String tmp = tmpDir + n.replace(File.separator, "-") + ".tmp";
            String dest = tmpDir + n.replace(File.separator, "-") + ".java.xml";
            FileInputStream in = new FileInputStream(source);
            XmlParser xp = new XmlParser();
            Resource r = xp.parse(in);
            System.err.print(".");
            JsonParser jp = new JsonParser();
            FileOutputStream out = new FileOutputStream(tmp);
            jp.setOutputStyle(OutputStyle.PRETTY);
            jp.compose(out, r);
            out.close();
            r = null;
            System.err.print(".");
            in = new FileInputStream(tmp);
            System.err.print(",");
            r = jp.parse(in);
            System.err.print(".");
            out = new FileOutputStream(dest);
            new XmlParser().compose(out, r, true);
            System.err.println("!");
            out.close();
            r = null;
            System.gc();
        }
    } catch (Throwable e) {
        System.err.println("Error: " + e.getMessage());
        throw e;
    }
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) FileOutputStream(java.io.FileOutputStream) Resource(org.hl7.fhir.dstu3.model.Resource) FileInputStream(java.io.FileInputStream) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream) JsonParser(org.hl7.fhir.dstu3.formats.JsonParser)

Example 5 with Round

use of org.hl7.elm.r1.Round in project org.hl7.fhir.core by hapifhir.

the class ToolsHelper method testRoundTrip.

public void testRoundTrip(String rootDir, String tmpDir, Collection<String> names) throws Throwable {
    try {
        System.err.println("Round trip from " + rootDir + " to " + tmpDir + ":" + Integer.toString(names.size()) + " files");
        for (String n : names) {
            System.err.print("  " + n);
            String source = rootDir + n + ".xml";
            // String tmpJson = tmpDir + n + ".json";
            String tmp = tmpDir + n.replace(File.separator, "-") + ".tmp";
            String dest = tmpDir + n.replace(File.separator, "-") + ".java.xml";
            FileInputStream in = new FileInputStream(source);
            XmlParser xp = new XmlParser();
            Resource r = xp.parse(in);
            System.err.print(".");
            JsonParser jp = new JsonParser();
            FileOutputStream out = new FileOutputStream(tmp);
            jp.setOutputStyle(OutputStyle.PRETTY);
            jp.compose(out, r);
            out.close();
            r = null;
            System.err.print(".");
            in = new FileInputStream(tmp);
            System.err.print(",");
            r = jp.parse(in);
            System.err.print(".");
            out = new FileOutputStream(dest);
            new XmlParser().compose(out, r, true);
            System.err.println("!");
            out.close();
            r = null;
            System.gc();
        }
    } catch (Throwable e) {
        System.err.println("Error: " + e.getMessage());
        throw e;
    }
}
Also used : XmlParser(org.hl7.fhir.r4.formats.XmlParser) FileOutputStream(java.io.FileOutputStream) Resource(org.hl7.fhir.r4.model.Resource) FileInputStream(java.io.FileInputStream) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream) JsonParser(org.hl7.fhir.r4.formats.JsonParser)

Aggregations

FileInputStream (java.io.FileInputStream)6 FileOutputStream (java.io.FileOutputStream)6 CSFileInputStream (org.hl7.fhir.utilities.CSFileInputStream)6 ArrayList (java.util.ArrayList)4 File (java.io.File)3 CSFile (org.hl7.fhir.utilities.CSFile)3 IniFile (org.hl7.fhir.utilities.IniFile)3 TextFile (org.hl7.fhir.utilities.TextFile)3 JsonObject (com.google.gson.JsonObject)2 JsonPrimitive (com.google.gson.JsonPrimitive)2 BigDecimal (java.math.BigDecimal)2 Expression (org.hl7.elm.r1.Expression)2 Round (org.hl7.elm.r1.Round)2 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1