use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project kindling by HL7.
the class PageProcessor method generateValueSetUsage.
private String generateValueSetUsage(ValueSet vs, String prefix, boolean addTitle) throws Exception {
List<String> items = new ArrayList<>();
if (vs.hasUrl()) {
for (CodeSystem cs : getCodeSystems().getList()) {
if (cs != null) {
if (vs.getUrl().equals(cs.getValueSet())) {
String p = cs.getUserString("path");
addItem(items, "<li>CodeSystem: This value set is the designated 'entire code system' value set for <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cs.getName() + "</a> " + "</li>\r\n");
}
}
}
}
for (ConceptMap cm : getConceptMaps().getList()) {
String p = cm.getUserString("path");
if (cm.hasSourceUriType() && cm.getSourceUriType().equals(vs.getUrl())) {
addItem(items, "<li>ConceptMap: Translation source in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.present() + "</a> " + "</li>\r\n");
} else if (cm.hasSourceCanonicalType() && (cm.getSourceCanonicalType().getValue().equals(vs.getUrl()) || vs.getUrl().endsWith("/" + cm.getSourceCanonicalType().getValue()))) {
addItem(items, "<li>ConceptMap: Translation source in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.getName() + "</a> " + "</li>\r\n");
}
}
for (ConceptMap cm : getConceptMaps().getList()) {
String p = cm.getUserString("path");
if (cm.hasTargetUriType() && cm.getTargetUriType().equals(vs.getUrl())) {
addItem(items, "<li>ConceptMap: Translation target in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.present() + "</a> " + "</li>\r\n");
} else if (cm.hasTargetCanonicalType() && (cm.getTargetCanonicalType().getValue().equals(vs.getUrl()) || vs.getUrl().endsWith("/" + cm.getTargetCanonicalType().getValue()))) {
addItem(items, "<li>ConceptMap: Translation target ConceptMap <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.getName() + "</a> " + "</li>\r\n");
}
}
for (ResourceDefn r : definitions.getBaseResources().values()) {
scanForUsage(items, vs, r.getRoot(), r.getName().toLowerCase() + "-definitions.html", prefix);
scanForOperationUsage(items, vs, r, r.getName().toLowerCase() + "-operation-", prefix);
scanForProfileUsage(items, vs, r, prefix);
}
for (ResourceDefn r : definitions.getResources().values()) {
scanForUsage(items, vs, r.getRoot(), r.getName().toLowerCase() + "-definitions.html", prefix);
scanForOperationUsage(items, vs, r, r.getName().toLowerCase() + "-operation-", prefix);
scanForProfileUsage(items, vs, r, prefix);
}
for (ElementDefn e : definitions.getInfrastructure().values()) {
scanForUsage(items, vs, e, definitions.getSrcFile(e.getName()) + "-definitions.html", prefix);
}
for (ElementDefn e : definitions.getTypes().values()) {
if (!definitions.dataTypeIsSharedInfo(e.getName())) {
scanForUsage(items, vs, e, definitions.getSrcFile(e.getName()) + "-definitions.html", prefix);
}
}
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
scanForUsage(items, vs, sd, sd.getUserString("path"), prefix);
}
for (ValueSet vsi : definitions.getValuesets().getList()) {
String path = (String) vsi.getUserData("path");
if (vs.hasCompose()) {
for (ConceptSetComponent t : vs.getCompose().getInclude()) {
for (UriType uri : t.getValueSet()) {
if (uri.getValue().equals(vs.getUrl())) {
addItem(items, "<li>ValueSet: Included in <a href=\"" + prefix + path + "\">" + Utilities.escapeXml(vs.present()) + "</a></li>\r\n");
}
}
}
for (ConceptSetComponent t : vs.getCompose().getExclude()) {
for (UriType uri : t.getValueSet()) {
if (uri.getValue().equals(vs.getUrl())) {
addItem(items, "<li>ValueSet: Excluded from <a href=\"" + prefix + path + "\">" + Utilities.escapeXml(vs.present()) + "</a></li>\r\n");
}
}
}
// for (ConceptSetComponent t : vsi.getCompose().getInclude()) {
// if (vs.hasCodeSystem() && t.getSystem().equals(vs.getCodeSystem().getSystem()))
// b.append(" <li>Included in Valueset <a href=\""+prefix+path+"\">"+Utilities.escapeXml(vs.getName())+"</a></li>\r\n");
// }
// for (ConceptSetComponent t : vsi.getCompose().getExclude()) {
// if (vs.hasCodeSystem() && t.getSystem().equals(vs.getCodeSystem().getSystem()))
// b.append(" <li>Excluded in Valueset <a href=\""+prefix+path+"\">"+Utilities.escapeXml(vs.getName())+"</a></li>\r\n");
// }
}
}
if (ini.getPropertyNames(vs.getUrl()) != null) {
for (String n : ini.getPropertyNames(vs.getUrl())) {
addItem(items, "<li>" + ini.getStringProperty(vs.getUrl(), n) + "</li>\r\n");
}
}
if (items.size() == 0)
return "<p>\r\nThis value set is not currently used\r\n</p>\r\n";
else {
StringBuilder b = new StringBuilder();
for (String s : items) {
b.append(" " + s);
}
return (addTitle ? "<p>\r\nThis value set is used in the following places:\r\n</p>\r\n" : "") + "<ul>\r\n" + b.toString() + "</ul>\r\n";
}
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project kindling by HL7.
the class PageProcessor method genConceptMapsTable.
private String genConceptMapsTable() throws Exception {
StringBuilder s = new StringBuilder();
s.append("<table class=\"codes\">\r\n");
s.append(" <tr><td><b>Name</b></td><td><b>Source</b></td><td><b>Target</b></td></tr>\r\n");
List<String> sorts = new ArrayList<String>();
sorts.addAll(conceptMaps.keys());
Collections.sort(sorts);
for (String sn : sorts) {
ConceptMap ae = conceptMaps.get(sn);
// String n = sn.substring(23);
ConceptMap cm = ae;
s.append(" <tr><td><a href=\"").append(ae.getUserData("path")).append("\">").append(cm.getName()).append("</a></td>").append("<td><a href=\"").append(getValueSetRef("", cm.hasSourceCanonicalType() ? (cm.getSourceCanonicalType()).getValue() : cm.getSourceUriType().asStringValue())).append("\">").append(describeValueSetByRef(cm.getSource())).append("</a></td>").append("<td><a href=\"").append(getValueSetRef("", cm.hasTargetCanonicalType() ? (cm.getTargetCanonicalType()).getValue() : cm.getTargetUriType().asStringValue())).append("\">").append(describeValueSetByRef(cm.getTarget())).append("</a></td></tr>\r\n");
}
s.append("</table>\r\n");
return s.toString();
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project kindling by HL7.
the class DSTU3ValidationConvertor method convert.
public void convert(String bundleSource, String bundleTarget) throws Exception {
System.out.println("Convert " + bundleSource);
try {
source = (Bundle) new XmlParser().parse(new FileInputStream(bundleSource));
org.hl7.fhir.dstu3.model.Bundle target = Bundle30_50.convertBundle(source);
new org.hl7.fhir.dstu3.formats.XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(bundleTarget), target);
} catch (Exception e) {
throw new Exception(e);
}
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project kindling by HL7.
the class CKMImporter method processArchetype.
private void processArchetype(String id) throws Exception {
String cfg = info == null ? null : Utilities.path(info, id + ".config");
String src = Utilities.path(dest, id + ".xml");
String dst = Utilities.path(dest, id.substring(id.indexOf(".") + 1) + ".xml");
if (new File(dst).exists())
System.out.println(id + " Already Processed");
else {
System.out.print("Process " + id + ": ");
try {
if (!new File(src).exists())
downloadArchetype(id);
if (cfg != null && new File(cfg).exists())
ADLImporter.main(new String[] { "-source", src, "-dest", dst, "-config", config, "-info", cfg });
else
ADLImporter.main(new String[] { "-source", src, "-dest", dst, "-config", config });
System.out.println(" ok");
} catch (Exception e) {
System.out.println(" error - " + e.getMessage());
}
}
}
use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project kindling by HL7.
the class HTMLLinkChecker method check.
private void check(XhtmlNode node, String href, String base, String source) throws FileNotFoundException, Exception {
if (href == null)
throw new Exception("no ref at " + node.allText());
if (href.startsWith("http:") || href.startsWith("https:") || href.startsWith("ftp:") || href.startsWith("mailto:"))
return;
String path = href;
String anchor = null;
if (href.contains("#")) {
path = href.substring(0, href.indexOf("#"));
anchor = href.substring(href.indexOf("#") + 1);
}
Entry e;
if (!Utilities.noString(path)) {
if (href.endsWith("qa.html") || href.endsWith(".epub.zip"))
return;
if ("self-link".equals(node.getAttribute("class")))
return;
String target = collapse(base, path, source);
if (target.endsWith(".xml") || target.endsWith(".json") || target.endsWith(".jsonld") || target.endsWith(".xsd") || target.endsWith(".shex") || target.endsWith(".txt") || target.endsWith(".sch") || target.endsWith(".pdf") || target.endsWith(".epub")) {
if (!(new File(Utilities.path(page.getFolders().dstDir, target)).exists()))
reportError(base, "Broken Link (1) in " + base + ": '" + href + "' not found at \"" + Utilities.path(page.getFolders().dstDir, target) + "\" (" + node.allText() + ")");
node.setAttribute("href", webPath + "/" + target.replace(File.separatorChar, '/'));
e = null;
} else if (externals.contains(target)) {
node.setAttribute("href", webPath + "/" + target.replace(File.separatorChar, '/'));
e = null;
} else {
e = getEntryForFile(target, source);
if (e == null) {
if (// we can't check those links
href.startsWith("v2/") || href.startsWith("v3/"))
return;
if (target.endsWith(".zip") || target.endsWith(".ttl") || target.endsWith(".jar") || target.endsWith(".cfm") || target.endsWith(".tgz") || target.endsWith(".xlsx"))
return;
reportError(base, "Broken Link (2) in " + base + ": '" + href + "' not found at \"" + target + "\"(" + node.allText() + ")");
return;
} else if (!e.include) {
node.setAttribute("href", webPath + "/" + node.getAttribute("href"));
}
}
} else
e = getEntryForFile(base, source);
if (Utilities.noString(anchor)) {
// if (e == null) - need to enable this an fix everything it finds
// reportError("Broken Link in "+base+": '"+href+"' anchor not found ("+node.allText()+")");
} else {
if (e != null) {
if (!e.checked)
check(e);
// td if (!e.anchors.contains(anchor))
// td reportError("Broken Link in "+base+": '"+href+"' anchor not found ("+node.allText()+")");
}
}
}
Aggregations