Search in sources :

Example 21 with ResourceDefn

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

the class Publisher method cloneToXhtml.

private void cloneToXhtml(String n, String description, boolean adorn, String pageType, String crumbTitle, ImplementationGuideDefn igd, ResourceDefn rd, WorkGroup wg) throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document xdoc = builder.parse(new CSFileInputStream(new CSFile(page.getFolders().dstDir + n + ".xml")));
    XhtmlGenerator xhtml = new XhtmlGenerator(new ExampleAdorner(page.getDefinitions(), page.genlevel(Utilities.charCount(n, File.separatorChar))));
    ByteArrayOutputStream b = new ByteArrayOutputStream();
    xhtml.generate(xdoc, b, n.toUpperCase().substring(0, 1) + n.substring(1), description, 0, adorn, n + ".xml.html");
    String html = TextFile.fileToString(page.getFolders().templateDir + "template-example-xml.html").replace("<%example%>", b.toString());
    html = page.processPageIncludes(n + ".xml.html", html, pageType, null, n + ".xml.html", null, null, crumbTitle, (adorn && hasNarrative(xdoc)) ? new Boolean(true) : null, igd, rd, wg);
    TextFile.stringToFile(html, page.getFolders().dstDir + n + ".xml.html");
    // page.getEpub().registerFile(n + ".xml.html", description, EPubManager.XHTML_TYPE);
    page.getHTMLChecker().registerExternal(n + ".xml.html");
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) CSFile(org.hl7.fhir.utilities.CSFile) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(org.w3c.dom.Document) XhtmlDocument(org.hl7.fhir.utilities.xhtml.XhtmlDocument) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream) XhtmlGenerator(org.hl7.fhir.utilities.xml.XhtmlGenerator)

Example 22 with ResourceDefn

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

the class PageProcessor method cloneToXhtml.

private void cloneToXhtml(String src, String dst, String name, String description, int level, boolean adorn, String pageType, String crumbTitle, ImplementationGuideDefn ig, ResourceDefn rd, WorkGroup wg) throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document xdoc = builder.parse(new CSFileInputStream(new CSFile(src)));
    // XhtmlGenerator xhtml = new XhtmlGenerator(null);
    // xhtml.generate(xdoc, new CSFile(dst), name, description, level, adorn);
    String n = new File(dst).getName();
    n = n.substring(0, n.length() - 9);
    XhtmlGenerator xhtml = new XhtmlGenerator(new ExampleAdorner(definitions, genlevel(level)));
    ByteArrayOutputStream b = new ByteArrayOutputStream();
    xhtml.generate(xdoc, b, name, description, level, adorn, n + ".xml.html");
    String html = ("<%setlevel " + Integer.toString(level) + "%>" + TextFile.fileToString(folders.srcDir + "template-example-xml.html")).replace("<%example%>", b.toString());
    html = processPageIncludes(n + ".xml.html", html, pageType, null, n + ".xml.html", null, null, crumbTitle, (adorn && hasNarrative(xdoc)) ? new Boolean(true) : null, ig, rd, wg);
    TextFile.stringToFile(html, dst);
    htmlchecker.registerExternal(dst);
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) CSFile(org.hl7.fhir.utilities.CSFile) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(org.w3c.dom.Document) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream) XhtmlGenerator(org.hl7.fhir.utilities.xml.XhtmlGenerator)

Example 23 with ResourceDefn

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

the class PageProcessor method buildResListByCommittee.

