Search in sources :

Example 1 with PageInformation

use of org.hl7.fhir.definitions.model.Definitions.PageInformation in project kindling by HL7.

the class Publisher method processWarnings.

private void processWarnings(boolean showOnlyErrors) throws Exception {
    String xslt = Utilities.path(page.getFolders().rootDir, "implementations", "xmltools", "OwnerResources.xslt");
    OutputStreamWriter s = new OutputStreamWriter(new FileOutputStream(page.getFolders().dstDir + "warnings.xml"), "UTF-8");
    s.write("<warnings>");
    for (WorkGroup wg : page.getDefinitions().getWorkgroups().values()) {
        s.write("<wg code=\"" + wg.getCode() + "\" name=\"" + wg.getName() + "\" url=\"" + wg.getUrl() + "\"/>\r\n");
    }
    for (PageInformation pn : page.getDefinitions().getPageInfo().values()) {
        s.write("<page name=\"" + pn.getName() + "\" wg=\"" + pn.getWgCode() + "\" fmm=\"" + pn.getFmm() + "\"/>\r\n");
    }
    try {
        s.write(new String(XsltUtilities.saxonTransform(page.getFolders().dstDir + "profiles-resources.xml", xslt)));
        s.write(new String(XsltUtilities.saxonTransform(page.getFolders().dstDir + "profiles-types.xml", xslt)));
        s.write(new String(XsltUtilities.saxonTransform(page.getFolders().dstDir + "profiles-others.xml", xslt)));
    } catch (Exception e) {
        for (ValidationMessage err : page.getValidationErrors()) {
            if (!page.getSuppressedMessages().contains(err.getDisplay()))
                System.out.println(err.summary());
        }
        System.out.println("WARNING: Unable to create warnings file - one or more profiles-* files unavailable or invalid");
        System.out.println("To determine the cause of the build failure, look in the log prior to the warning and information messages immediately above");
    }
    for (ValidationMessage e : page.getValidationErrors()) {
        if (!page.getSuppressedMessages().contains(e.getDisplay()))
            s.write(e.toXML());
    }
    s.write("</warnings>");
    s.flush();
    s.close();
    String xslt2 = Utilities.path(page.getFolders().rootDir, "implementations", "xmltools", "CategorizeWarnings.xslt");
    FileOutputStream s2 = new FileOutputStream(page.getFolders().dstDir + "work-group-warnings.xml");
    try {
        s2.write(XsltUtilities.saxonTransform(page.getFolders().dstDir + "warnings.xml", xslt2).getBytes("UTF8"));
    } catch (Exception e) {
    // nothing - do not want to know.
    }
    s2.flush();
    s2.close();
    String xslt3 = Utilities.path(page.getFolders().rootDir, "implementations", "xmltools", "RenderWarnings.xslt");
    try {
        String hw = XsltUtilities.saxonTransform(page.getFolders().dstDir + "work-group-warnings.xml", xslt3);
        if (!showOnlyErrors)
            page.log(hw, LogMessageType.Process);
    } catch (Exception e) {
    // nothing - do not want to know.
    }
    int i = 0;
    int w = 0;
    int ee = 0;
    for (ValidationMessage e : page.getValidationErrors()) {
        if (e.getLevel() == IssueSeverity.ERROR || e.getLevel() == IssueSeverity.FATAL) {
            ee++;
            page.log(e.summary(), LogMessageType.Hint);
        } else if (e.getLevel() == IssueSeverity.WARNING) {
            w++;
        } else if (e.getLevel() == IssueSeverity.INFORMATION) {
            i++;
        }
    }
    page.getQa().setCounts(ee, w, i);
}
Also used : WorkGroup(org.hl7.fhir.definitions.model.WorkGroup) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) PageInformation(org.hl7.fhir.definitions.model.Definitions.PageInformation) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 TransformerException (javax.xml.transform.TransformerException)1 PageInformation (org.hl7.fhir.definitions.model.Definitions.PageInformation)1 WorkGroup (org.hl7.fhir.definitions.model.WorkGroup)1 FHIRException (org.hl7.fhir.exceptions.FHIRException)1 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)1 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)1