use of org.hl7.fhir.definitions.model.TypeRef in project kindling by HL7.
the class XSDGenerator method generateAny.
private void generateAny(ElementDefn root, ElementDefn e) throws Exception {
String close = " minOccurs=\"0\">";
if (!forCodeGeneration) {
write(" <xs:choice minOccurs=\"" + e.getMinCardinality().toString() + "\" maxOccurs=\"1\">\r\n");
if (e.hasDefinition()) {
write(" <xs:annotation>\r\n");
write(" <xs:documentation xml:lang=\"en\">" + Utilities.escapeXml(e.getDefinition()) + "</xs:documentation>\r\n");
write(" </xs:annotation>\r\n");
}
close = "/>";
}
for (TypeRef t : datatypes) {
if (t.isResourceReference()) {
write(" <xs:element name=\"Resource\" type=\"Reference\"" + close + "\r\n");
} else {
write(" <xs:element name=\"" + t.getName() + "\" type=\"" + t.getName() + "\"" + close + "\r\n");
}
if (forCodeGeneration) {
write(" <xs:annotation>\r\n");
if (e.hasDefinition()) {
write(" <xs:documentation xml:lang=\"en\">" + Utilities.escapeXml(e.getDefinition()) + " (choose any one of the elements, but only one)</xs:documentation>\r\n");
} else {
write(" <xs:documentation xml:lang=\"en\">(choose any one of the elements, but only one)</xs:documentation>\r\n");
}
write(" </xs:annotation>\r\n");
write(" </xs:element>\r\n");
}
}
if (!forCodeGeneration)
write(" </xs:choice>\r\n");
}
use of org.hl7.fhir.definitions.model.TypeRef in project kindling by HL7.
the class JsonSpecGenerator method writeTypeLinks.
/*
private String docPrefix(int widthSoFar, int indent, ElementDefinition elem) {
if (widthSoFar + (elem.getShort() == null ? 0 : elem.getShort().length())+8+elem.getPath().length() > 105) {
String ret = "\r\n ";
for (int i = 0; i < indent+2; i++)
ret = ret + " ";
return ret;
}
else
return "";
}
*/
private int writeTypeLinks(ElementDefn elem, int indent, TypeRef t) throws Exception {
write(" <span style=\"color: darkgreen\">");
int i = 0;
// this is wrong if the type is an attribute, but the wrapping concern shouldn't apply in this case, so this is ok
int w = indent + 12 + elem.getName().length();
// for (TypeRef t : elem.getTypes()) {
if (i > 0) {
write("|");
w++;
}
if (w + t.getName().length() > 80) {
throw new Error("this sholdn't happen");
// write("\r\n ");
// for (int j = 0; j < indent; j++)
// write(" ");
// w = indent+2;
}
// again, could be wrong if this is an extension, but then it won't wrap
w = w + t.getName().length();
if (t.isXhtml() || t.getName().equals("list"))
write(t.getName());
else if (t.getName().equals("Extension") && t.getParams().size() == 0 && !Utilities.noString(t.getProfile()))
write("<a href=\"" + prefix + t.getProfile() + "\"><span style=\"color: DarkViolet\">@" + t.getProfile().substring(1) + "</span></a>");
else if (definitions.getConstraints().containsKey(t.getName())) {
ProfiledType pt = definitions.getConstraints().get(t.getName());
write("<a href=\"" + prefix + (dtRoot + definitions.getSrcFile(pt.getBaseType()) + ".html#" + pt.getBaseType() + "\">" + pt.getBaseType()) + "</a>");
w = w + pt.getBaseType().length() + 2;
write("(<a style=\"color:navy\" href=\"" + prefix + (dtRoot + definitions.getSrcFile(t.getName()) + ".html#" + t.getName() + "\">" + t.getName()) + "</a>)");
} else
write("<a href=\"" + prefix + (dtRoot + definitions.getSrcFile(t.getName()) + ".html#" + t.getName() + "\">" + t.getName()) + "</a>");
if (t.hasParams()) {
write("(");
boolean firstp = true;
List<String> ap = new ArrayList<>();
for (String p : t.getParams()) {
if (definitions.hasLogicalModel(p))
ap.addAll(definitions.getLogicalModel(p).getImplementations());
else
ap.add(p);
}
Collections.sort(ap);
for (String p : ap) {
if (!firstp) {
write("|");
w++;
}
// again, p.length() could be wrong if this is an extension, but then it won't wrap
if (w + p.length() > 80) {
write("\r\n ");
for (int j = 0; j < indent; j++) write(" ");
w = indent + 2;
}
w = w + p.length();
// TODO: Display action and/or profile information
if (p.equals("Any")) {
write("<a href=\"" + prefix + "resourcelist.html" + "\">" + p + "</a>");
} else if (isReference(t.getName()) && t.getParams().size() == 1 && !Utilities.noString(t.getProfile()))
write("<a href=\"" + prefix + t.getProfile() + "\"><span style=\"color: DarkViolet\">@" + t.getProfile().substring(1) + "</span></a>");
else
write("<a href=\"" + prefix + (dtRoot + definitions.getSrcFile(p) + ".html#" + p) + "\">" + p + "</a>");
firstp = false;
}
write(")");
w++;
}
i++;
// }
write("</span>");
return w;
}
use of org.hl7.fhir.definitions.model.TypeRef in project kindling by HL7.
the class DictHTMLGenerator method patternAnalysis.
private String patternAnalysis(ElementDefn e) {
StringBuilder b = new StringBuilder();
boolean first = true;
for (TypeRef tr : e.getTypes()) {
if (tr.getPatterns() != null) {
if (first)
first = false;
else
b.append("<br/>\r\n");
if (tr.getPatterns().isEmpty())
b.append(tr.summary() + ": No common pattern");
else {
CommaSeparatedStringBuilder cb = new CommaSeparatedStringBuilder();
for (String s : tr.getPatterns()) {
cb.append("<a href=\"" + s.toLowerCase() + ".html#" + s + "\">" + s + "</a>");
}
if (tr.getPatterns().size() == 0)
b.append(tr.summary() + ": Common pattern = " + cb.toString());
else
b.append(tr.summary() + ": Common patterns = " + cb.toString());
}
}
}
return b.toString();
}
use of org.hl7.fhir.definitions.model.TypeRef in project kindling by HL7.
the class JsonSpecGenerator method generateCoreElem.
private void generateCoreElem(ElementDefn elem, int indent, String rootName, String pathName, boolean backbone, boolean last) throws Exception {
// base pattern: "name" : "value" // optionality documentation
int width = 0;
// If this is an unrolled element, show its profile name
if (elem.getProfileName() != null && !elem.getProfileName().equals("")) {
for (int i = 0; i < indent; i++) write(" ");
write("<span style=\"color: Gray\">// </span><span style=\"color: blue\">\"" + elem.getProfileName() + "\":</span>\r\n");
}
if (elem.getMaxCardinality() != null && elem.getMaxCardinality() == 0)
write("<span style=\"text-decoration: line-through\">");
String en = elem.getName();
if (en.contains("[x]") && elem.getTypes().size() == 1 && !elem.getTypes().get(0).isWildcardType())
en = en.replace("[x]", elem.typeCode());
if (en.contains("[x]")) {
// 1. name
for (int i = 0; i < indent; i++) {
write(" ");
}
if (elem.getTypes().size() > 1) {
write("<span style=\"color: Gray\">// " + en + ": <span style=\"color: navy; opacity: 0.8\">" + docPrefix(width, indent, elem) + Utilities.escapeXml(elem.getShortDefn()) + "</span>. One of these " + Integer.toString(elem.getTypes().size()) + ":</span>\r\n");
for (TypeRef t : elem.getTypes()) generateCoreElemDetails(elem, indent, rootName, pathName, backbone, last, width, en.replace("[x]", nameForType(t.getName())), t, false);
} else {
List<WildcardInformation> tr = TypesUtilities.wildcards(version);
write("<span style=\"color: Gray\">// " + en + ": <span style=\"color: navy; opacity: 0.8\">" + docPrefix(width, indent, elem) + Utilities.escapeXml(elem.getShortDefn()) + "</span>. One of these " + Integer.toString(tr.size()) + ":</span>\r\n");
for (WildcardInformation t : tr) generateCoreElemDetails(elem, indent, rootName, pathName, backbone, last, width, en.replace("[x]", upFirst(t.getTypeName())), toTypeRef(t), false);
}
} else {
generateCoreElemDetails(elem, indent, rootName, pathName, backbone, last, width, en, elem.getTypes().isEmpty() ? null : elem.getTypes().get(0), true);
}
}
use of org.hl7.fhir.definitions.model.TypeRef in project kindling by HL7.
the class JsonSpecGenerator method toTypeRef.
private TypeRef toTypeRef(WildcardInformation t) {
TypeRef r = new TypeRef();
r.setName(t.getTypeName());
return r;
}
Aggregations