more work on better presentation for comparison

This commit is contained in:
Grahame Grieve 2020-08-18 17:58:24 +10:00
parent 4e200acead
commit 17d9e61baf
3 changed files with 32 additions and 18 deletions

View File

@ -82,14 +82,9 @@ public abstract class CanonicalResourceComparer extends ResourceComparer {
@Override
protected String toTable() {
String s = null;
if (left != null && right != null && !left.getUrl().equals(right.getUrl())) {
s = "<td>"+left.getUrl()+"</td><td>"+right.getUrl()+"</td>";
} else if (left != null) {
s = "<td colspan=2>"+left.getUrl()+"</td>";
} else {
s = "<td colspan=2>"+right.getUrl()+"</td>";
}
String s = "";
s = s + refCell(left);
s = s + refCell(right);
s = s + "<td><a href=\""+getId()+".html\">Comparison</a></td>";
s = s + "<td>"+outcomeSummary()+"</td>";
return "<tr style=\"background-color: "+color()+"\">"+s+"</tr>\r\n";

View File

@ -56,10 +56,17 @@ public class ComparisonRenderer implements IEvaluationContext {
return templates;
}
public void render() throws IOException {
public void render(String leftName, String rightName) throws IOException {
dumpBinaries();
StringBuilder b = new StringBuilder();
b.append("<table class=\"grid\">\r\n");
b.append(" <tr>\r\n");
b.append(" <td width=\"260\"><b>"+Utilities.escapeXml(leftName)+"</b></td>\r\n");
b.append(" <td width=\"260\"><b>"+Utilities.escapeXml(rightName)+"</b></td>\r\n");
b.append(" <td width=\"100\"><b>Difference</b></td>\r\n");
b.append(" <td width=\"260\"><b>Notes</b></td>\r\n");
b.append(" </tr>\r\n");
List<String> list = sorted(session.getCompares().keySet());
processList(list, b, "CodeSystem");
processList(list, b, "ValueSet");
@ -82,7 +89,7 @@ public class ComparisonRenderer implements IEvaluationContext {
if (comp.fhirType().equals(name)) {
if (first) {
first = false;
b.append("<tr><td colspan=4><b>"+name+"</b></td></tr>\r\n");
b.append("<tr><td colspan=\"4\"><b>"+Utilities.pluralize(name, 2)+"</b></td></tr>\r\n");
}
try {
renderComparison(id, comp);

View File

@ -60,6 +60,21 @@ public class ResourceComparer {
id = abbreviation()+"-"+leftId + "-" + rightId;
}
protected String refCell(CanonicalResource cr) {
if (cr == null) {
return "<td></td>";
}
String t = cr.present();
if (Utilities.noString(t)) {
t = cr.getId();
}
if (cr.hasUserData("path")) {
String p = cr.getUserString("path");
return "<td><a href=\""+(Utilities.isAbsoluteUrl(p) ? "" : "../")+p+"\">"+Utilities.escapeXml(t)+"</td>";
} else
return "<td>"+Utilities.escapeXml(t)+"</td>";
}
protected abstract String abbreviation();
public String getLeftId() {
@ -175,15 +190,10 @@ public class ResourceComparer {
@Override
protected String toTable() {
String s = null;
String s = "";
String color = null;
if (left != null && right != null && !left.getUrl().equals(right.getUrl())) {
s = "<td>"+left.getUrl()+"</td><td>"+right.getUrl()+"</td>";
} else if (left != null) {
s = "<td colspan=2>"+left.getUrl()+"</td>";
} else {
s = "<td colspan=2>"+right.getUrl()+"</td>";
}
s = s + refCell(left);
s = s + refCell(right);
if (left == null) {
s = s + "<td>Added</td>";
color = COLOR_NO_ROW_LEFT;
@ -198,6 +208,8 @@ public class ResourceComparer {
return "<tr style=\"background-color: "+color+"\">"+s+"</tr>\r\n";
}
public Throwable getE() {
return e;
}