private String buildResListByCommittee() {
    List<String> res = new ArrayList<String>();
    for (ResourceDefn rd : definitions.getBaseResources().values()) res.add(rd.getWg().getName() + ":" + rd.getName());
    for (ResourceDefn rd : definitions.getResources().values()) res.add(rd.getWg().getName() + ":" + rd.getName());
    Collections.sort(res);
    StringBuilder b = new StringBuilder();
    for (String s : sorted(definitions.getWorkgroups().keySet())) {
        WorkGroup wg = definitions.getWorkgroups().get(s);
        boolean first = true;
        for (String rn : res) {
            if (rn.startsWith(wg.getName() + ":")) {
                if (first) {
                    b.append("<p><b>");
                    b.append(Utilities.escapeXml(wg.getName()));
                    b.append("</b></p>\r\n<ul style=\"width: 90%; -moz-column-count: 4; -moz-column-gap: 10px; -webkit-column-count: 4; -webkit-column-gap: 10px; column-count: 4; column-gap: 10px\">\r\n");
                    first = false;
                }
                String r = rn.substring(rn.indexOf(":") + 1);
                b.append("  <li><a title=\"[%resdesc " + r + "%]\" href=\"" + r.toLowerCase() + ".html\">" + r + " [%fmmshort " + r + "%]</a></li>\r\n");
            }
        }
        if (!first)
            b.append("</ul>\r\n");
    }
    return b.toString();
}
Also used : WorkGroup(org.hl7.fhir.definitions.model.WorkGroup) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ArrayList(java.util.ArrayList) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 24 with ResourceDefn

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

the class PageProcessor method genOperationsSummary.

private String genOperationsSummary(List<Operation> oplist, ResourceDefn resource) throws Exception {
    StringBuilder b = new StringBuilder();
    b.append("<table class=\"list\">\r\n");
    for (Operation op : oplist) {
        b.append("<tr><td><a href=\"" + resource.getName().toLowerCase() + "-operation-" + op.getName() + ".html\">$" + Utilities.escapeXml(op.getName()) + "</a></td><td>" + Utilities.escapeXml(op.getTitle()) + "</td>");
        if (resource.getStatus() == StandardsStatus.NORMATIVE) {
            if (op.getStandardsStatus() == null)
                b.append("<td><a class=\"" + resource.getStatus().toCode() + "-flag\" href=\"versions.html#std-process\">" + resource.getStatus().toDisplay() + "</a></td>");
            else
                b.append("<td><a class=\"" + op.getStandardsStatus().toCode() + "-flag\" href=\"versions.html#std-process\">" + op.getStandardsStatus().toDisplay() + "</a></td>");
        }
        b.append("</tr>\r\n");
    }
    b.append("</table>\r\n");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) Operation(org.hl7.fhir.definitions.model.Operation)

Example 25 with ResourceDefn

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

the class PageProcessor method buildOpReferenceList.

private String buildOpReferenceList(String rt) {
    StringBuilder b = new StringBuilder();
    b.append("<ul>\r\n");
    for (String rn : definitions.sortedResourceNames()) {
        ResourceDefn rd = definitions.getResources().get(rn);
        for (Operation op : rd.getOperations()) {
            boolean ok = false;
            for (OperationExample ex : op.getExamples()) {
                if (ex.getContent().contains("&lt;" + rt) || ex.getContent().contains("\"" + rt + "\""))
                    ok = true;
            }
            for (OperationExample ex : op.getExamples2()) {
                if (ex.getContent().contains("<" + rt) || ex.getContent().contains("\"" + rt + "\""))
                    ok = true;
            }
            if (ok) {
                b.append(" <li><a href=\"" + rn.toLowerCase() + "-operation-" + op.getName().toLowerCase() + ".html#examples\">" + rn + "/$" + op.getName() + "</a></li>\r\n");
            }
        }
    }
    b.append("</ul>\r\n");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) Operation(org.hl7.fhir.definitions.model.Operation) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Aggregations

ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)75 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)42 ArrayList (java.util.ArrayList)38 FHIRException (org.hl7.fhir.exceptions.FHIRException)36 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)31 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)28 File (java.io.File)26 FileOutputStream (java.io.FileOutputStream)25 CSFile (org.hl7.fhir.utilities.CSFile)24 XmlParser (org.hl7.fhir.r5.formats.XmlParser)22 FileNotFoundException (java.io.FileNotFoundException)20 IOException (java.io.IOException)20 Example (org.hl7.fhir.definitions.model.Example)20 Profile (org.hl7.fhir.definitions.model.Profile)20 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)18 IniFile (org.hl7.fhir.utilities.IniFile)18 ImplementationGuideDefn (org.hl7.fhir.definitions.model.ImplementationGuideDefn)16 TransformerException (javax.xml.transform.TransformerException)15 TextFile (org.hl7.fhir.utilities.TextFile)15 SearchParameterDefn (org.hl7.fhir.definitions.model.SearchParameterDefn)14