use of org.hl7.fhir.definitions.generators.specification.MappingsGenerator in project kindling by HL7.
the class Publisher method produceLogicalModel.
private void produceLogicalModel(LogicalModel lm, ImplementationGuideDefn ig) throws Exception {
String n = lm.getId();
Map<String, String> examples = new HashMap<String, String>();
File tmp = Utilities.createTempFile("tmp", ".tmp");
TerminologyNotesGenerator tgen = new TerminologyNotesGenerator(new FileOutputStream(tmp), page);
if (lm.hasResource())
tgen.generate("", lm.getResource().getRoot());
else
tgen.generate("", lm.getDefinition());
tgen.close();
String tx = TextFile.fileToString(tmp.getAbsolutePath());
DictHTMLGenerator dgen = new DictHTMLGenerator(new FileOutputStream(tmp), page, "");
if (lm.hasResource())
dgen.generate(lm.getResource().getRoot());
else
dgen.generate(lm.getDefinition());
dgen.close();
String dict = TextFile.fileToString(tmp.getAbsolutePath());
MappingsGenerator mgen = new MappingsGenerator(page.getDefinitions());
if (lm.hasResource())
mgen.generate(lm.getResource());
else
mgen.generate(lm.getDefinition());
String mappings = mgen.getMappings();
String mappingsList = mgen.getMappingsList();
SvgGenerator svg = new SvgGenerator(page, "", lm.getLayout(), true, false, page.getVersion());
String fn = ig.getPrefix() + n;
if (lm.hasResource())
svg.generate(lm.getResource(), page.getFolders().dstDir + fn + ".svg", "2");
else
svg.generate(lm.getDefinition(), page.getFolders().dstDir + fn + ".svg", "2");
String prefix = page.getBreadCrumbManager().getIndexPrefixForReference(lm.getId() + ".html");
SectionTracker st = new SectionTracker(prefix, true);
st.start("");
page.getSectionTrackerCache().put(fn, st);
if (lm.getDefinition() != null) {
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, ig.getPrefix(), n + ".xml")), lm.getDefinition());
cloneToXhtml(ig.getPrefix() + n, "Logical Model " + lm.getDefinition().getName(), true, "logical-model", lm.getDefinition().getName(), null, lm.getWg());
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, ig.getPrefix(), n + ".json")), lm.getDefinition());
jsonToXhtml(ig.getPrefix() + n, "Logical Model " + lm.getDefinition().getName(), new JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(lm.getDefinition()), "logical-model", lm.getDefinition().getName(), null, lm.getWg());
ttlToXhtml(ig.getPrefix() + n, "Logical Model " + lm.getDefinition().getName(), new RdfParser().setOutputStyle(OutputStyle.PRETTY).composeString(lm.getDefinition()), "logical-model", lm.getDefinition().getName(), null, lm.getWg());
}
if (lm.getWg() != null && lm.getResource().getWg() == null)
lm.getResource().setWg(lm.getWg());
String template = "template-logical";
String src = TextFile.fileToString(page.getFolders().templateDir + template + ".html");
Map<String, String> values = new HashMap<String, String>();
if (lm.hasResource())
src = insertSectionNumbers(page.processResourceIncludes(n, lm.getResource(), "", "", "", tx, dict, src, mappings, mappingsList, "resource", n + ".html", ig, values, lm.getWg(), examples), st, n + ".html", ig.getLevel(), null);
else
src = insertSectionNumbers(new LogicalModelProcessor(n, page, ig, lm.getDefinition().getId(), "logical-model", n + ".html", lm.getDefinition(), tx, dict, examples, ig.getLogicalModels(), page.getDefinitions(), page.getVersion()).process(src), st, n + ".html", ig.getLevel(), null);
TextFile.stringToFile(src, page.getFolders().dstDir + fn + ".html");
page.getHTMLChecker().registerFile(fn + ".html", "Base Page for " + n, HTMLLinkChecker.XHTML_TYPE, true);
src = TextFile.fileToString(page.getFolders().templateDir + "template-logical-definitions.html");
if (lm.hasResource())
TextFile.stringToFile(insertSectionNumbers(page.processResourceIncludes(n, lm.getResource(), "", "", "", tx, dict, src, mappings, mappingsList, "res-Detailed Descriptions", n + "-definitions.html", ig, values, lm.getWg(), examples), st, n + "-definitions.html", ig.getLevel(), null), page.getFolders().dstDir + fn + "-definitions.html");
else
TextFile.stringToFile(insertSectionNumbers(new LogicalModelProcessor(n, page, ig, lm.getDefinition().getId(), "logical-model", n + ".html", lm.getDefinition(), tx, dict, examples, ig.getLogicalModels(), page.getDefinitions(), page.getVersion()).process(src), st, n + "-definitions.html", ig.getLevel(), null), page.getFolders().dstDir + fn + "-definitions.html");
page.getHTMLChecker().registerFile(fn + "-definitions.html", "Detailed Descriptions for " + (lm.hasResource() ? lm.getResource().getName() : lm.getDefinition().getName()), HTMLLinkChecker.XHTML_TYPE, true);
src = TextFile.fileToString(page.getFolders().templateDir + "template-logical-examples.html");
if (lm.hasResource())
TextFile.stringToFile(insertSectionNumbers(page.processResourceIncludes(n, lm.getResource(), "", "", "", tx, dict, src, mappings, mappingsList, "resource", n + ".html", ig, values, lm.getWg(), examples), st, n + ".html", ig.getLevel(), null), page.getFolders().dstDir + fn + "-implementations.html");
else
TextFile.stringToFile(insertSectionNumbers(new LogicalModelProcessor(n, page, ig, lm.getDefinition().getId(), "logical-model", n + ".html", lm.getDefinition(), tx, dict, examples, ig.getLogicalModels(), page.getDefinitions(), page.getVersion()).process(src), st, n + "-implementations.html", ig.getLevel(), null), page.getFolders().dstDir + fn + "-implementations.html");
page.getHTMLChecker().registerFile(fn + "-implementations.html", "Implementations for " + (lm.hasResource() ? lm.getResource().getName() : lm.getDefinition().getName()), HTMLLinkChecker.XHTML_TYPE, true);
src = TextFile.fileToString(page.getFolders().templateDir + "template-logical-mappings.html");
if (lm.hasResource())
TextFile.stringToFile(insertSectionNumbers(page.processResourceIncludes(n, lm.getResource(), "", "", "", tx, dict, src, mappings, mappingsList, "res-Mappings", n + "-mappings.html", ig, values, lm.getWg(), examples), st, n + "-mappings.html", ig.getLevel(), null), page.getFolders().dstDir + fn + "-mappings.html");
else
TextFile.stringToFile(insertSectionNumbers(new LogicalModelProcessor(n, page, ig, lm.getDefinition().getId(), "logical-model", n + ".html", lm.getDefinition(), tx, dict, examples, ig.getLogicalModels(), page.getDefinitions(), page.getVersion()).process(src), st, n + "-mappings.html", ig.getLevel(), null), page.getFolders().dstDir + fn + "-mappings.html");
page.getHTMLChecker().registerFile(fn + "-mappings.html", "Formal Mappings for " + n, HTMLLinkChecker.XHTML_TYPE, true);
src = TextFile.fileToString(page.getFolders().templateDir + "template-logical-analysis.html");
if (lm.hasResource())
TextFile.stringToFile(insertSectionNumbers(page.processResourceIncludes(n, lm.getResource(), "", "", "", tx, dict, src, mappings, mappingsList, "res-Analysis", n + "-analysis.html", ig, values, lm.getWg(), examples), st, n + "-analysis.html", ig.getLevel(), null), page.getFolders().dstDir + fn + "-analysis.html");
else
TextFile.stringToFile(insertSectionNumbers(new LogicalModelProcessor(n, page, ig, lm.getDefinition().getId(), "logical-model", n + ".html", lm.getDefinition(), tx, dict, examples, ig.getLogicalModels(), page.getDefinitions(), page.getVersion()).process(src), st, n + "-analysis.html", ig.getLevel(), null), page.getFolders().dstDir + fn + "-analysis.html");
page.getHTMLChecker().registerFile(fn + "-analysis.html", "Analysis for " + n, HTMLLinkChecker.XHTML_TYPE, true);
tmp.delete();
}
Aggregations