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; ...@@ -19,7 +19,6 @@ import static java.util.Arrays.asList;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static org.fortiss.tooling.kernel.ui.service.IContextMenuService.BOTTOM_MOST_MENU_SECTION_ID; import static org.fortiss.tooling.kernel.ui.service.IContextMenuService.BOTTOM_MOST_MENU_SECTION_ID;
import java.util.List; import java.util.List;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
...@@ -29,12 +28,10 @@ import org.eclipse.jface.action.IContributionItem; ...@@ -29,12 +28,10 @@ import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.fortiss.af3.project.model.FileProject; import org.fortiss.af3.project.model.FileProject;
import org.fortiss.tooling.ext.quality.service.IModelQualityService; 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.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService; import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor; import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider; 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 * Crates a context menu entry to generate the for the selected
...@@ -73,6 +70,7 @@ public class ModelQualityExtractionMenu implements IContextMenuContributor { ...@@ -73,6 +70,7 @@ public class ModelQualityExtractionMenu implements IContextMenuContributor {
/** */ /** */
private final FileProject fp; private final FileProject fp;
/** Constructor. */ /** Constructor. */
public MetricExtractionAction(FileProject fp) { public MetricExtractionAction(FileProject fp) {
super(MENU_NAME, getActionIcon()); super(MENU_NAME, getActionIcon());
...@@ -83,9 +81,7 @@ public class ModelQualityExtractionMenu implements IContextMenuContributor { ...@@ -83,9 +81,7 @@ public class ModelQualityExtractionMenu implements IContextMenuContributor {
@Override @Override
public void run() { public void run() {
ITopLevelElement top = IPersistencyService.getInstance().getTopLevelElementFor(this.fp); ITopLevelElement top = IPersistencyService.getInstance().getTopLevelElementFor(this.fp);
IModelQualityService.getInstance().performMetricAnalysis(top); IModelQualityService.getInstance().performMetricAnalysis(top);
System.out.println("We print something"); System.out.println("We print something");
} }
} }
......
...@@ -40,8 +40,9 @@ import java.util.stream.Collectors; ...@@ -40,8 +40,9 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.eclipse.emf.ecore.EObject; 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.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.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem; import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService; import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
...@@ -116,20 +117,20 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr ...@@ -116,20 +117,20 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr
} }
/** /**
* @param top * @param topLvl
* the file project on which the analysis should be performed * the file project on which the analysis should be performed
* @return result resulting metrics * @return result resulting metrics
*/ */
@Override @Override
public Map<IProjectRootElement, IModelQualityProvider<? extends EObject>> public Map<IProjectRootElement, IModelQualityProvider<? extends EObject>>
performMetricAnalysis(ITopLevelElement top) { performMetricAnalysis(ITopLevelElement topLvl) {
Map<IProjectRootElement, IModelQualityProvider<? extends EObject>> result = new HashMap<>(); 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) { if(rootElement instanceof IHierarchicElement) {
// TODO check get(0) // TODO check get(0)
IHierarchicElement firstNode = IHierarchicElement firstNode =
((IHierarchicElement)rootElement).getContainedElements().get(0); ((IHierarchicElement)rootElement).getContainedElements().get(0);
HierarchicElementSizeProvider hes = new HierarchicElementSizeProvider(); HierarchicElementSizeProvider hes = new HierarchicElementSizeProvider();
hes.apply(firstNode); hes.apply(firstNode);
System.out.println("checked in hierarchic metrics for: " + rootElement.getName()); System.out.println("checked in hierarchic metrics for: " + rootElement.getName());
...@@ -142,8 +143,6 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr ...@@ -142,8 +143,6 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr
result.put(rootElement, hes); result.put(rootElement, hes);
} }
} }
last_metrics = result; last_metrics = result;
metricExtractionToCSV(result); metricExtractionToCSV(result);
return result; return result;
...@@ -205,13 +204,13 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr ...@@ -205,13 +204,13 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr
if(data == null || data.isEmpty()) { if(data == null || data.isEmpty()) {
return; return;
} }
// path to csv file // path to csv file
Path path = Paths.get("data_ultra_cool.csv"); Path path = Paths.get("data_ultra_cool.csv");
List<String> allKeys = new ArrayList<>(); List<String> allKeys = new ArrayList<>();
boolean createNewIndex = true; boolean createNewIndex = true;
if(Files.exists(path)) { if(Files.exists(path)) {
// Read first line and try to extract the keys from the already existing file // Read first line and try to extract the keys from the already existing file
try(BufferedReader reader = new BufferedReader(new FileReader(path.toFile()))) { try(BufferedReader reader = new BufferedReader(new FileReader(path.toFile()))) {
...@@ -226,7 +225,7 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr ...@@ -226,7 +225,7 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr
} }
try(var writer = new BufferedWriter(new FileWriter(path.toFile(), true))) { try(var writer = new BufferedWriter(new FileWriter(path.toFile(), true))) {
if(createNewIndex) { if(createNewIndex) {
// Create new index and write it into the first line of the file // Create new index and write it into the first line of the file
var anyProvider = data.values().iterator().next(); var anyProvider = data.values().iterator().next();
...@@ -256,18 +255,18 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr ...@@ -256,18 +255,18 @@ public class ModelQualityService extends EObjectAwareServiceBase<IModelQualityPr
@Override @Override
public void accept(HierarchicElementSizeProvider provider) { public void accept(HierarchicElementSizeProvider provider) {
var metrics = provider.getStoredMetrics(); var metrics = provider.getStoredMetrics();
// These 4 data entries are just concatenated in front // These 4 data entries are just concatenated in front
var startStream = Stream.of(formattedDateTime, rootName, "null", "null"); 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 var values = Stream
.concat(startStream, .concat(startStream,
valueKeys.stream().map(metrics::get).map(String::valueOf)) valueKeys.stream().map(metrics::get).map(String::valueOf))
.collect(Collectors.joining(",")); .collect(Collectors.joining(","));
try { try {
// write values // write values
writer.write(values); writer.write(values);
writer.write("\n"); writer.write("\n");
} catch(IOException e) { } 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