use of org.hl7.fhir.utilities.ZipGenerator in project kindling by HL7.
the class Publisher method produceSchemaZip.
private void produceSchemaZip() throws Exception {
char sc = File.separatorChar;
File f = new CSFile(page.getFolders().dstDir + "fhir-all-xsd.zip");
if (f.exists())
f.delete();
ZipGenerator zip = new ZipGenerator(page.getFolders().tmpResDir + "fhir-all-xsd.zip");
zip.addFiles(page.getFolders().dstDir, "", ".xsd", null);
zip.addFiles(page.getFolders().dstDir, "", ".sch", null);
zip.addFiles(page.getFolders().rootDir + "tools" + sc + "schematron" + sc, "", ".xsl", "");
zip.close();
Utilities.copyFile(new CSFile(page.getFolders().tmpResDir + "fhir-all-xsd.zip"), f);
f = new CSFile(page.getFolders().dstDir + "fhir-codegen-xsd.zip");
if (f.exists())
f.delete();
zip = new ZipGenerator(page.getFolders().tmpResDir + "fhir-codegen-xsd.zip");
zip.addFiles(page.getFolders().xsdDir + "codegen" + File.separator, "", ".xsd", null);
zip.close();
Utilities.copyFile(new CSFile(page.getFolders().tmpResDir + "fhir-codegen-xsd.zip"), f);
f = new CSFile(page.getFolders().dstDir + "fhir.schema.json.zip");
if (f.exists())
f.delete();
zip = new ZipGenerator(page.getFolders().tmpResDir + "fhir.schema.json.zip");
zip.addFiles(page.getFolders().dstDir, "", ".schema.json", null);
zip.close();
Utilities.copyFile(new CSFile(page.getFolders().tmpResDir + "fhir.schema.json.zip"), f);
f = new CSFile(page.getFolders().dstDir + "fhir.schema.graphql.zip");
if (f.exists())
f.delete();
zip = new ZipGenerator(page.getFolders().tmpResDir + "fhir.schema.graphql.zip");
zip.addFiles(page.getFolders().dstDir, "", ".graphql", null);
zip.close();
Utilities.copyFile(new CSFile(page.getFolders().tmpResDir + "fhir.schema.graphql.zip"), f);
zip = new ZipGenerator(page.getFolders().dstDir + "fhir.schema.shex.zip");
zip.addFileName("fhir.shex", Utilities.path(page.getFolders().dstDir, "fhir.shex"), false);
zip.close();
}
use of org.hl7.fhir.utilities.ZipGenerator in project org.hl7.fhir.core by hapifhir.
the class ArgonautConverter method convert.
private void convert(String sourceFolder, String filename, Coding clss) throws IOException {
if (new File(Utilities.path(sourceFolder, filename)).length() == 0)
return;
CDAUtilities cda;
try {
System.out.println("Process " + Utilities.path(sourceFolder, filename));
cda = new CDAUtilities(new FileInputStream(Utilities.path(sourceFolder, filename)));
zipJ = new ZipGenerator(Utilities.path(destFolder, "json/doc", Utilities.changeFileExt(filename, ".json.zip")));
zipX = new ZipGenerator(Utilities.path(destFolder, "xml/doc", Utilities.changeFileExt(filename, ".xml.zip")));
Element doc = cda.getElement();
Convert convert = new Convert(cda, ucumSvc, "-0400");
convert.setGenerateMissingExtensions(true);
Context context = new Context();
context.setBaseId(Utilities.changeFileExt(filename, ""));
context.setEncClass(clss);
makeSubject(cda, convert, doc, context, context.getBaseId() + "-patient");
makeAuthor(cda, convert, doc, context, context.getBaseId() + "-author");
makeEncounter(cda, convert, doc, context, context.getBaseId() + "-encounter");
Element body = cda.getDescendent(doc, "component/structuredBody");
for (Element c : cda.getChildren(body, "component")) {
processSection(cda, convert, context, cda.getChild(c, "section"));
}
oids.addAll(convert.getOids());
saveResource(context.getEncounter());
makeBinary(sourceFolder, filename, context);
makeDocumentReference(cda, convert, doc, context);
zipJ.close();
zipX.close();
} catch (Exception e) {
throw new Error("Unable to process " + Utilities.path(sourceFolder, filename) + ": " + e.getMessage(), e);
}
}
use of org.hl7.fhir.utilities.ZipGenerator in project org.hl7.fhir.core by hapifhir.
the class SpecDifferenceEvaluator method saveResource.
private void saveResource(ZipGenerator zip, Resource t, FhirFormat fmt) throws IOException {
ByteArrayOutputStream bs = new ByteArrayOutputStream();
if (fmt == FhirFormat.JSON)
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(bs, t);
else
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(bs, t);
zip.addBytes(t.fhirType() + "-" + t.getId() + "." + fmt.getExtension(), bs.toByteArray(), true);
}
Aggregations