use of org.hl7.fhir.definitions.model.ImplementationGuideDefn 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");
}
use of org.hl7.fhir.definitions.model.ImplementationGuideDefn in project kindling by HL7.
the class Publisher method copyStaticContent.
private void copyStaticContent() throws IOException, Exception {
if (page.getIni().getPropertyNames("support") != null)
for (String n : page.getIni().getPropertyNames("support")) {
Utilities.copyFile(new CSFile(page.getFolders().srcDir + n), new CSFile(page.getFolders().dstDir + n));
page.getHTMLChecker().registerFile(n, "Support File", HTMLLinkChecker.determineType(n), true);
}
for (String n : page.getIni().getPropertyNames("images")) {
copyImage(page.getFolders().imgDir, n);
}
for (ImplementationGuideDefn ig : page.getDefinitions().getSortedIgs()) {
for (String n : ig.getImageList()) {
copyIgImage(ig, n);
}
}
for (String n : page.getIni().getPropertyNames("files")) {
Utilities.copyFile(new CSFile(page.getFolders().rootDir + n), new CSFile(page.getFolders().dstDir + page.getIni().getStringProperty("files", n)));
page.getHTMLChecker().registerFile(page.getIni().getStringProperty("files", n), "Support File", HTMLLinkChecker.determineType(page.getIni().getStringProperty("files", n)), true);
}
page.log("Copy HTML templates", LogMessageType.Process);
Utilities.copyDirectory(page.getFolders().rootDir + page.getIni().getStringProperty("html", "source"), page.getFolders().dstDir, page.getHTMLChecker());
TextFile.stringToFile("\r\n[FHIR]\r\nFhirVersion=" + page.getVersion() + "-" + page.getBuildId() + "\r\nversion=" + page.getVersion().toCode() + "\r\nbuildId=" + page.getBuildId() + "\r\ndate=" + new SimpleDateFormat("yyyyMMddHHmmss").format(page.getGenDate().getTime()), Utilities.path(page.getFolders().dstDir, "version.info"), false);
for (String n : page.getDefinitions().getDiagrams().keySet()) {
page.log(" ...diagram " + n, LogMessageType.Process);
page.getSvgs().put(n, TextFile.fileToString(page.getFolders().srcDir + page.getDefinitions().getDiagrams().get(n)));
}
}
use of org.hl7.fhir.definitions.model.ImplementationGuideDefn in project kindling by HL7.
the class PageProcessor method produceDataTypeExtras.
private String produceDataTypeExtras(String tn, boolean profiles) {
int count = 0;
Map<String, StructureDefinition> map = new HashMap<String, StructureDefinition>();
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
boolean inc = false;
for (StructureDefinitionContextComponent ec : sd.getContext()) {
if (ec.getType() == ExtensionContextType.ELEMENT) {
inc = inc || matchesType(tn, ec.getExpression());
}
}
if (inc)
map.put(sd.getId(), sd);
}
StringBuilder b = new StringBuilder();
b.append(" <tr><td colspan=\"3\"><b>Extensions</b> (+ see <a href=\"" + definitions.getElementExtrasLink() + "\">extensions on all Elements</a>)</td></tr>\r\n");
for (String s : sorted(map.keySet())) {
StructureDefinition cs = map.get(s);
count++;
b.append(" <tr>\r\n");
String ref = cs.getUserString("path");
b.append(" <td><a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.getId())).append("</a></td>\r\n");
b.append(" <td>").append(Utilities.escapeXml(cs.getName())).append("</td>\r\n");
Profile ap = (Profile) cs.getUserData("profile");
if (ap == null)
b.append(" <td></td>\r\n");
else {
ImplementationGuideDefn ig = definitions.getIgs().get(ap.getCategory());
b.append(" <td>for <a href=\"" + ig.getPrefix() + ap.getId().toLowerCase() + ".html\">" + Utilities.escapeXml(ap.getTitle()) + "</a></td>\r\n");
}
b.append(" </tr>\r\n");
}
if (count == 0)
b.append("<tr><td>No Extensions defined for " + (tn.equals("primitives") ? "primitive types" : "this type") + " (though see <a href=\"element-extensions.html\">extensions on all Elements</a>)</td></tr>");
if (profiles) {
count = 0;
Map<String, CSPair> pmap = new HashMap<String, CSPair>();
for (Profile ap : definitions.getPackList()) {
for (ConstraintStructure cs : ap.getProfiles()) {
if (coversType(cs, tn))
pmap.put(cs.getTitle(), new CSPair(ap, cs));
}
}
b.append(" <tr><td colspan=\"3\"><b>Profiles</b></td></tr>\r\n");
for (String s : sorted(pmap.keySet())) {
CSPair cs = pmap.get(s);
ImplementationGuideDefn ig = definitions.getIgs().get(cs.p.getCategory());
count++;
b.append(" <tr>\r\n");
String ref = (ig.isCore() ? "" : ig.getCode() + File.separator) + cs.cs.getId() + ".html";
b.append(" <td><a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.cs.getTitle())).append("</a></td>\r\n");
b.append(" <td>").append(Utilities.escapeXml(cs.p.getDescription())).append("</td>\r\n");
ref = (ig.isCore() ? "" : ig.getCode() + File.separator) + cs.p.getId().toLowerCase() + ".html";
b.append(" <td>for <a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.p.getTitle())).append("</a></td>\r\n");
b.append(" </tr>\r\n");
}
if (count == 0)
b.append("<tr><td>No Profiles defined for for " + (tn.equals("primitives") ? "primitive types" : "this type") + "</td></tr>");
}
return b.toString();
}
use of org.hl7.fhir.definitions.model.ImplementationGuideDefn in project kindling by HL7.
the class PageProcessor method buildIgRegistry.
private String buildIgRegistry(ImplementationGuideDefn ig, String types) throws Exception {
StringBuilder b = new StringBuilder();
b.append("<table class=\"codes\">\r\n");
b.append("<tr><td><b>Id</b></td><td><b>Name</b></td><td><b>Description</b></td></tr>\r\n");
// examples second:
boolean example = false;
while (true) {
boolean usedPurpose = false;
for (String type : types.split("\\,")) {
List<String> ids = new ArrayList<String>();
Map<String, ImplementationGuideDefinitionResourceComponent> map = new HashMap<String, ImplementationGuideDefinitionResourceComponent>();
for (ImplementationGuideDefinitionResourceComponent r : ig.getIg().getDefinition().getResource()) {
Resource ar = (Resource) r.getUserData(ToolResourceUtilities.RES_ACTUAL_RESOURCE);
if (ar != null && ar.getResourceType().toString().equals(type) && r.hasExample() == example) {
String id = ar.getId();
ids.add(id);
map.put(id, r);
}
Example ex = (Example) r.getUserData(ToolResourceUtilities.NAME_RES_EXAMPLE);
if (ex != null && ex.getResourceName().equals(type) && r.hasExample() == example) {
String id = ex.getId();
ids.add(id);
map.put(id, r);
}
}
if (ids.size() > 0) {
if (!usedPurpose) {
b.append("<tr><td colspan=\"3\" style=\"background: #DFDFDF\"><b>" + (example ? "Specification" : "Example") + "</b> </td></tr>\r\n");
usedPurpose = true;
}
Collections.sort(ids);
b.append("<tr><td colspan=\"3\" style=\"background: #EFEFEF\">" + getTypePluralDesc(type) + "</td></tr>\r\n");
for (String id : ids) {
ImplementationGuideDefinitionResourceComponent r = map.get(id);
b.append("<tr><td><a href=\"" + Utilities.changeFileExt(r.getReference().getReference(), ".html") + "\">" + id + "</a></td><td>" + Utilities.escapeXml(r.getName()) + "</td><td>" + Utilities.escapeXml(r.getDescription()) + "</td></tr>\r\n");
}
}
}
if (example)
break;
else
example = true;
}
b.append("</table>\r\n");
return b.toString();
}
use of org.hl7.fhir.definitions.model.ImplementationGuideDefn in project kindling by HL7.
the class PageProcessor method genExtensionsTable.
private String genExtensionsTable() throws Exception {
StringBuilder s = new StringBuilder();
s.append("<table class=\"list\">\r\n");
s.append("<tr>");
s.append("<td><b>Identity</b></td>");
s.append("<td><b><a href=\"defining-extensions.html#cardinality\">Conf.</a></b></td>");
s.append("<td><b>Type</b></td>");
s.append("<td><b><a href=\"defining-extensions.html#context\">Context</a></b></td>");
s.append("<td><b><a href=\"versions.html#maturity\">FMM</a></b></td>");
s.append("</tr>");
List<String> names = new ArrayList<String>();
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) names.add(sd.getUrl());
Collections.sort(names);
Set<StructureDefinition> processed = new HashSet<StructureDefinition>();
for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
// if (ig.isCore()) {
for (String n : names) {
StructureDefinition ed = workerContext.fetchResource(StructureDefinition.class, n);
if (!processed.contains(ed)) {
processed.add(ed);
// if (ig.getCode().equals(ToolResourceUtilities.getUsage(ed))) {
genExtensionRow(ig, s, ed);
// }
}
}
// }
}
s.append("</table>\r\n");
return s.toString();
}
Aggregations