Search in sources :

Example 1 with Report

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;
}
Also used : ComparisonReport(de.jplag.reporting2.reportobject.model.ComparisonReport) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with Report

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);
    }
}
Also used : JPlagOptions(de.jplag.options.JPlagOptions) Report(de.jplag.reporting2.Report) JsonReport(de.jplag.reporting2.JsonReport) JsonReport(de.jplag.reporting2.JsonReport) ExitException(de.jplag.exceptions.ExitException) Namespace(net.sourceforge.argparse4j.inf.Namespace)

Example 3 with Report

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);
}
Also used : JPlagReport(de.jplag.reporting2.reportobject.model.JPlagReport) File(java.io.File)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ExitException (de.jplag.exceptions.ExitException)1 JPlagOptions (de.jplag.options.JPlagOptions)1 JsonReport (de.jplag.reporting2.JsonReport)1 Report (de.jplag.reporting2.Report)1 ComparisonReport (de.jplag.reporting2.reportobject.model.ComparisonReport)1 JPlagReport (de.jplag.reporting2.reportobject.model.JPlagReport)1 File (java.io.File)1 IOException (java.io.IOException)1 Namespace (net.sourceforge.argparse4j.inf.Namespace)1