Search in sources :

Example 1 with ImplementationGuideDefinitionPageComponent

use of org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionPageComponent in project kindling by HL7.

the class Publisher method produceIgPage.

private void produceIgPage(ImplementationGuideDefn ig, ImplementationGuideDefinitionPageComponent p) throws Exception {
    String actualName = Utilities.path(page.getFolders().rootDir, Utilities.getDirectoryForFile(ig.getSource()), p.getNameUrlType().getValue());
    String logicalName = Utilities.fileTitle(actualName);
    String src;
    if (IgParser.getKind(p) == GuidePageKind.TOC)
        src = TextFile.fileToString(Utilities.path(page.getFolders().templateDir, "template-ig-toc.html"));
    else
        throw new Exception("Unsupported special page kind " + IgParser.getKind(p).toCode());
    String file = ig.getCode() + File.separator + logicalName + ".html";
    src = page.processPageIncludes(file, src, "page", null, null, null, logicalName, ig, null, null);
    // before we save this page out, we're going to figure out what it's index
    // is, and number the headers if we can
    src = addSectionNumbers(file, logicalName, src, null, 1, null, ig);
    TextFile.stringToFile(src, Utilities.path(page.getFolders().dstDir, file));
    src = TextFile.fileToString(Utilities.path(page.getFolders().dstDir, file)).replace("<body>", "<body style=\"margin: 10px\">");
    src = page.processPageIncludesForBook(file, src, "page", null, ig, null);
    cachePage(file, src, logicalName, true);
}
Also used : TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with ImplementationGuideDefinitionPageComponent

use of org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionPageComponent in project kindling by HL7.

the class IgParser method processPage.

private void processPage(ImplementationGuideDefinitionPageComponent page, ImplementationGuideDefn igd) throws Exception {
    if (!page.hasTitle())
        throw new Exception("Page " + page.getNameUrlType().getValue() + " has no name");
    if (getKind(page) == null || getKind(page) == GuidePageKind.PAGE || getKind(page) == GuidePageKind.DIRECTORY || getKind(page) == GuidePageKind.LIST || getKind(page) == GuidePageKind.RESOURCE) {
        checkExists(igd, page.getNameUrlType().getValue());
        igd.getPageList().add(page.getNameUrlType().getValue());
    }
    for (ImplementationGuideDefinitionPageComponent pp : page.getPage()) {
        processPage(pp, igd);
    }
}
Also used : ImplementationGuideDefinitionPageComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionPageComponent)

Example 3 with ImplementationGuideDefinitionPageComponent

use of org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionPageComponent in project kindling by HL7.

the class ImplementationGuideDefn method findLogicalPage.

private boolean findLogicalPage(String n, String type, List<LinkTriple> res, List<ImplementationGuideDefinitionPageComponent> page) throws Exception {
    // see if we can find it as an example of an existing profile
    String src = Utilities.fileTitle(n) + ".html";
    for (ImplementationGuideDefinitionResourceComponent r : ig.getDefinition().getResource()) {
        if (src.equals(r.getReference().getReference())) {
            if (r.hasExampleCanonicalType()) {
                String psrc = r.getExampleCanonicalType().getValueAsString().substring(r.getExampleCanonicalType().getValueAsString().lastIndexOf("/") + 1) + ".html";
                if (findPage(psrc, res, page)) {
                    res.add(new LinkTriple(null, r.getName(), null));
                    return true;
                }
            }
        }
    }
    // now, see if we can find a registry to make it a child of
    String id = Utilities.fileTitle(n);
    for (Example e : examples) {
        if (e.getId().equals(id))
            if (findRegistryPage(e.getResourceName(), res, page)) {
                res.add(new LinkTriple(null, e.getName(), null));
                return true;
            }
    }
    if (type.startsWith("profile:"))
        if (findRegistryPage("StructureDefinition", res, page)) {
            res.add(new LinkTriple(null, "Profile", null));
            return true;
        }
    if (findModified(n, "-operations.html", "Operations", res, page))
        return true;
    if (findModified(n, "-questionnaire.html", "Questionnaire", res, page))
        return true;
    if (findModified(n, ".profile.html", "StructureDefinition", res, page))
        return true;
    return false;
}
Also used : ImplementationGuideDefinitionResourceComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent)

Example 4 with ImplementationGuideDefinitionPageComponent

use of org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionPageComponent in project kindling by HL7.

the class ImplementationGuideDefn method addPage.

private void addPage(HierarchicalTableGenerator gen, List<Row> rows, ImplementationGuideDefinitionPageComponent page) throws FHIRException {
    Row row = gen.new Row();
    rows.add(row);
    row.setIcon(getIcon(IgParser.getKind(page)), IgParser.getKind(page).getDisplay());
    String ndx = page.getUserString(ToolResourceUtilities.NAME_PAGE_INDEX);
    if (ndx == null)
        ndx = "";
    else
        ndx = ndx + " ";
    row.getCells().add(gen.new Cell("", page.getNameUrlType().getValue(), ndx + page.getTitle(), null, null));
    for (ImplementationGuideDefinitionPageComponent p : page.getPage()) {
        addPage(gen, row.getSubRows(), p);
    }
}
Also used : Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) ImplementationGuideDefinitionPageComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionPageComponent)

Example 5 with ImplementationGuideDefinitionPageComponent

use of org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionPageComponent in project kindling by HL7.

the class ImplementationGuideDefn method numberPages.

private void numberPages(List<ImplementationGuideDefinitionPageComponent> list, String prefix) {
    for (int i = 0; i < list.size(); i++) {
        ImplementationGuideDefinitionPageComponent page = list.get(i);
        page.setUserData(ToolResourceUtilities.NAME_PAGE_INDEX, prefix + Integer.toString(i + 1) + (page.hasPage() ? ".0" : ""));
        numberPages(page.getPage(), prefix + Integer.toString(i + 1) + ".");
    }
}
Also used : ImplementationGuideDefinitionPageComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionPageComponent)

Aggregations

ImplementationGuideDefinitionPageComponent (org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionPageComponent)5 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 TransformerException (javax.xml.transform.TransformerException)2 ImplementationGuideDefn (org.hl7.fhir.definitions.model.ImplementationGuideDefn)2 FHIRException (org.hl7.fhir.exceptions.FHIRException)2 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)2 ValueSet (org.hl7.fhir.r5.model.ValueSet)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URISyntaxException (java.net.URISyntaxException)1 HashSet (java.util.HashSet)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1