Example #1
0
 private void saveToCache(ValidationResult res, String cacheName) throws IOException {
   if (cacheName == null) return;
   if (res.getDisplay() != null) TextFile.stringToFile(res.getDisplay(), cacheName);
   else if (res.getMessage() != null) {
     if (res.getSeverity() == IssueSeverity.WARNING)
       TextFile.stringToFile("!warning: " + res.getMessage(), cacheName);
     else TextFile.stringToFile("!error: " + res.getMessage(), cacheName);
   }
 }
 private void doTest(String name) throws FileNotFoundException, IOException, FHIRException {
   String workingDirectory =
       "C:\\work\\org.hl7.fhir.2016May\\build\\publish"; // FileSystems.getDefault().getPath(System.getProperty("user.dir"), "data").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.fetchResource(
           StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + 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());
 }