use of org.hl7.fhir.dstu2016may.model.Base in project kindling by HL7.
the class SvgGenerator method drawClass.
private ClassItem drawClass(XMLWriter xml, ElementDefn e, boolean isRoot, ResourceDefn resource, boolean link, String path, DefinedCode primitive, StandardsStatus status) throws Exception {
ClassItem item = classes.get(e);
String tn = e.getName();
if (!definitions.hasPrimitiveType(tn) && !tn.equals("xhtml")) {
tn = Utilities.capitalize(tn);
}
ResourceDefn r = definitions.hasResource(tn) ? definitions.getResourceByName(tn) : null;
if (r == null) {
r = definitions.getBaseResources().get(tn);
}
xml.attribute("id", "n" + (++nc));
xml.enter("g");
xml.attribute("x", Double.toString(item.left));
xml.attribute("y", Double.toString(item.top));
xml.attribute("rx", "4");
xml.attribute("ry", "4");
xml.attribute("width", Double.toString(item.width));
xml.attribute("height", Double.toString(item.height));
xml.attribute("filter", "url(#shadow" + id + ")");
if (r != null) {
xml.attribute("style", "fill:" + r.getStatus().getColorSvg() + ";stroke:black;stroke-width:1");
status = r.getStatus();
} else if (e == null || e.getStandardsStatus() == null)
xml.attribute("style", "fill:" + (status == null ? "#ffffff" : status.getColorSvg()) + ";stroke:black;stroke-width:1");
else {
xml.attribute("style", "fill:" + e.getStandardsStatus().getColorSvg() + ";stroke:black;stroke-width:1");
status = e.getStandardsStatus();
}
if (!makeTargets)
xml.attribute("id", "n" + (++nc));
else
xml.attribute("id", item.getId());
xml.element("rect", null);
xml.attribute("x1", Double.toString(item.left));
xml.attribute("y1", Double.toString(item.top + HEADER_HEIGHT + GAP_HEIGHT * 2));
xml.attribute("x2", Double.toString(item.left + item.width));
xml.attribute("y2", Double.toString(item.top + HEADER_HEIGHT + GAP_HEIGHT * 2));
xml.attribute("style", "stroke:dimgrey;stroke-width:1");
xml.attribute("id", "n" + (++nc));
xml.element("line", null);
xml.attribute("x", Double.toString(item.left + item.width / 2));
xml.attribute("y", Double.toString(item.top + HEADER_HEIGHT));
xml.attribute("fill", "black");
if (isRoot)
xml.attribute("class", "diagram-class-title diagram-class-resource");
else
xml.attribute("class", "diagram-class-title");
if (link) {
xml.attribute("id", "n" + (++nc));
if (e.isAbstractType()) {
xml.attribute("style", "font-style: italic");
}
xml.enter("text");
xml.attribute("xlink:href", makeRel(definitions.getSrcFile(tn) + ".html#" + tn));
xml.attribute("id", "n" + (++nc));
xml.enter("a");
xml.text(tn);
xml.exit("a");
if (definitions.getBaseResources().containsKey(e.getName()) && definitions.getBaseResources().get(e.getName()).isInterface()) {
xml.text(" ");
xml.attribute("xlink:href", makeRel("uml.html#interface"));
xml.enter("a");
xml.text("«Interface»");
xml.exit("a");
}
xml.exit("text");
} else if (isRoot) {
xml.attribute("id", "n" + (++nc));
if (e.isAbstractType()) {
xml.attribute("style", "font-style: italic");
}
xml.enter("text");
xml.text(tn);
if (Utilities.noString(e.typeCode())) {
xml.text(" \u00ABResource\u00BB");
} else {
xml.attribute("class", "diagram-class-title-link");
xml.enter("tspan");
xml.text(" (");
if ("Logical".equals(e.typeCode()))
xml.attribute("xlink:href", prefix + definitions.getBaseLink());
else
xml.attribute("xlink:href", prefix + definitions.getSrcFile(e.typeCode()) + ".html#" + e.typeCode());
xml.attribute("class", "diagram-class-reference");
xml.attribute("id", "n" + (++nc));
xml.attribute("style", "font-style: italic");
if ("Logical".equals(e.typeCode())) {
xml.element("a", "Base");
} else {
xml.element("a", e.typeCode());
}
xml.text(")");
xml.exit("tspan");
}
if ("Logical".equals(e.typeCode())) {
xml.text(" ");
xml.attribute("xlink:href", makeRel("uml.html#pattern"));
xml.enter("a");
xml.text("«Pattern»");
xml.exit("a");
}
if (definitions.getBaseResources().containsKey(e.getName()) && definitions.getBaseResources().get(e.getName()).isInterface()) {
xml.text(" ");
xml.attribute("xlink:href", makeRel("uml.html#interface"));
xml.enter("a");
xml.text("«Interface»");
xml.exit("a");
}
xml.exit("text");
} else if (e.hasStatedType()) {
xml.attribute("id", "n" + (++nc));
xml.element("text", e.getStatedType());
} else {
xml.attribute("id", "n" + (++nc));
xml.element("text", tn);
}
if (attributes) {
if (primitive != null) {
if (primitive instanceof PrimitiveType)
addValueAttribute(xml, item.left, item.top + HEADER_HEIGHT + GAP_HEIGHT * 2 + LINE_HEIGHT, getXsi(primitive).split("\\|"));
} else {
int i = 0;
for (ElementDefn c : e.getElements()) {
if (isAttribute(c)) {
i++;
addAttribute(xml, item.left, item.top + HEADER_HEIGHT + GAP_HEIGHT * 2 + LINE_HEIGHT * i, c, path, LINE_HEIGHT, item.width);
String[] texts = textForAttribute(c);
i = i + texts.length - 1;
}
}
}
}
xml.exit("g");
if (attributes) {
for (ElementDefn c : e.getElements()) {
if (!isAttribute(c)) {
if (Utilities.noString(c.typeCode()) || !c.typeCode().startsWith("@")) {
links.add(new Link(item, drawClass(xml, c, false, resource, false, path + "." + c.getName(), null, status), LinkType.COMPOSITION, c.getName(), c.describeCardinality(), PointKind.unknown, baseUrl(path) + path + "." + c.getName(), c.getEnhancedDefinition()));
} else {
ClassItem target = getItemForPath(resource, c.typeCode().substring(1));
links.add(new Link(item, target, LinkType.COMPOSITION, c.getName(), c.describeCardinality(), PointKind.unknown, baseUrl(path) + path + "." + c.getName(), c.getEnhancedDefinition()));
}
}
}
}
return item;
}
use of org.hl7.fhir.dstu2016may.model.Base in project kindling by HL7.
the class SvgGenerator method drawElement.
private ClassItem drawElement(XMLWriter xml, String[] classNames) throws Exception {
// classNames.length == 1 && classNames[0].equals("Base");
boolean onlyElement = false;
if (classNames != null) {
for (String cn : classNames) {
if (definitions.getPrimitives().containsKey(cn)) {
DefinedCode cd = definitions.getPrimitives().get(cn);
ElementDefn fake = fakes.get(cn);
if (cd instanceof DefinedStringPattern) {
links.add(new Link(classes.get(fakes.get(((DefinedStringPattern) cd).getBase())), drawClass(xml, fake, false, null, true, null, cd, StandardsStatus.NORMATIVE), LinkType.SPECIALIZATION, null, null, PointKind.unknown, null, null));
} else {
ClassItem parent = classes.get(definitions.getElementDefn(version.isR4B() ? "Element" : "PrimitiveType"));
if (parent == null) {
drawClass(xml, fake, false, null, true, null, cd, StandardsStatus.NORMATIVE);
} else {
links.add(new Link(parent, drawClass(xml, fake, false, null, true, null, cd, StandardsStatus.NORMATIVE), LinkType.SPECIALIZATION, null, null, PointKind.unknown, null, null));
}
}
} else if ("xhtml".equals(cn)) {
DefinedCode cd = new DefinedCode("xhtml", "XHTML for resource narrative", null);
ElementDefn fake = fakes.get(cn);
ClassItem parent = classes.get(definitions.getElementDefn(version.isR4B() ? "Element" : "DataType"));
if (parent == null) {
drawClass(xml, fake, false, null, true, null, cd, StandardsStatus.NORMATIVE);
} else {
links.add(new Link(parent, drawClass(xml, fake, false, null, true, null, cd, StandardsStatus.NORMATIVE), LinkType.SPECIALIZATION, null, null, PointKind.unknown, null, null));
}
} else if (definitions.getConstraints().containsKey(cn)) {
ProfiledType cd = definitions.getConstraints().get(cn);
ElementDefn fake = fakes.get(cn);
ClassItem parent = classes.get(definitions.getElementDefn(cd.getBaseType()));
links.add(new Link(parent, drawClass(xml, fake, false, null, true, null, null, StandardsStatus.NORMATIVE), LinkType.CONSTRAINT, null, null, PointKind.unknown, null, null));
} else if (definitions.getPrimitives().containsKey(cn)) {
DefinedCode cd = new DefinedCode("xhtml", "XHTML for resource narrative", null);
ElementDefn fake = fakes.get(cn);
// links.add(new Link(item,
// , LinkType.SPECIALIZATION, null, null, PointKind.unknown, null, null));
drawClass(xml, fake, false, null, true, null, cd, StandardsStatus.NORMATIVE);
} else if (!onlyElement) {
ElementDefn e = definitions.getElementDefn(cn);
ClassItem parent = Utilities.noString(e.typeCode()) ? null : classes.get(definitions.getElementDefn(e.typeCode()));
if (parent == null) {
drawClass(xml, e, false, null, true, cn, null, e.getStandardsStatus());
} else {
links.add(new Link(parent, drawClass(xml, e, false, null, true, cn, null, e.getStandardsStatus()), LinkType.SPECIALIZATION, null, null, PointKind.unknown, null, null));
}
}
}
}
return null;
}
use of org.hl7.fhir.dstu2016may.model.Base in project kindling by HL7.
the class XSDBaseGenerator method genResource.
private void genResource(String name, ResourceDefn res) throws Exception {
enums.clear();
enumDefs.clear();
boolean isBase = Utilities.noString(res.getRoot().typeCode());
write(" <xs:complexType name=\"" + name + "\">\r\n");
write(" <xs:annotation>\r\n");
write(" <xs:documentation xml:lang=\"en\">" + Utilities.escapeXml(res.getDefinition()) + "</xs:documentation>\r\n");
write(" </xs:annotation>\r\n");
if (!isBase) {
write(" <xs:complexContent>\r\n");
write(" <xs:extension base=\"" + res.getRoot().typeCode() + "\">\r\n");
}
if (!res.isInterface()) {
write(" <xs:sequence>\r\n");
for (ElementDefn e : res.getRoot().getElements()) {
generateElement(res.getRoot(), e, null, null);
}
write(" </xs:sequence>\r\n");
}
if (!isBase) {
write(" </xs:extension>\r\n");
write(" </xs:complexContent>\r\n");
}
write(" </xs:complexType>\r\n");
genRegex();
while (!structures.isEmpty()) {
String s = structures.keySet().iterator().next();
generateType(res.getRoot(), s, structures.get(s));
structures.remove(s);
}
for (BindingSpecification en : enums) {
generateEnum(en);
}
genRegex();
}
use of org.hl7.fhir.dstu2016may.model.Base in project kindling by HL7.
the class XSDGenerator method generateType.
private void generateType(ElementDefn root, String name, ElementDefn struc, boolean isResource) throws IOException, Exception {
write(" <xs:complexType name=\"" + name + "\">\r\n");
write(" <xs:annotation>\r\n");
write(" <xs:documentation xml:lang=\"en\">" + Utilities.escapeXml(root.getDefinition()) + "</xs:documentation>\r\n");
if (isResource)
write(" <xs:documentation xml:lang=\"en\">If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>\r\n");
write(" </xs:annotation>\r\n");
write(" <xs:complexContent>\r\n");
if (isResource)
write(" <xs:extension base=\"" + root.typeCode() + "\">\r\n");
else
write(" <xs:extension base=\"BackboneElement\">\r\n");
write(" <xs:sequence>\r\n");
for (ElementDefn e : struc.getElements()) {
if (e.getName().equals("[type]"))
generateAny(root, e);
else
generateElement(root, e);
}
write(" </xs:sequence>\r\n");
write(" </xs:extension>\r\n");
write(" </xs:complexContent>\r\n");
write(" </xs:complexType>\r\n");
}
use of org.hl7.fhir.dstu2016may.model.Base in project kindling by HL7.
the class XSDGenerator method generateEnum.
private void generateEnum(String en) throws IOException {
if (allenums.contains(en))
return;
allenums.add(en);
write(" <xs:simpleType name=\"" + en + "-list\">\r\n");
write(" <xs:restriction base=\"code-primitive\">\r\n");
ValueSet vs = enums.get(en);
vs.setUserData(ToolResourceUtilities.NAME_VS_USE_MARKER, true);
ValueSet ex = workerContext.expandVS(vs, true, false).getValueset();
for (ValueSetExpansionContainsComponent cc : ex.getExpansion().getContains()) {
genIncludedCode(cc);
}
write(" </xs:restriction>\r\n");
write(" </xs:simpleType>\r\n");
write(" <xs:complexType name=\"" + en + "\">\r\n");
write(" <xs:annotation>\r\n");
write(" <xs:documentation xml:lang=\"en\">" + Utilities.escapeXml(enumDefs.get(en)) + "</xs:documentation>\r\n");
write(" <xs:documentation xml:lang=\"en\">If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>\r\n");
write(" </xs:annotation>\r\n");
write(" <xs:complexContent>\r\n");
write(" <xs:extension base=\"Element\">\r\n");
write(" <xs:attribute name=\"value\" type=\"" + en + "-list\" use=\"optional\"/>\r\n");
write(" </xs:extension>\r\n");
write(" </xs:complexContent>\r\n");
write(" </xs:complexType>\r\n");
}
Aggregations