use of de.jplag.reporting2.Report in project JPlag by jplag.
the class JsonFactory method saveJsonFiles.
/**
* Creates Json Files for the given JPlagReport and saves them in the given folder.
* @return A boolean, representing whether the process was successful.
*/
public static boolean saveJsonFiles(JPlagReport jPlagReport, String folderPath) {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(Path.of(folderPath, "overview.json").toFile(), jPlagReport.getOverviewReport());
for (ComparisonReport report : jPlagReport.getComparisons()) {
String name = report.getFirstSubmissionId().concat("-").concat(report.getSecondSubmissionId()).concat(".json");
mapper.writeValue(Path.of(folderPath, name).toFile(), report);
}
} catch (IOException e) {
System.out.println("Failed to save json files: " + e.getMessage());
return false;
}
return true;
}
use of de.jplag.reporting2.Report in project JPlag by jplag.
the class CLI method main.
/**
* Main class for using JPlag via the CLI.
* @param args are the CLI arguments that will be passed to JPlag.
*/
public static void main(String[] args) {
try {
CLI cli = new CLI();
Namespace arguments = cli.parseArguments(args);
JPlagOptions options = cli.buildOptionsFromArguments(arguments);
JPlag program = new JPlag(options);
System.out.println("JPlag initialized");
JPlagResult result = program.run();
Report report = new JsonReport();
report.saveReport(result, arguments.getString(RESULT_FOLDER.flagWithoutDash()));
} catch (ExitException exception) {
System.out.println("Error: " + exception.getMessage());
System.exit(1);
}
}
use of de.jplag.reporting2.Report in project JPlag by jplag.
the class JsonReport method saveReport.
@Override
public boolean saveReport(JPlagResult result, String path) {
JPlagReport report = ReportObjectFactory.getReportObject(result);
File dir = new File(path);
if (!dir.exists()) {
if (!dir.mkdir()) {
System.out.println("Failed to create dir.");
}
}
return JsonFactory.saveJsonFiles(report, path);
}
Aggregations