diff options
Diffstat (limited to 'Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/EMFGraph.xtend')
-rw-r--r-- | Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/EMFGraph.xtend | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/EMFGraph.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/EMFGraph.xtend index 959006f4..8fa29fe6 100644 --- a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/EMFGraph.xtend +++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/EMFGraph.xtend | |||
@@ -7,10 +7,15 @@ import java.util.List | |||
7 | import org.eclipse.emf.common.util.EList | 7 | import org.eclipse.emf.common.util.EList |
8 | import org.eclipse.emf.ecore.EObject | 8 | import org.eclipse.emf.ecore.EObject |
9 | import org.eclipse.emf.ecore.EReference | 9 | import org.eclipse.emf.ecore.EReference |
10 | import org.eclipse.xtend.lib.annotations.Accessors | ||
10 | 11 | ||
11 | class EMFGraph extends Graph{ | 12 | class EMFGraph extends Graph{ |
13 | @Accessors(PUBLIC_GETTER) | ||
14 | var EObject root; | ||
15 | |||
12 | def void init (EObject root, List<Metric> metrics, String name, List<EReference> referenceTypes){ | 16 | def void init (EObject root, List<Metric> metrics, String name, List<EReference> referenceTypes){ |
13 | val otherContents = root.eAllContents.toList(); | 17 | val otherContents = root.eAllContents.toList(); |
18 | this.root = root; | ||
14 | otherContents.add(root); | 19 | otherContents.add(root); |
15 | init(otherContents, metrics, name, referenceTypes); | 20 | init(otherContents, metrics, name, referenceTypes); |
16 | } | 21 | } |
@@ -30,17 +35,11 @@ class EMFGraph extends Graph{ | |||
30 | statistic.addNodeWithAllTypes(it, types); | 35 | statistic.addNodeWithAllTypes(it, types); |
31 | ] | 36 | ] |
32 | 37 | ||
33 | referenceTypes.forEach[it| | 38 | referenceTypes.forEach[it| |
34 | var typeToAdd = it; | 39 | // Only consider the edges that are not derived to preserve the statistical property |
35 | 40 | if(!it.derived){ | |
36 | // TODO: Here is to only consider one part of opposite edges | 41 | statistic.addEdgeType(it.name); |
37 | // if(it.upperBound != -1 && it.EOpposite !== null && | 42 | } |
38 | // (it.EOpposite.upperBound == -1 || it.EOpposite.upperBound > it.upperBound | ||
39 | // )){ | ||
40 | // typeToAdd = it.EOpposite; | ||
41 | // } | ||
42 | // | ||
43 | statistic.addEdgeType(typeToAdd.name); | ||
44 | ]; | 43 | ]; |
45 | 44 | ||
46 | objects.forEach[source| | 45 | objects.forEach[source| |
@@ -62,6 +61,12 @@ class EMFGraph extends Graph{ | |||
62 | this.name = name; | 61 | this.name = name; |
63 | } | 62 | } |
64 | 63 | ||
64 | def void removeReference(EReference r){ | ||
65 | if (statistic.containsEdgeType(r.name)){ | ||
66 | statistic.removeReference(r.name, r.containment); | ||
67 | } | ||
68 | } | ||
69 | |||
65 | /** | 70 | /** |
66 | * Set basic information for the output | 71 | * Set basic information for the output |
67 | */ | 72 | */ |
@@ -94,15 +99,8 @@ class EMFGraph extends Graph{ | |||
94 | } | 99 | } |
95 | 100 | ||
96 | def addEdge(EObject source, EObject target, EReference r){ | 101 | def addEdge(EObject source, EObject target, EReference r){ |
97 | // TODO: Here is to only consider one part of opposite edges | 102 | //Only add the edge if the reference is not derived to preserve the statistical property |
98 | //check for the opposite reference and do not add if its opposite will be added | 103 | if(target !== null && r !== null && !r.derived){ |
99 | // if(r.upperBound != -1 && r.EOpposite !== null && | ||
100 | // (r.EOpposite.upperBound == -1 || r.EOpposite.upperBound > r.upperBound | ||
101 | // )){ | ||
102 | // return; | ||
103 | // } | ||
104 | |||
105 | if(target !== null && r !== null){ | ||
106 | statistic.addEdge(source, target, r.name); | 104 | statistic.addEdge(source, target, r.name); |
107 | } | 105 | } |
108 | } | 106 | } |