-
Notifications
You must be signed in to change notification settings - Fork 328
6. Report File Generation
ReportObjectFactory
is the starting point and anchor for the reporting process. CLI
calls ReportObjectFactory#createAndSaveReport(result: JPlagResult, path: String)
, providing the factory with the result of the JPlag run and the desired target path for the report.
ReportObjectFactory#createAndSaveReport
then goes on and delegates the creation of all necessary files and folders and consequently zips the report.
result.zip
│ overview.json
| submissionFileIndex.json
| options.json
│
└───submissions
│ └───submissionId1
│ │ submission1File1
│ │ submission1File2
│ │ ...
│ └───submissionId2
│ │ submission2File1
│ │ submission2File2
│ │ ...
│ └───submissionId...
│ │ ...
│ └───submissionIdN
│ │ submissionNFile1
│ │ submissionNFile2
│ │ ...
│ submission1-submission2.json
│ submission1-submission3.json
│ submission1-submission....json
│ submission1-submissionN.json
│ submission2-submission3.json
│ submission2-submission....json
│ submission2-submissionN.json
│ ...
The report zip contains
-
overview.json
- The
overview.json
encapsulates the main information from a JPlagResult such as base directory path, language, min- and max-metric, etc. Theoverview.json
provides data to theOverviewView.vue
that is first displayed after the report is dropped into the viewer. Corresponds to the Java recordOverviewReport
.
- The
-
submissionFileIndex.json
- The
submissionFileIndex.json
stores a list of all files in the submission for each submission id.
- The
-
options.json
- This File contains all options given to JPlag either over the CLI or programmatically
-
submissions
- This folder contains all files of all submissions JPlag was run with. For each submission the
submissions
folder contains a subfolder with the name of the corresponding submission id. A subfolder for a submission contains all files of said submission. These files are displayed in theComparisonView.vue
- This folder contains all files of all submissions JPlag was run with. For each submission the
-
comparison files
- For each submission pair submission1 submission2 with ids submissionId1 and submissionId2, the report contains either submissionId1-submissionId2.json or submissionId2-submissionId1.json. This file contains information the comparison between the two submissions, such as the similarity and concrete matches. Corresponds to the Java record
ComparisonReport
.
- For each submission pair submission1 submission2 with ids submissionId1 and submissionId2, the report contains either submissionId1-submissionId2.json or submissionId2-submissionId1.json. This file contains information the comparison between the two submissions, such as the similarity and concrete matches. Corresponds to the Java record
The overview.json
contains a map that associates a submission id to its display name.
For internal use in the report viewer use only(!) the submission id. Whenever the name of a submission has to be displayed in the report viewer, the id has to be resolved to its display name first. The report viewer's vuex store provides a getter for this resolution.
At the beginning of report generation a map and a function that associate a JPlag Submission
to a submission id is built. Whenever you reference a submission in a report viewer DTO use this map/function to resolve the submission to its id.
The new design of JPlag reporting and viewing enables the easy addition of new attributes. Adding a new attribute follows the pattern:
In JPlag:
- Introduce a new attribute to the Java DTO that represents the file you aim to change.
- Define how the attribute is obtained from the JPlagResult. Do so either by introducing a new component that extracts the attribute from the
JPlagResult
or by modifying an existing component.ReportObjectFactory
then calls this component and assigns the result to the attribute defined in 1.
In the Report Viewer:
- Introduce the new attribute to the Typescript DTO.
- Define how the attribute is extracted from the JSON file.
- Display the attribute in the desired Vue component.
An example is provided in the following section which explains how new attributes can be introduced to the JPlagReport and then processed in the report viewer. In the following example we add the number of tokens per match to the JPlag report and view.
Task: Adding the number of tokens in a match, which has to be displayed in the MatchesTable in the ComparisonView.
- Add
int tokens
toMatch.java
(sub-model ofComparisonReport.java
) - Modify the existing component
ComparisonReportWriter.java
to additionally extract the number of tokens in a match from theJPlagResult.java
and save it in the Match DTO - Add
tokens: number
toMatch.ts
- Edit
ComparisonFactory.ts
to get the number of tokens from the JSON report file. [report-viewer] - Edit
MatchTable.vue
to display the tokens number in theComparisonView.vue
.