Skip to content
Snippets Groups Projects
Commit 009e68c7 authored by Konstantin Blaschke's avatar Konstantin Blaschke
Browse files

Finishing merge kernel Master on 4310. Removing unnecessary comments

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



Signed-off-by: default avatarKonstantin Blaschke <blaschke@fortiss.org>
parent 22d5f6f7
No related branches found
No related tags found
1 merge request!210Setting up Metric extraction plugin for AF3 : Issue 4310
......@@ -19,7 +19,6 @@ import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static org.fortiss.tooling.kernel.ui.service.IContextMenuService.BOTTOM_MOST_MENU_SECTION_ID;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
......@@ -29,12 +28,10 @@ import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.resource.ImageDescriptor;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.tooling.ext.quality.service.IModelQualityService;
import org.fortiss.tooling.ext.quality.service.ModelQualityService;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
import org.fortiss.tooling.kernel.utils.KernelModelElementUtils;
/**
* Crates a context menu entry to generate the for the selected
......@@ -73,6 +70,7 @@ public class ModelQualityExtractionMenu implements IContextMenuContributor {
/** */
private final FileProject fp;
/** Constructor. */
public MetricExtractionAction(FileProject fp) {
super(MENU_NAME, getActionIcon());
......@@ -83,9 +81,7 @@ public class ModelQualityExtractionMenu implements IContextMenuContributor {
@Override
public void run() {
ITopLevelElement top = IPersistencyService.getInstance().getTopLevelElementFor(this.fp);
IModelQualityService.getInstance().performMetricAnalysis(top);
System.out.println("We print something");
}
}
......
......@@ -40,8 +40,9 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.ext.quality.service.IModelQualityProvider.IVisitorModelQualityProvider;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
......@@ -116,20 +117,20 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr
}
/**
* @param top
* @param topLvl
* the file project on which the analysis should be performed
* @return result resulting metrics
*/
@Override
public Map<IProjectRootElement, IModelQualityProvider<? extends EObject>>
performMetricAnalysis(ITopLevelElement top) {
performMetricAnalysis(ITopLevelElement topLvl) {
Map<IProjectRootElement, IModelQualityProvider<? extends EObject>> result = new HashMap<>();
for(IProjectRootElement rootElement : top.getRootElements()) {
for(IProjectRootElement rootElement : EcoreUtils
.getChildrenWithType(topLvl.getRootModelElement(), IProjectRootElement.class)) {
if(rootElement instanceof IHierarchicElement) {
// TODO check get(0)
IHierarchicElement firstNode =
((IHierarchicElement)rootElement).getContainedElements().get(0);
HierarchicElementSizeProvider hes = new HierarchicElementSizeProvider();
hes.apply(firstNode);
System.out.println("checked in hierarchic metrics for: " + rootElement.getName());
......@@ -142,8 +143,6 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr
result.put(rootElement, hes);
}
}
last_metrics = result;
metricExtractionToCSV(result);
return result;
......@@ -205,13 +204,13 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr
if(data == null || data.isEmpty()) {
return;
}
// path to csv file
Path path = Paths.get("data_ultra_cool.csv");
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()))) {
......@@ -226,7 +225,7 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr
}
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
var anyProvider = data.values().iterator().next();
......@@ -256,18 +255,18 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr
@Override
public void accept(HierarchicElementSizeProvider provider) {
var metrics = provider.getStoredMetrics();
// These 4 data entries are just concatenated in front
var startStream = Stream.of(formattedDateTime, rootName, "null", "null");
// Collect all values from provider in the correct order and combine
// Collect all values from provider in the correct order and combine
var values = Stream
.concat(startStream,
valueKeys.stream().map(metrics::get).map(String::valueOf))
.collect(Collectors.joining(","));
try {
// write values
// write values
writer.write(values);
writer.write("\n");
} catch(IOException e) {
......
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