Search in sources :

Example 1 with SourceParser

use of org.hl7.fhir.definitions.parsers.SourceParser in project kindling by HL7.

the class Publisher method initialize.

private boolean initialize(String folder) throws Exception {
    HierarchicalTableGenerator.ACTIVE_TABLES = true;
    page.setDefinitions(new Definitions());
    page.getWorkerContext().setCanRunWithoutTerminology(!web);
    page.log("Checking Source for " + folder, LogMessageType.Process);
    List<String> errors = new ArrayList<String>();
    Utilities.checkFolder(page.getFolders().rootDir, errors);
    if (checkFile("required", page.getFolders().rootDir, "publish.ini", errors, "all")) {
        checkFile("required", page.getFolders().srcDir, "navigation.xml", errors, "all");
        page.setIni(new IniFile(page.getFolders().rootDir + "publish.ini"));
        page.setVersion(FHIRVersion.fromCode(page.getIni().getStringProperty("FHIR", "version")));
        prsr = new SourceParser(page, folder, page.getDefinitions(), web, page.getVersion(), page.getWorkerContext(), page.getGenDate(), page, fpUsages, isCIBuild);
        prsr.checkConditions(errors, dates);
        page.setRegistry(prsr.getRegistry());
        page.getDiffEngine().loadFromIni(prsr.getIni());
        for (String s : page.getIni().getPropertyNames("special-pages")) page.getDefinitions().getStructuralPages().add(s);
        Utilities.checkFolder(page.getFolders().xsdDir, errors);
        checkFile("required", page.getFolders().srcDir, "hierarchy.xml", errors, "all");
        checkFile("required", page.getFolders().srcDir, "fhir-all.xsd", errors, "all");
        checkFile("required", page.getFolders().templateDir, "template.html", errors, "all");
        checkFile("required", page.getFolders().templateDir, "template-book.html", errors, "all");
        checkFile("required", page.getFolders().srcDir, "mappingSpaces.xml", errors, "all");
        if (page.getIni().getPropertyNames("support") != null)
            for (String n : page.getIni().getPropertyNames("support")) checkFile("support", page.getFolders().srcDir, n, errors, "all");
        for (String n : page.getIni().getPropertyNames("images")) checkFile("image", page.getFolders().imgDir, n, errors, "all");
        for (String n : page.getIni().getPropertyNames("schema")) checkFile("schema", page.getFolders().srcDir, n, errors, "all");
        for (String n : page.getIni().getPropertyNames("pages")) checkFile("page", page.getFolders().srcDir, n, errors, "page-" + n);
        for (String n : page.getIni().getPropertyNames("files")) checkFile("file", page.getFolders().rootDir, n, errors, "page-" + n);
    }
    if (checkFile("translations", page.getFolders().rootDir + "implementations" + File.separator, "translations.xml", errors, null)) {
        // schema check
        XmlValidator xv = new XmlValidator(page.getValidationErrors(), page.getFolders().rootDir + "implementations", Utilities.path(page.getFolders().rootDir, "tools", "schematron"), new String[] { "translations.xsd" });
        xv.checkBySchema(Utilities.path(page.getFolders().rootDir, "implementations", "translations.xml"), true);
        Utilities.copyFile(page.getFolders().rootDir + "implementations" + File.separator + "translations.xml", page.getFolders().dstDir + "translations.xml");
        page.getTranslations().setLang("en");
        page.getTranslations().load(page.getFolders().rootDir + "implementations" + File.separator + "translations.xml");
    }
    if (errors.size() > 0)
        page.log("Unable to publish FHIR specification:", LogMessageType.Error);
    for (String e : errors) {
        page.log(e, LogMessageType.Error);
    }
    return errors.size() == 0;
}
Also used : XmlValidator(org.hl7.fhir.definitions.validation.XmlValidator) IniFile(org.hl7.fhir.utilities.IniFile) Definitions(org.hl7.fhir.definitions.model.Definitions) ArrayList(java.util.ArrayList) SourceParser(org.hl7.fhir.definitions.parsers.SourceParser)

Aggregations

ArrayList (java.util.ArrayList)1 Definitions (org.hl7.fhir.definitions.model.Definitions)1 SourceParser (org.hl7.fhir.definitions.parsers.SourceParser)1 XmlValidator (org.hl7.fhir.definitions.validation.XmlValidator)1 IniFile (org.hl7.fhir.utilities.IniFile)1