use of org.hl7.fhir.definitions.model.TypeRef in project kindling by HL7.
the class SvgGenerator method addAttribute.
private void addAttribute(XMLWriter xml, double left, double top, ElementDefn e, String path, LineStatus ls, double height, double width) throws Exception {
if (e.getStandardsStatus() != null) {
xml.attribute("x", Double.toString(left + 1));
xml.attribute("y", Double.toString(top - height + GAP_HEIGHT));
xml.attribute("id", "n" + (++nc));
xml.attribute("width", Double.toString(width - 2));
xml.attribute("height", Double.toString(height));
xml.attribute("style", "fill:" + e.getStandardsStatus().getColorSvg() + ";stroke:black;stroke-width:0");
xml.element("rect", null);
}
xml.attribute("x", Double.toString(left + LEFT_MARGIN + (ls.line == 0 ? 0 : WRAP_INDENT)));
xml.attribute("y", Double.toString(top + LINE_HEIGHT * ls.line));
xml.attribute("fill", "black");
xml.attribute("class", "diagram-class-detail");
xml.attribute("id", "n" + (++nc));
xml.enter("text");
xml.attribute("xlink:href", baseUrl(path) + path + "." + e.getName().replace("[", "_").replace("]", "_"));
xml.attribute("id", "n" + (++nc));
xml.enter("a");
xml.element("title", e.getEnhancedDefinition());
xml.text(ls.see(e.getName()));
xml.exit("a");
xml.text(ls.see(" : "));
encodeType(xml, ls, getTypeCodeForElement(e.getTypes()));
xml.text(ls.see(" [" + e.describeCardinality() + "]"));
// now, the stereotypes
boolean hasTS = !((e.getTypes().isEmpty()) || (e.getTypes().size() == 1 && !isReference(e.getTypes().get(0).getName())));
boolean hasBinding = (e.hasBinding() && e.getBinding().getBinding() != BindingMethod.Unbound);
if (hasTS || hasBinding) {
xml.text(ls.see(" \u00AB "));
if (hasTS) {
if (isReference(e.getTypes().get(0).getName()) && e.getTypes().size() == 1) {
boolean first = true;
for (String p : e.getTypes().get(0).getParams()) {
if (first)
first = false;
else
xml.text(ls.see("|"));
ls.check(xml, left, top, p.length(), null);
encodeType(xml, ls, p);
}
} else {
boolean firstOuter = true;
for (TypeRef t : e.getTypes()) {
if (firstOuter)
firstOuter = false;
else
xml.text(ls.see("|"));
ls.check(xml, left, top, t.getName().length(), null);
encodeType(xml, ls, t.getName());
if (t.getParams().size() > 0) {
xml.text(ls.see("("));
boolean first = true;
for (String p : t.getParams()) {
if (first)
first = false;
else
xml.text(ls.see("|"));
ls.check(xml, left, top, p.length(), null);
encodeType(xml, ls, p);
}
xml.text(ls.see(")"));
}
}
}
}
if (hasTS && hasBinding) {
xml.text(ls.see("; "));
}
if (hasBinding) {
BindingSpecification b = e.getBinding();
String name = e.getBinding().getValueSet() != null ? e.getBinding().getValueSet().getName() : e.getBinding().getName();
if (name.toLowerCase().endsWith(" codes"))
name = name.substring(0, name.length() - 5);
if (name.length() > 30)
name = name.substring(0, 29) + "...";
String link = getBindingLink(prefix, e);
if (b.getStrength() == BindingStrength.EXAMPLE) {
if (link != null) {
xml.attribute("xlink:href", link);
xml.attribute("id", "n" + (++nc));
xml.enter("a");
xml.attribute("id", "n" + (++nc));
}
xml.element("title", b.getDefinition() + " (Strength=Example)");
for (String p : parts(name)) {
ls.check(xml, left, top, p.length(), link);
xml.text(ls.see(p));
}
if (link != null) {
xml.exit("a");
}
xml.text("??");
} else if (b.getStrength() == BindingStrength.PREFERRED) {
xml.attribute("xlink:href", link);
xml.attribute("id", "n" + (++nc));
xml.enter("a");
xml.element("title", b.getDefinition() + " (Strength=Preferred)");
for (String p : parts(name)) {
ls.check(xml, left, top, p.length(), link);
xml.text(ls.see(p));
}
xml.exit("a");
xml.text("?");
} else if (b.getStrength() == BindingStrength.EXTENSIBLE) {
// if (b.hasMax())
// what do in this case...
xml.attribute("xlink:href", link);
xml.attribute("id", "n" + (++nc));
xml.enter("a");
xml.attribute("id", "n" + (++nc));
xml.element("title", b.getDefinition() + " (Strength=Extensible)");
for (String p : parts(name)) {
ls.check(xml, left, top, p.length(), link);
xml.text(ls.see(p));
}
xml.exit("a");
xml.text("+");
} else if (b.getStrength() == BindingStrength.REQUIRED) {
xml.attribute("xlink:href", link);
xml.attribute("id", "n" + (++nc));
xml.enter("a");
xml.attribute("id", "n" + (++nc));
xml.element("title", b.getDefinition() + " (Strength=Required)");
// xml.open("b");
for (String p : parts(name)) {
ls.check(xml, left, top, p.length(), link);
xml.text(ls.see(p));
}
// xml.close("b");
xml.exit("a");
xml.text("!");
} else {
xml.attribute("id", "n" + (++nc));
xml.attribute("xlink:href", link);
xml.enter("a");
xml.attribute("id", "n" + (++nc));
xml.element("title", b.getDefinition() + " (??)");
for (String p : parts(name)) {
ls.check(xml, left, top, p.length(), link);
xml.text(ls.see(p));
}
xml.exit("a");
}
}
xml.text(ls.see(" \u00BB"));
}
xml.exit("text");
}
use of org.hl7.fhir.definitions.model.TypeRef in project kindling by HL7.
the class PageProcessor method dictForDt.
// private boolean notime;
private String dictForDt(String dt) throws Exception {
File tmp = Utilities.createTempFile("tmp", ".tmp");
DictHTMLGenerator gen = new DictHTMLGenerator(new FileOutputStream(tmp), this, "");
TypeParser tp = new TypeParser(version.toCode());
TypeRef t = tp.parse(dt, false, null, workerContext, true).get(0);
ElementDefn e;
if (t.getName().equals("Resource"))
e = definitions.getBaseResources().get("DomainResource").getRoot();
else
e = definitions.getElementDefn(t.getName());
if (e == null) {
gen.close();
throw new Exception("unable to find definition for " + dt);
} else {
gen.generate(e);
gen.close();
}
String val = TextFile.fileToString(tmp.getAbsolutePath()) + "\r\n";
tmp.delete();
return val;
}
use of org.hl7.fhir.definitions.model.TypeRef in project kindling by HL7.
the class PageProcessor method tsForDt.
private String tsForDt(String dt) throws Exception {
File tmp = Utilities.createTempFile("tmp", ".tmp");
tmp.deleteOnExit();
TerminologyNotesGenerator gen = new TerminologyNotesGenerator(new FileOutputStream(tmp), this);
TypeParser tp = new TypeParser(version.toCode());
TypeRef t = tp.parse(dt, false, null, workerContext, true).get(0);
ElementDefn e = definitions.getElementDefn(t.getName());
if (e == null) {
gen.close();
throw new Exception("unable to find definition for " + dt);
} else {
gen.generate("", e);
gen.close();
}
String val = TextFile.fileToString(tmp.getAbsolutePath()) + "\r\n";
tmp.delete();
return val;
}
use of org.hl7.fhir.definitions.model.TypeRef in project kindling by HL7.
the class PageProcessor method buildChoiceElementList.
private void buildChoiceElementList(StringBuilder b, String s, ElementDefn t) throws Exception {
if (t.getName().contains("[x]")) {
if (b.length() > 0)
b.append(",\r\n");
b.append(" ");
b.append("\"" + t.getPath() + "\": [");
boolean first = true;
for (TypeRef tt : t.getTypes()) {
if (first)
first = false;
else
b.append(", ");
b.append("\"");
b.append(tt.getName());
b.append("\"");
}
b.append("]");
}
for (ElementDefn e : t.getElements()) buildChoiceElementList(b, s, e);
}
use of org.hl7.fhir.definitions.model.TypeRef in project kindling by HL7.
the class PageProcessor method xmlForDt.
private String xmlForDt(String dt, String pn) throws Exception {
File tmp = Utilities.createTempFile("tmp", ".tmp");
XmlSpecGenerator gen = new XmlSpecGenerator(new FileOutputStream(tmp), pn == null ? null : pn.substring(0, pn.indexOf(".")) + "-definitions.html", null, this, "");
TypeParser tp = new TypeParser(version.toCode());
TypeRef t = tp.parse(dt, false, null, workerContext, true).get(0);
ElementDefn e = definitions.getElementDefn(t.getName());
if (e == null) {
gen.close();
throw new Exception("unable to find definition for " + dt);
} else {
gen.generate(e, e.getName().equals("Element") || e.getName().equals("BackboneElement"), false);
gen.close();
}
String val = TextFile.fileToString(tmp.getAbsolutePath()) + "\r\n";
tmp.delete();
return val;
}
Aggregations