if (result0 == null) // No rows!
return null;
// 2. Generate table header
SortableTableModel table = new SortableTableModel(9);
String sort = "<img src=/img/sort_asc.gif></img>";
if(sortDirection.equals("DESCENDING")){
sort = "<img src=\"/img/sort_asc.gif\" border=\"0\"></img>";
}else if(sortDirection.equals("ASCENDING")){
sort = "<img src=\"/img/sort_desc.gif\" border=\"0\"></img>";
}
if(column == 0)
table.setHeader(0, "RunID " + sort);
else
table.setHeader(0, "RunID");
if(column == 1)
table.setHeader(1, "Description " + sort);
else
table.setHeader(1, "Description");
if(column == 2)
table.setHeader(2, "Result " + sort);
else
table.setHeader(2, "Result");
boolean singleScale = false;
if (scaleNames.size() == 1 && scaleUnits.size() == 1) {
singleScale = true;
if (result0.scaleName.length() > 0 &&
result0.scaleUnit.length() > 0){
table.setHeader(3, result0.scaleName + " (" +
result0.scaleUnit + ')');
}else if (result0.scaleName.length() > 0){
table.setHeader(3, result0.scaleName);
}else if (result0.scaleUnit.length() > 0){
table.setHeader(3, result0.scaleUnit);
}else{
if(column == 3)
table.setHeader(3, "Scale " + sort);
else
table.setHeader(3, "Scale");
}
} else {
if(column == 3)
table.setHeader(3, "Scale " + sort);
else
table.setHeader(3, "Scale");
}
boolean singleMetric = false;
if (metricUnits.size() == 1) {
singleMetric = true;
if (result0.metricUnit.length() > 0){
table.setHeader(4, result0.metricUnit);
}else{
if(column == 4)
table.setHeader(4, "Metric " + sort);
else
table.setHeader(4, "Metric");
}
} else {
if(column == 4)
table.setHeader(4, "Metric " + sort);
else
table.setHeader(4, "Metric");
}
//table.setHeader(5, "Status");
if(column == 5)
table.setHeader(5, "Date/Time " + sort);
else
table.setHeader(5, "Date/Time");
if(column == 6)
table.setHeader(6, "Submitter " + sort);
else
table.setHeader(6, "Submitter");
if(column == 7)
table.setHeader(7, "Tags " + sort);
else
table.setHeader(7, "Tags");
// Pseudo-column for the link.
table.setHeader(8, "Link");
// 3. Generate table rows.
StringBuilder b = new StringBuilder();
// The output format.
SimpleDateFormat dateFormat = (SimpleDateFormat) dateFormatOrig.clone();
for (RunResult result : runs) {
//int idx = table.newRow();
Comparable[] row = table.newRow();
row[0] = result.runId;
if (result.description == null || result.description.length() == 0)
row[1] = "UNAVAILABLE";
else
row[1] = result.description;
row[8] = ""; // Initialize the link to zero string in case it does not get set.
ResultField<String> r = new ResultField<String>();
if (result.result != null) {
r.value = result.result;
if (result.resultLink != null){
if(result.result.equals("PASSED"))
r.text = "<img onmouseover=\"showtip('" + result.result.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/passed.png'></img>";
else if(result.result.equals("FAILED"))
r.text = "<img onmouseover=\"showtip('" + result.result.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/failed.png'></img>";
row[8] = result.resultLink;
}
} else if (result.status != null) {
r.value = result.status;
if (result.logLink != null){
if(result.status.equals("FAILED"))
r.text = "<img onmouseover=\"showtip('" + result.status.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/incomplete.png'></img>";
else if(result.status.equals("KILLED"))
r.text = "<img onmouseover=\"showtip('" + result.status.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/killed.png'></img>";
else if(result.status.equals("RECEIVED"))
r.text = "<img onmouseover=\"showtip('" + result.status.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/received.png'></img>";
else if(result.status.equals("STARTED"))
r.text = "<img onmouseover=\"showtip('" + result.status.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/running.png'></img>";
else if(result.status.equals("COMPLETED"))
r.text = "<img onmouseover=\"showtip('" + result.status.toString() + "')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/failed.png'></img>";
else if(result.status.equals("UNKNOWN"))
r.text = "<img onmouseover=\"showtip('unknown')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/unknown.png'></img>";
row[8] = result.logLink;
}
} else {
r.value = NOT_AVAILABLE;
r.text = "<img onmouseover=\"showtip('unknown')\" onmouseout=\"hideddrivetip()\" class=\"icon\"; src='/img/unknown.png'></img>";
}
row[2] = r;
ResultField<Integer> scale = new ResultField<Integer>();
if (result.scale == null || result.scale.length() < 1) {
scale.text = "N/A";
scale.value = Integer.MIN_VALUE;
} else if (singleScale) {
scale.text = result.scale;
scale.value = new Integer(result.scale);
} else {
b.append(result.scale);
if (result.scaleName.length() > 0)
b.append(' ').append(result.scaleName).append(' ');
if (result.scaleUnit.length() > 0)
b.append(' ').append(result.scaleUnit);
scale.text = b.toString();
scale.value = new Integer(result.scale);
b.setLength(0);
}
row[3] = scale;
ResultField<Double> metric = new ResultField<Double>();
if (result.metric.text == null) {
metric.text = "N/A";
metric.value = -1d;
} else if (singleMetric) {
metric.text = result.metric.text;
metric.value = result.metric.value;
} else {
b.append(result.metric);
if (result.metricUnit.length() > 0)
b.append(' ').append(result.metricUnit);
metric.text = b.toString();
metric.value = result.metric.value;
b.setLength(0);
}
row[4] = metric;
/*ResultField<String> status = new ResultField<String>();
if (result.status != null) {
status.value = result.status;
if (result.logLink != null)
status.text = "<a href=\""+ result.logLink + "\">" +
result.status + "</a>";
else
status.text = result.status;
} else {
status.value = NOT_AVAILABLE;
status.text = "UNKNOWN";
}
row[5] = status;*/
ResultField<Long> dateTime = new ResultField<Long>();
if (result.dateTime != null) {
dateTime.text = dateFormat.format(result.dateTime);
dateTime.value = result.dateTime.getTime();
} else {
dateTime.text = "N/A";
dateTime.value = 0l;
}
row[5] = dateTime;
if (result.submitter != null)
row[6] = result.submitter;
else
row[6] = " ";
if (result.tags != null && result.tags.length > 0) {
for (String tag : result.tags) {
b.append(tag).append(' ');
}
b.setLength(b.length() - 1);
row[7] = b.toString();
b.setLength(0);
} else {
row[7] = " ";
}
}
SortDirection enumValForDirection = SortDirection.valueOf(sortDirection);
table.sort(column, enumValForDirection);
return table;
}