use of org.hl7.fhir.definitions.model.MappingSpace in project kindling by HL7.
the class PageProcessor method genMappingsTable.
private String genMappingsTable() throws IOException {
StringBuilder b = new StringBuilder();
b.append("<table class=\"rows\">\r\n");
b.append(" <tr>\r\n");
b.append(" <th width=\"250\">Name</th>\r\n");
b.append(" <th>Details</th>\r\n");
b.append(" </tr>\r\n");
for (String s : definitions.getMapTypes().keySet()) {
MappingSpace m = definitions.getMapTypes().get(s);
if (m.isPublish()) {
b.append(" <tr>\r\n");
b.append(" <td><a name=\"" + m.getId() + "\"></a>");
if (m.hasLink())
b.append("<a href=\"" + m.getLink() + "\">" + Utilities.escapeXml(m.getTitle()) + "</a></td>\r\n");
else
b.append(Utilities.escapeXml(m.getTitle()) + "</td>\r\n");
b.append(" <td>Formal URL: <code>" + s + "</code>" + (m.getPreamble() != null ? "<br/>" + new XhtmlComposer(false, true).compose(m.getPreamble()) : "") + "</td>\r\n");
b.append(" </tr>\r\n");
}
}
b.append("</table>\r\n");
return b.toString();
}
use of org.hl7.fhir.definitions.model.MappingSpace in project kindling by HL7.
the class OldSpreadsheetParser method checkMappings.
private void checkMappings(Profile pack) throws Exception {
pack.getMappingSpaces().clear();
Sheet sheet = loadSheet("Mappings");
if (sheet != null) {
for (int row = 0; row < sheet.rows.size(); row++) {
String uri = sheet.getNonEmptyColumn(row, "Uri");
MappingSpace ms = new MappingSpace(sheet.getNonEmptyColumn(row, "Column"), sheet.getNonEmptyColumn(row, "Title"), sheet.getNonEmptyColumn(row, "Id"), sheet.getIntColumn(row, "Sort Order"), true, false, false, sheet.hasColumn(row, "Link") ? sheet.getColumn(row, "Link") : uri);
pack.getMappingSpaces().put(uri, ms);
}
}
}
use of org.hl7.fhir.definitions.model.MappingSpace in project kindling by HL7.
the class MappingsGenerator method generate.
public void generate(ResourceDefn resource) throws IOException {
StringBuilder s = new StringBuilder();
List<String> maps = new ArrayList<String>();
listKnownMappings(resource.getRoot(), maps);
Collections.sort(maps, new Sorter());
StringBuilder list = new StringBuilder();
for (String m : maps) {
MappingSpace ms = definitions.getMapTypes().get(m);
list.append("|" + ms.getTitle() + "#" + ms.getId());
s.append("<a name=\"" + m + "\"> </a><a name=\"" + ms.getId() + "\"> </a>");
if (!Utilities.noString(ms.getLink()))
s.append("<h3>" + ms.getTitle() + " (<a href=\"" + ms.getLink() + "\">" + m + "</a>)</h3>");
else
s.append("<h3>" + ms.getTitle() + " (" + m + ")</h3>");
XhtmlNode pre = ms.getPreamble();
if (pre != null)
s.append(new XhtmlComposer(XhtmlComposer.HTML).compose(pre));
s.append("<table class=\"grid\">\r\n");
genElement(s, 0, resource.getRoot(), m, ROOT_ONLY, true, ms.isSparse());
genInherited(s, resource, m);
genElement(s, 0, resource.getRoot(), m, CHILDREN_ONLY, true, ms.isSparse());
s.append("</table>\r\n");
}
mappings = s.toString();
mappingsList = list.length() == 0 ? "" : list.toString().substring(1);
}
use of org.hl7.fhir.definitions.model.MappingSpace in project kindling by HL7.
the class ProfileGenerator method addElementConstraint.
/*
* // resource
// domain resource
for (ElementDefn child : definitions.getBaseResources().get("DomainResource").getRoot().getElements())
defineElement(null, p, p.getSnapshot(), child, r.getRoot().getName()+"."+child.getName(), containedSlices, new ArrayList<ProfileGenerator.SliceHandle>(), SnapShotMode.Resource);
*/
/*
private String registerMapping(ConformancePackage ap, StructureDefinition p, String m) {
for (StructureDefinitionMappingComponent map : p.getMapping()) {
if (map.getUri().equals(m))
return map.getIdentity();
}
StructureDefinitionMappingComponent map = new StructureDefinitionMappingComponent();
MappingSpace space = definitions.getMapTypes().get(m);
if (space != null)
map.setIdentity(space.getId());
else
map.setIdentity("m" + Integer.toString(p.getMapping().size()+1));
map.setUri(m);
String name = ap.metadata(m+"-name");
if (Utilities.noString(name) && space != null)
name = space.getTitle();
if (!Utilities.noString(name))
map.setName(name);
String comments = ap.metadata(m+"-comments");
if (Utilities.noString(comments) && space != null)
comments = space.getPreamble();
if (!Utilities.noString(comments))
map.setComments(comments);
return map.getIdentity();
}
*/
private ElementDefinition addElementConstraint(StructureDefinition sd, ElementDefinition ed) {
if (!ed.getPath().contains(".") && sd.getKind() == StructureDefinitionKind.RESOURCE)
return ed;
if (hasSystemType(ed))
return ed;
if (isResource(ed))
return ed;
if (hasConstraint(ed, "ele-1"))
return ed;
ElementDefinitionConstraintComponent inv = ed.addConstraint();
inv.setKey("ele-1");
inv.setSeverity(ConstraintSeverity.ERROR);
inv.setHuman("All FHIR elements must have a @value or children");
inv.setExpression("hasValue() or (children().count() > id.count())");
inv.setXpath("@value|f:*|h:div");
inv.setSource("http://hl7.org/fhir/StructureDefinition/Element");
return ed;
}
use of org.hl7.fhir.definitions.model.MappingSpace in project kindling by HL7.
the class SourceParser method loadMappingSpaces.
private void loadMappingSpaces() throws Exception {
FileInputStream is = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
is = new FileInputStream(Utilities.path(srcDir, "mappingSpaces.xml"));
Document doc = builder.parse(is);
Element e = XMLUtil.getFirstChild(doc.getDocumentElement());
while (e != null) {
MappingSpace m = new MappingSpace(XMLUtil.getNamedChild(e, "columnName").getTextContent(), XMLUtil.getNamedChild(e, "title").getTextContent(), XMLUtil.getNamedChild(e, "id").getTextContent(), Integer.parseInt(XMLUtil.getNamedChild(e, "sort").getTextContent()), isTrue(XMLUtil.getNamedChild(e, "publish")), isTrue(XMLUtil.getNamedChild(e, "sparse")), isTrue(XMLUtil.getNamedChild(e, "pattern")), XMLUtil.getNamedChild(e, "link") != null ? XMLUtil.getNamedChild(e, "link").getTextContent() : XMLUtil.getNamedChild(e, "url").getTextContent());
definitions.getMapTypes().put(XMLUtil.getNamedChild(e, "url").getTextContent(), m);
Element p = XMLUtil.getNamedChild(e, "preamble");
if (p != null)
m.setPreamble(new XhtmlParser().parseHtmlNode(p).setName("div"));
e = XMLUtil.getNextSibling(e);
}
} catch (Exception e) {
throw new Exception("Error processing mappingSpaces.xml: " + e.getMessage(), e);
} finally {
IOUtils.closeQuietly(is);
}
}
Aggregations