public XhtmlNode generateTable(String defFile, StructureDefinition profile, boolean diff, String imageFolder, boolean inlineGraphics, String profileBaseFileName, boolean snapshot, String corePath, String imagePath, boolean logicalModel, boolean allInvariants, Set<String> outputTracker) throws IOException, FHIRException { assert(diff != snapshot);// check it's ok to get rid of one of these HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true); gen.setTranslator(getTranslator()); TableModel model = gen.initNormalTable(corePath, false); List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement(); List<StructureDefinition> profiles = new ArrayList<StructureDefinition>(); profiles.add(profile); if (list.isEmpty()) throw new FHIRException((diff ? "Differential" : "Snapshot") + " is empty generating hierarchical table for "+profile.getUrl()); genElement(defFile == null ? null : defFile+"#", gen, model.getRows(), list.get(0), list, profiles, diff, profileBaseFileName, null, snapshot, corePath, imagePath, true, logicalModel, profile.getDerivation() == TypeDerivationRule.CONSTRAINT && usesMustSupport(list), allInvariants); try { return gen.generate(model, imagePath, 0, outputTracker); } catch (org.hl7.fhir.exceptions.FHIRException e) { throw new FHIRException("Error generating table for profile " + profile.getUrl() + ": " + e.getMessage(), e); } }
public XhtmlNode generateGrid(String defFile, StructureDefinition profile, String imageFolder, boolean inlineGraphics, String profileBaseFileName, String corePath, String imagePath, Set<String> outputTracker) throws IOException, FHIRException { HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true); gen.setTranslator(getTranslator()); TableModel model = gen.initGridTable(corePath); List<ElementDefinition> list = profile.getSnapshot().getElement(); List<StructureDefinition> profiles = new ArrayList<StructureDefinition>(); profiles.add(profile); genGridElement(defFile == null ? null : defFile+"#", gen, model.getRows(), list.get(0), list, profiles, true, profileBaseFileName, null, corePath, imagePath, true, profile.getDerivation() == TypeDerivationRule.CONSTRAINT && usesMustSupport(list)); try { return gen.generate(model, imagePath, 1, outputTracker); } catch (org.hl7.fhir.exceptions.FHIRException e) { throw new FHIRException(e.getMessage(), e); } }
private void checkModel(TableModel model) throws FHIRException { check(!model.getRows().isEmpty(), "Must have rows"); check(!model.getTitles().isEmpty(), "Must have titles"); for (Cell c : model.getTitles()) check(c); int i = 0; for (Row r : model.getRows()) { check(r, "rows", model.getTitles().size(), Integer.toString(i)); i++; } }
private String checkExists(List<Integer> indents, boolean hasChildren, int lineColor, Set<String> outputTracker) throws IOException { String filename = makeName(indents); return files.get(filename); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); genImage(indents, hasChildren, lineColor, bytes); b.append("data: image/png;base64,"); byte[] encodeBase64 = Base64.encodeBase64(bytes.toByteArray()); if (!new File(file).exists()) { FileOutputStream stream = new FileOutputStream(file); genImage(indents, hasChildren, lineColor, stream); if (outputTracker!=null) outputTracker.add(file);
public XhtmlNode generateSpanningTable(StructureDefinition profile, String imageFolder, boolean onlyConstraints, String constraintPrefix, Set<String> outputTracker) throws IOException, FHIRException { HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, false); gen.setTranslator(getTranslator()); TableModel model = initSpanningTable(gen, "", false); Set<String> processed = new HashSet<String>(); SpanEntry span = buildSpanningTable("(focus)", "", profile, processed, onlyConstraints, constraintPrefix); genSpanEntry(gen, model.getRows(), span); return gen.generate(model, "", 0, outputTracker); }
public XhtmlNode generate(TableModel model, String imagePath, int border, Set<String> outputTracker) throws IOException, FHIRException { checkModel(model); XhtmlNode table = new XhtmlNode(NodeType.Element, "table").setAttribute("border", Integer.toString(border)).setAttribute("cellspacing", "0").setAttribute("cellpadding", "0"); table.setAttribute("style", "border: " + border + "px #F0F0F0 solid; font-size: 11px; font-family: verdana; vertical-align: top;"); XhtmlNode tc = null; for (Title t : model.getTitles()) { tc = renderCell(tr, t, "th", null, null, null, false, null, "white", 0, imagePath, border, outputTracker); if (t.width != 0) tc.setAttribute("style", "width: "+Integer.toString(t.width)+"px"); renderRow(table, r, 0, new ArrayList<Integer>(), imagePath, border, outputTracker); tc.setAttribute("colspan", Integer.toString(model.getTitles().size())); tc.addTag("br"); XhtmlNode a = tc.addTag("a").setAttribute("title", translate("sd.doco", "Legend for this format")).setAttribute("href", model.getDocoRef()); if (model.getDocoImg() != null) a.addTag("img").setAttribute("alt", "doco").setAttribute("style", "background-color: inherit").setAttribute("src", model.getDocoImg()); a.addText(" "+translate("sd.doco", "Documentation for this format"));
tc.setAttribute("class", "hierarchy"); if (indents != null) { tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_spacer.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); tc.setAttribute("style", "vertical-align: top; text-align : left; background-color: "+color+"; border: "+ border +"px #F0F0F0 solid; padding:0px 4px 0px 4px; white-space: nowrap; background-image: url("+imagePath+checkExists(indents, hasChildren, lineColor, outputTracker)+")"); for (int i = 0; i < indents.size()-1; i++) { switch (indents.get(i)) { case NEW_SLICER: case NEW_SLICE: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_blank.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break; case CONTINUE_REGULAR: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vline.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break; case CONTINUE_SLICER: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vline_slicer.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break; case CONTINUE_SLICE: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vline_slice.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break; default: switch (indents.get(indents.size()-1)) { case NEW_REGULAR: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vjoin_end.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break; case NEW_SLICER: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vjoin_end_slicer.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break;
public XhtmlNode generate(TableModel model, String imagePath, int border, Set<String> outputTracker) throws IOException, FHIRException { checkModel(model); XhtmlNode table = new XhtmlNode(NodeType.Element, "table").setAttribute("border", Integer.toString(border)).setAttribute("cellspacing", "0").setAttribute("cellpadding", "0"); table.setAttribute("style", "border: " + border + "px #F0F0F0 solid; font-size: 11px; font-family: verdana; vertical-align: top;"); XhtmlNode tc = null; for (Title t : model.getTitles()) { tc = renderCell(tr, t, "th", null, null, null, false, null, "white", 0, imagePath, border, outputTracker); if (t.width != 0) tc.setAttribute("style", "width: "+Integer.toString(t.width)+"px"); renderRow(table, r, 0, new ArrayList<Integer>(), imagePath, border, outputTracker); tc.setAttribute("colspan", Integer.toString(model.getTitles().size())); tc.addTag("br"); XhtmlNode a = tc.addTag("a").setAttribute("title", translate("sd.doco", "Legend for this format")).setAttribute("href", model.getDocoRef()); if (model.getDocoImg() != null) a.addTag("img").setAttribute("alt", "doco").setAttribute("style", "background-color: inherit").setAttribute("src", model.getDocoImg()); a.addText(" "+translate("sd.doco", "Documentation for this format"));
tc.setAttribute("class", "hierarchy"); if (indents != null) { tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_spacer.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); tc.setAttribute("style", "vertical-align: top; text-align : left; background-color: "+color+"; border: "+ border +"px #F0F0F0 solid; padding:0px 4px 0px 4px; white-space: nowrap; background-image: url("+imagePath+checkExists(indents, hasChildren, lineColor, outputTracker)+")"); for (int i = 0; i < indents.size()-1; i++) { switch (indents.get(i)) { case NEW_SLICER: case NEW_SLICE: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_blank.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break; case CONTINUE_REGULAR: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vline.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break; case CONTINUE_SLICER: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vline_slicer.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break; case CONTINUE_SLICE: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vline_slice.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break; default: switch (indents.get(indents.size()-1)) { case NEW_REGULAR: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vjoin_end.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break; case NEW_SLICER: tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vjoin_end_slicer.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", "."); break;
private String checkExists(List<Integer> indents, boolean hasChildren, int lineColor, Set<String> outputTracker) throws IOException { String filename = makeName(indents); return files.get(filename); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); genImage(indents, hasChildren, lineColor, bytes); b.append("data: image/png;base64,"); byte[] encodeBase64 = Base64.encodeBase64(bytes.toByteArray()); if (!new File(file).exists()) { FileOutputStream stream = new FileOutputStream(file); genImage(indents, hasChildren, lineColor, stream); if (outputTracker!=null) outputTracker.add(file);
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, String imagePath, Set<String> outputTracker) throws IOException, FHIRException { HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true); gen.setTranslator(getTranslator()); TableModel model = gen.initNormalTable(corePath, false); return gen.generate(model, corePath, 0, outputTracker); } catch (org.hl7.fhir.exceptions.FHIRException e) { throw new FHIRException(e.getMessage(), e);
public XhtmlNode generateGrid(String defFile, StructureDefinition profile, String imageFolder, boolean inlineGraphics, String profileBaseFileName, String corePath, String imagePath, Set<String> outputTracker) throws IOException, FHIRException { HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics); gen.setTranslator(getTranslator()); TableModel model = gen.initGridTable(corePath); List<ElementDefinition> list = profile.getSnapshot().getElement(); List<StructureDefinition> profiles = new ArrayList<StructureDefinition>(); profiles.add(profile); genGridElement(defFile == null ? null : defFile+"#", gen, model.getRows(), list.get(0), list, profiles, true, profileBaseFileName, null, corePath, imagePath, true, profile.getDerivation() == TypeDerivationRule.CONSTRAINT && usesMustSupport(list)); try { return gen.generate(model, imagePath, 1, outputTracker); } catch (org.hl7.fhir.exceptions.FHIRException e) { throw new FHIRException(e.getMessage(), e); } }
private void check(Row r, String string, int size, String path) throws FHIRException { check(r.getCells().size() == size, "All rows must have the same number of columns ("+Integer.toString(size)+") as the titles but row "+path+" doesn't ("+r.getCells().get(0).text()+"): "+r.getCells()); int i = 0; for (Row c : r.getSubRows()) { check(c, "rows", size, path+"."+Integer.toString(i)); i++; } }
public XhtmlNode generateTable(String defFile, StructureDefinition profile, boolean diff, String imageFolder, boolean inlineGraphics, String profileBaseFileName, boolean snapshot, String corePath, String imagePath, boolean logicalModel, boolean allInvariants, Set<String> outputTracker) throws IOException, FHIRException { assert(diff != snapshot);// check it's ok to get rid of one of these HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics); gen.setTranslator(getTranslator()); TableModel model = gen.initNormalTable(corePath, false); List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement(); List<StructureDefinition> profiles = new ArrayList<StructureDefinition>(); profiles.add(profile); genElement(defFile == null ? null : defFile+"#", gen, model.getRows(), list.get(0), list, profiles, diff, profileBaseFileName, null, snapshot, corePath, imagePath, true, logicalModel, profile.getDerivation() == TypeDerivationRule.CONSTRAINT && usesMustSupport(list), allInvariants); try { return gen.generate(model, imagePath, 0, outputTracker); } catch (org.hl7.fhir.exceptions.FHIRException e) { throw new FHIRException(e.getMessage(), e); } }
public XhtmlNode generateGrid(String defFile, StructureDefinition profile, String imageFolder, boolean inlineGraphics, String profileBaseFileName, String corePath, String imagePath, Set<String> outputTracker) throws IOException, FHIRException { HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true); gen.setTranslator(getTranslator()); TableModel model = gen.initGridTable(corePath); List<ElementDefinition> list = profile.getSnapshot().getElement(); List<StructureDefinition> profiles = new ArrayList<StructureDefinition>(); profiles.add(profile); genGridElement(defFile == null ? null : defFile+"#", gen, model.getRows(), list.get(0), list, profiles, true, profileBaseFileName, null, corePath, imagePath, true, profile.getDerivation() == TypeDerivationRule.CONSTRAINT && usesMustSupport(list)); try { return gen.generate(model, imagePath, 1, outputTracker); } catch (org.hl7.fhir.exceptions.FHIRException e) { throw new FHIRException(e.getMessage(), e); } }
private void check(Cell c) throws FHIRException { boolean hasText = false; for (Piece p : c.pieces) if (!Utilities.noString(p.getText())) hasText = true; check(hasText, "Title cells must have text"); }
public XhtmlNode generateTable(String defFile, StructureDefinition profile, boolean diff, String imageFolder, boolean inlineGraphics, String profileBaseFileName, boolean snapshot, String corePath, String imagePath, boolean logicalModel, boolean allInvariants, Set<String> outputTracker) throws IOException, FHIRException { assert(diff != snapshot);// check it's ok to get rid of one of these HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true); gen.setTranslator(getTranslator()); TableModel model = gen.initNormalTable(corePath, false); List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement(); List<StructureDefinition> profiles = new ArrayList<StructureDefinition>(); profiles.add(profile); if (list.isEmpty()) throw new FHIRException((diff ? "Differential" : "Snapshot") + " is empty generating hierarchical table for "+profile.getUrl()); genElement(defFile == null ? null : defFile+"#", gen, model.getRows(), list.get(0), list, profiles, diff, profileBaseFileName, null, snapshot, corePath, imagePath, true, logicalModel, profile.getDerivation() == TypeDerivationRule.CONSTRAINT && usesMustSupport(list), allInvariants); try { return gen.generate(model, imagePath, 0, outputTracker); } catch (org.hl7.fhir.exceptions.FHIRException e) { throw new FHIRException("Error generating table for profile " + profile.getUrl() + ": " + e.getMessage(), e); } }
private void checkModel(TableModel model) throws FHIRException { check(!model.getRows().isEmpty(), "Must have rows"); check(!model.getTitles().isEmpty(), "Must have titles"); for (Cell c : model.getTitles()) check(c); int i = 0; for (Row r : model.getRows()) { check(r, "rows", model.getTitles().size(), Integer.toString(i)); i++; } }
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, String imagePath, Set<String> outputTracker) throws IOException, FHIRException { HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics); gen.setTranslator(getTranslator()); TableModel model = gen.initNormalTable(corePath, false); return gen.generate(model, corePath, 0, outputTracker); } catch (org.hl7.fhir.exceptions.FHIRException e) { throw new FHIRException(e.getMessage(), e);
private void check(Row r, String string, int size, String path) throws FHIRException { check(r.getCells().size() == size, "All rows must have the same number of columns ("+Integer.toString(size)+") as the titles but row "+path+" doesn't ("+r.getCells().get(0).text()+"): "+r.getCells()); int i = 0; for (Row c : r.getSubRows()) { check(c, "rows", size, path+"."+Integer.toString(i)); i++; } }