use of org.hl7.fhir.dstu2.utils.SimpleWorkerContext in project org.hl7.fhir.core by hapifhir.
the class R2R3ConversionManager method setR3Definitions.
public void setR3Definitions(InputStream stream) throws IOException, FHIRException {
needPrepare = true;
Map<String, InputStream> files = readInputStream(stream);
contextR3 = new SimpleWorkerContext();
contextR2.setAllowLoadingDuplicates(true);
contextR3.loadFromFile(files.get("profiles-types.xml"), "profiles-types.xml", null);
contextR3.loadFromFile(files.get("profiles-resources.xml"), "profiles-resources.xml", null);
contextR3.loadFromFile(files.get("extension-definitions.xml"), "extension-definitions.xml", null);
contextR3.loadFromFile(files.get("valuesets.xml"), "valuesets.xml", null);
contextR3.setCanRunWithoutTerminology(true);
}
use of org.hl7.fhir.dstu2.utils.SimpleWorkerContext in project org.hl7.fhir.core by hapifhir.
the class ToolsHelper method generateSnapshots.
private void generateSnapshots(String[] args) throws IOException, FHIRException {
if (args.length == 1) {
System.out.println("tools.jar snapshot-maker [source] -defn [definitions]");
System.out.println("");
System.out.println("Generates a snapshot from a differential. The nominated profile must have a single struture that has a differential");
System.out.println("");
System.out.println("source - the profile to generate the snapshot for. Maybe a file name, or a URL reference to a server running FHIR RESTful API");
System.out.println("definitions - filename for local copy of the validation.zip file");
}
String address = args[1];
String definitions = args[3];
SimpleWorkerContext context = SimpleWorkerContext.fromDefinitions(getDefinitions(definitions));
// } else {
throw new NotImplementedException("generating snapshots not done yet (address = " + address + ")");
// }
}
use of org.hl7.fhir.dstu2.utils.SimpleWorkerContext in project org.hl7.fhir.core by hapifhir.
the class ToolsHelper method generateSnapshots.
private void generateSnapshots(String[] args) throws IOException, FHIRException {
if (args.length == 1) {
System.out.println("tools.jar snapshot-maker [source] -defn [definitions]");
System.out.println("");
System.out.println("Generates a snapshot from a differential. The nominated profile must have a single struture that has a differential");
System.out.println("");
System.out.println("source - the profile to generate the snapshot for. Maybe a file name, or a URL reference to a server running FHIR RESTful API");
System.out.println("definitions - filename for local copy of the validation.zip file");
}
String address = args[1];
String definitions = args[3];
SimpleWorkerContext context = SimpleWorkerContext.fromDefinitions(getDefinitions(definitions));
// } else {
throw new NotImplementedException("generating snapshots not done yet (address = " + address + ")");
// }
}
use of org.hl7.fhir.dstu2.utils.SimpleWorkerContext in project org.hl7.fhir.core by hapifhir.
the class SimpleWorkerContext method fromClassPath.
public static SimpleWorkerContext fromClassPath(String name, boolean allowDuplicates) throws IOException, FHIRException {
InputStream s = SimpleWorkerContext.class.getResourceAsStream("/" + name);
SimpleWorkerContext res = new SimpleWorkerContext();
res.setAllowLoadingDuplicates(allowDuplicates);
res.loadFromStream(s, null);
return res;
}
use of org.hl7.fhir.dstu2.utils.SimpleWorkerContext in project org.hl7.fhir.core by hapifhir.
the class ValidationTestConvertor method main.
/**
* @param args
* @throws FHIRException
* @throws IOException
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException, IOException, FHIRException {
SimpleWorkerContext context = new SimpleWorkerContext.SimpleWorkerContextBuilder().fromPack("C:\\work\\org.hl7.fhir\\build\\publish\\validation-min.xml.zip");
for (File f : new File("C:\\work\\org.hl7.fhir\\build\\tests\\validation-examples").listFiles()) {
if (f.getAbsolutePath().endsWith(".xml")) {
File t = new File(Utilities.changeFileExt(f.getAbsolutePath(), ".ttl"));
if (!t.exists()) {
try {
System.out.print("Process " + f.getAbsolutePath());
Element e = Manager.parseSingle(context, new FileInputStream(f), FhirFormat.XML);
Manager.compose(context, e, new FileOutputStream(t), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
System.out.println(" .... success");
} catch (Exception e) {
System.out.println(" .... fail: " + e.getMessage());
}
}
}
if (f.getAbsolutePath().endsWith(".json")) {
if (!new File(Utilities.changeFileExt(f.getAbsolutePath(), ".ttl")).exists()) {
File t = new File(Utilities.changeFileExt(f.getAbsolutePath(), ".ttl"));
if (!t.exists()) {
try {
System.out.print("Process " + f.getAbsolutePath());
Element e = Manager.parseSingle(context, new FileInputStream(f), FhirFormat.JSON);
Manager.compose(context, e, new FileOutputStream(t), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
System.out.println(" .... success");
} catch (Exception e) {
System.out.println(" .... fail: " + e.getMessage());
}
}
}
}
}
}
Aggregations