-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into report-viewer/clus…
…ter-graph
- Loading branch information
Showing
29 changed files
with
1,567 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
core/src/main/java/de/jplag/reporting/jsonfactory/DummyWriter.java
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
core/src/main/java/de/jplag/reporting/jsonfactory/FileWriter.java
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
core/src/main/java/de/jplag/reporting/jsonfactory/ToDiskWriter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
core/src/main/java/de/jplag/reporting/reportobject/model/Metric.java
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
core/src/main/java/de/jplag/reporting/reportobject/writer/DummyWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package de.jplag.reporting.reportobject.writer; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* This writer is used as a mock for testing purposes only. | ||
*/ | ||
public class DummyWriter extends JsonWriter { | ||
private static final Logger logger = LoggerFactory.getLogger(DummyWriter.class); | ||
private static final String MESSAGE = "DummyWriter writes object {} to path {} with name {} as JSON."; | ||
|
||
@Override | ||
public void writeFile(Object fileToSave, String folderPath, String fileName) { | ||
logger.info(MESSAGE, fileToSave, folderPath, fileName); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
core/src/main/java/de/jplag/reporting/reportobject/writer/FileWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.jplag.reporting.reportobject.writer; | ||
|
||
/** | ||
* Responsible for writing a specific file type to the disk. | ||
* @param <T> Object that the FileWriter writes. | ||
*/ | ||
public interface FileWriter<T> { | ||
|
||
/** | ||
* Saves the provided object to the provided path under the provided name | ||
* @param fileContent The object to save | ||
* @param folderPath The path to save the object to | ||
* @param fileName The name to save the object under | ||
*/ | ||
void writeFile(T fileContent, String folderPath, String fileName); | ||
} |
29 changes: 29 additions & 0 deletions
29
core/src/main/java/de/jplag/reporting/reportobject/writer/JsonWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package de.jplag.reporting.reportobject.writer; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
/** | ||
* Writes an object with {@link com.fasterxml.jackson.annotation.JsonProperty}s to the disk. | ||
*/ | ||
public class JsonWriter implements FileWriter<Object> { | ||
private static final Logger logger = LoggerFactory.getLogger(JsonWriter.class); | ||
private static final ObjectMapper objectMapper = new ObjectMapper(); | ||
private static final String WRITE_ERROR = "Failed to write JSON file {}"; | ||
|
||
@Override | ||
public void writeFile(Object fileToSave, String folderPath, String fileName) { | ||
Path path = Path.of(folderPath, fileName); | ||
try { | ||
objectMapper.writeValue(path.toFile(), fileToSave); | ||
} catch (IOException e) { | ||
logger.error(WRITE_ERROR, e, path); | ||
} | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
core/src/main/java/de/jplag/reporting/reportobject/writer/TextWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package de.jplag.reporting.reportobject.writer; | ||
|
||
import java.io.BufferedWriter; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Writes plain text to a file. | ||
*/ | ||
public class TextWriter implements FileWriter<String> { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(TextWriter.class); | ||
private static final String WRITE_ERROR = "Failed to write text file {}"; | ||
|
||
@Override | ||
public void writeFile(String fileContent, String folderPath, String fileName) { | ||
String path = Path.of(folderPath, fileName).toString(); | ||
try (BufferedWriter writer = new BufferedWriter(new java.io.FileWriter(path))) { | ||
writer.write(fileContent); | ||
} catch (IOException e) { | ||
logger.error(WRITE_ERROR, e, path); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.