use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method genSpanEntry.
private void genSpanEntry(HierarchicalTableGenerator gen, List<Row> rows, SpanEntry span) throws IOException {
Row row = gen.new Row();
rows.add(row);
row.setAnchor(span.getId());
// row.setColor(..?);
if (span.isProfile())
row.setIcon("icon_profile.png", HierarchicalTableGenerator.TEXT_ICON_PROFILE);
else
row.setIcon("icon_resource.png", HierarchicalTableGenerator.TEXT_ICON_RESOURCE);
row.getCells().add(gen.new Cell(null, null, span.getName(), null, null));
row.getCells().add(gen.new Cell(null, null, span.getCardinality(), null, null));
row.getCells().add(gen.new Cell(null, span.getProfileLink(), span.getType(), null, null));
row.getCells().add(gen.new Cell(null, null, span.getDescription(), null, null));
for (SpanEntry child : span.getChildren()) genSpanEntry(gen, row.getSubRows(), child);
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method generateGrid.
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, profile.getId());
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);
}
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method genTypes.
private Cell genTypes(HierarchicalTableGenerator gen, Row r, ElementDefinition e, String profileBaseFileName, StructureDefinition profile, String corePath, String imagePath) {
Cell c = gen.new Cell();
r.getCells().add(c);
List<TypeRefComponent> types = e.getType();
if (!e.hasType()) {
if (e.hasContentReference()) {
return c;
} else {
ElementDefinition d = (ElementDefinition) e.getUserData(DERIVATION_POINTER);
if (d != null && d.hasType()) {
types = new ArrayList<ElementDefinition.TypeRefComponent>();
for (TypeRefComponent tr : d.getType()) {
TypeRefComponent tt = tr.copy();
tt.setUserData(DERIVATION_EQUALS, true);
types.add(tt);
}
} else
return c;
}
}
boolean first = true;
TypeRefComponent tl = null;
for (TypeRefComponent t : types) {
if (first)
first = false;
else
c.addPiece(checkForNoChange(tl, gen.new Piece(null, ", ", null)));
tl = t;
if (t.hasTarget()) {
c.getPieces().add(gen.new Piece(corePath + "references.html", t.getWorkingCode(), null));
c.getPieces().add(gen.new Piece(null, "(", null));
boolean tfirst = true;
for (UriType u : t.getTargetProfile()) {
if (tfirst)
tfirst = false;
else
c.addPiece(gen.new Piece(null, " | ", null));
genTargetLink(gen, profileBaseFileName, corePath, c, t, u.getValue());
}
c.getPieces().add(gen.new Piece(null, ")", null));
if (t.getAggregation().size() > 0) {
c.getPieces().add(gen.new Piece(corePath + "valueset-resource-aggregation-mode.html", " {", null));
boolean firstA = true;
for (Enumeration<AggregationMode> a : t.getAggregation()) {
if (firstA = true)
firstA = false;
else
c.getPieces().add(gen.new Piece(corePath + "valueset-resource-aggregation-mode.html", ", ", null));
c.getPieces().add(gen.new Piece(corePath + "valueset-resource-aggregation-mode.html", codeForAggregation(a.getValue()), hintForAggregation(a.getValue())));
}
c.getPieces().add(gen.new Piece(corePath + "valueset-resource-aggregation-mode.html", "}", null));
}
} else if (t.hasProfile() && (!t.getWorkingCode().equals("Extension") || isProfiledType(t.getProfile()))) {
// a profiled type
String ref;
ref = pkp.getLinkForProfile(profile, t.getProfile().get(0).getValue());
if (ref != null) {
String[] parts = ref.split("\\|");
if (parts[0].startsWith("http:") || parts[0].startsWith("https:")) {
// c.addPiece(checkForNoChange(t, gen.new Piece(parts[0], "<" + parts[1] + ">", t.getCode()))); Lloyd
c.addPiece(checkForNoChange(t, gen.new Piece(parts[0], parts[1], t.getWorkingCode())));
} else {
// c.addPiece(checkForNoChange(t, gen.new Piece((t.getProfile().startsWith(corePath)? corePath: "")+parts[0], "<" + parts[1] + ">", t.getCode())));
c.addPiece(checkForNoChange(t, gen.new Piece((t.getProfile().get(0).getValue().startsWith(corePath + "StructureDefinition") ? corePath : "") + parts[0], parts[1], t.getWorkingCode())));
}
} else
c.addPiece(checkForNoChange(t, gen.new Piece((t.getProfile().get(0).getValue().startsWith(corePath) ? corePath : "") + ref, t.getWorkingCode(), null)));
} else {
String tc = t.getWorkingCode();
if (pkp != null && pkp.hasLinkFor(tc)) {
c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), tc, null)));
} else
c.addPiece(checkForNoChange(t, gen.new Piece(null, tc, null)));
}
}
return c;
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method generateSpanningTable.
public XhtmlNode generateSpanningTable(StructureDefinition profile, String imageFolder, boolean onlyConstraints, String constraintPrefix, Set<String> outputTracker) throws IOException, FHIRException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, false, true);
gen.setTranslator(getTranslator());
TableModel model = initSpanningTable(gen, "", false, profile.getId());
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);
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method generateTable.
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 {
// check it's ok to get rid of one of these
assert (diff != snapshot);
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true);
gen.setTranslator(getTranslator());
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId() + (diff ? "d" : "s"), false);
List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement();
List<StructureDefinition> profiles = new ArrayList<StructureDefinition>();
profiles.add(profile);
if (list.isEmpty()) {
ElementDefinition root = new ElementDefinition().setPath(profile.getType());
root.setId(profile.getType());
list.add(root);
}
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, null);
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);
}
}
Aggregations