Skip to content
Snippets Groups Projects
Commit 27352dbb authored by blaschke's avatar blaschke
Browse files

Every project gets own file to store the data for it.

Issue-Ref: 4310
Issue-Url: af3#4310


Signed-off-by: default avatarKonstantin Blaschke <blaschke@fortiss.org>
parent 369c3487
No related branches found
No related tags found
1 merge request!210Setting up Metric extraction plugin for AF3 : Issue 4310
......@@ -227,7 +227,6 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
metricDataManagerInstance.getTreeNodeLookupTable().put(rootElement, rootNode);
metricUpdateListeners.forEach(l -> l.metricUpdate(rootElement));
}
// Store all currently saved metrics to the csv
CSVFileWriter.metricExtractionToCSV(updatedElements);
}
......
......@@ -27,6 +27,7 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -69,12 +70,15 @@ public class CSVFileWriter {
}
// path to csv file
Path path = new File(ModelQualityStorageManager.MODEL_QUALITY_PROJECT_DIR,
ModelQualityStorageManager.CSV_FILE_NAME).toPath();
Collection<DataRootElement> values = map.values();
DataRootElement firstValue = values.toArray(new DataRootElement[0])[0];
String projectName = firstValue.getTopLevelElement().getSaveableName();
Path path = new File(ModelQualityStorageManager.MODEL_QUALITY_PROJECT_DIR,
projectName.replace(ModelQualityStorageManager.AF3_PRJ_SUFFIX,ModelQualityStorageManager.CSV)).toPath();
List<String> allKeys = new ArrayList<>();
boolean createNewIndex = true;
if(Files.exists(path)) {
// Read first line and try to extract the keys from the already existing file
try(BufferedReader reader = new BufferedReader(new FileReader(path.toFile()))) {
......@@ -105,6 +109,8 @@ public class CSVFileWriter {
*/
private static void writeMetricsToFile(Map<IProjectRootElement, DataRootElement> map,
List<String> allKeys, Path path, boolean createNewIndex) {
try(var writer = new BufferedWriter(new FileWriter(path.toFile(), true))) {
if(createNewIndex) {
// Create new index and write it into the first line of the file
......
......@@ -38,6 +38,9 @@ public class ModelQualityStorageManager {
public static final File MODEL_QUALITY_PROJECT_DIR =
new File(WORKSPACE_ROOT.getLocation() + File.separator + AF3_QUALITY_DIRECTORY_NAME);
/** Defines the suffix of AF3 project files. */
public static final String AF3_PRJ_SUFFIX = "af3_23";
/** Name of the file in which the data is written. */
public static final String CSV_FILE_NAME = "metric_logfile.csv";
public static final String CSV = "csv";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment