Skip to content
Snippets Groups Projects
Commit d17b0b49 authored by Lazarenko, Elena's avatar Lazarenko, Elena :duck:
Browse files

Add method to generate CSV output

parent 3053aae7
No related branches found
No related tags found
No related merge requests found
Pipeline #9329 passed
......@@ -1041,6 +1041,12 @@ public class CorpusMagician {
} else {
reportOutput = ReportItem.generateDataTableHTML(report.getRawStatistics(), report.getSummaryLines());
}
} else if (reportlocation.getFile().endsWith("csv")) {
if (iserrorsonly) {
reportOutput = ReportItem.GenerateCSV(report.getErrorStatistics(), report.getSummaryLines());
} else {
reportOutput = ReportItem.GenerateCSV(report.getRawStatistics(), report.getSummaryLines());
}
} else {
//reportOutput = report.getSummaryLines() + "\n" + report.getErrorReports();
reportOutput = report.getSummaryLines() + "\n" + report.getFullReports();
......
......@@ -603,4 +603,35 @@ public class ReportItem {
return report;
}
/* Generate a CSV file with validation errors list with double quotes as delimeters*/
public static String GenerateCSV (Collection<ReportItem> errors, String summarylines) {
String report = new String();
report += "Type\"Function\"FIlename:line.column\"Error\"Fix\"Original\n";
for (ReportItem error : errors) {
switch (error.getSeverity()) {
case CRITICAL:
report += "Critical\"";
break;
case WARNING:
report += "Warning\"";
break;
case NOTE:
report += "Note\"";
break;
case UNKNOWN:
report += "Unknown\"";
break;
default:
report += "Other\"";
break;
}
report += error.getFunction() + "\"";
report += error.getLocation() + "\"";
report += error.getWhat() + "\"";
report += error.getHowto() + "\"";
report += error.getLocalisedMessage() + "\"";
report += error.getStackTrace() +"\n";
}
return report;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment