aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/src/converter/UML2TGF.xtend
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/src/converter/UML2TGF.xtend')
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/src/converter/UML2TGF.xtend152
1 files changed, 78 insertions, 74 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/src/converter/UML2TGF.xtend b/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/src/converter/UML2TGF.xtend
index f3762d54..283ddf79 100644
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/src/converter/UML2TGF.xtend
+++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/src/converter/UML2TGF.xtend
@@ -31,14 +31,12 @@ class UML2TGF {
31// new OpenDrive15ResourceFactoryImpl); 31// new OpenDrive15ResourceFactoryImpl);
32 val res = resourceSet.getResource(URI.createFileURI("instance//Instance_model_A.uml"), true); 32 val res = resourceSet.getResource(URI.createFileURI("instance//Instance_model_A.uml"), true);
33 val docRoot = res.contents.get(0) as Model 33 val docRoot = res.contents.get(0) as Model
34
35
36 34
35// val nodes = docRoot.allOwnedElements.filter [it instanceof InstanceSpecification && it instanceof EnumerationLiteral != true]
37 val nodes = docRoot.allOwnedElements.filter[it instanceof InstanceSpecification] 36 val nodes = docRoot.allOwnedElements.filter[it instanceof InstanceSpecification]
38
39 val allTypes = new HashSet<Object> 37 val allTypes = new HashSet<Object>
40 38
41 for(e : nodes){ 39 for (e : nodes) {
42 allTypes.add(e.class) 40 allTypes.add(e.class)
43 } 41 }
44 42
@@ -51,64 +49,63 @@ class UML2TGF {
51 val unidentified = new ArrayList<Object> 49 val unidentified = new ArrayList<Object>
52 val enums = new ArrayList<Object> 50 val enums = new ArrayList<Object>
53 51
54/* 52 /*
55 val writer = new PrintWriter("output//graph-" + formattedDate + ".tgf") 53 * val writer = new PrintWriter("output//graph-" + formattedDate + ".tgf")
56 54
57 println("begin Writing") 55 * println("begin Writing")
58 56
59 // transform Nodes 57 * // transform Nodes
60 var ind = 0 58 * var ind = 0
61 for (node : nodes) { 59 * for (node : nodes) {
62 val n = node as InstanceSpecification 60 * val n = node as InstanceSpecification
63 map.put(n, ind) 61 * map.put(n, ind)
64 62
65 writer.append(ind + " " + n.name + "\n") 63 * writer.append(ind + " " + n.name + "\n")
66 ind++ 64 * ind++
67 } 65 * }
68 writer.append("#\n") 66 * writer.append("#\n")
69 67
70// println(node.name) 68 * // println(node.name)
71// 69 * //
72// println(node.slots) 70 * // println(node.slots)
73// val sl = node.slots 71 * // val sl = node.slots
74// 72 * //
75// for (s : sl) { 73 * // for (s : sl) {
76// val v = s.values.get(0) 74 * // val v = s.values.get(0)
77// if (v instanceof InstanceValue) { 75 * // if (v instanceof InstanceValue) {
78// println(map.get(v.instance)) 76 * // println(map.get(v.instance))
79// } else { 77 * // } else {
80// println("--" + v.class) 78 * // println("--" + v.class)
81// } 79 * // }
82// } 80 * // }
83 // transform Edges 81 * // transform Edges
84 var Slot s = null 82 * var Slot s = null
85 try { 83 * try {
86 for (node : nodes) { 84 * for (node : nodes) {
87 val n = node as InstanceSpecification 85 * val n = node as InstanceSpecification
88 val nind = map.get(n) 86 * val nind = map.get(n)
89 for (slot : n.slots) { 87 * for (slot : n.slots) {
90 s = slot 88 * s = slot
91 var fname = "null" 89 * var fname = "null"
92 if(slot.definingFeature !== null) fname = slot.definingFeature.name 90 * if(slot.definingFeature !== null) fname = slot.definingFeature.name
93 for (v : slot.values) { 91 * for (v : slot.values) {
94 if (v instanceof InstanceValue) { 92 * if (v instanceof InstanceValue) {
95 val vind = map.get(v.instance) 93 * val vind = map.get(v.instance)
96 94
97 writer.append(nind + " " + vind + " " + fname + "\n") 95 * writer.append(nind + " " + vind + " " + fname + "\n")
98 } 96 * }
99// else { 97 * // else {
100// println("--" + v.class) 98 * // println("--" + v.class)
101// } 99 * // }
102 } 100 * }
103 } 101 * }
104 } 102 * }
105 } catch (Exception e) { 103 * } catch (Exception e) {
106 println(s.definingFeature) 104 * println(s.definingFeature)
107 } 105 * }
108 106
109 writer.close 107 * writer.close
110 println("End")*/ 108 println("End")*/
111
112 val writer = new PrintWriter("output//graph-" + formattedDate + ".gml") 109 val writer = new PrintWriter("output//graph-" + formattedDate + ".gml")
113 110
114 println("begin Writing") 111 println("begin Writing")
@@ -120,17 +117,23 @@ class UML2TGF {
120 var numEdges = 0 117 var numEdges = 0
121 for (node : nodes) { 118 for (node : nodes) {
122 val n = node as InstanceSpecification 119 val n = node as InstanceSpecification
120 if(map.keySet.contains(n)) System.err.println("contained")
123 map.put(n, ind) 121 map.put(n, ind)
124 122
125 writer.append(''' node 123 writer.append(''' node
126 [ 124 [
127 id «ind» 125 id «ind»
128 label "«IF n.name !== null»«n.name»«ENDIF»" 126 label "«IF n.name !== null»«n.name»«ENDIF»"
129«IF n.name !== null && n.name.contains("Household")» graphics 127«IF n.name !== null && (n.name.contains("Household")|| n.name.contains("Household"))» graphics
130 [ 128 [
131 fill "#00FF00" 129 fill "#00FF00"
132 ] 130 ]
133 «ENDIF» 131 «ENDIF»
132 «IF node instanceof EnumerationLiteral» graphics
133 [
134 fill "#FF0000"
135 ]
136 «ENDIF»
134 ] 137 ]
135 ''') 138 ''')
136 ind++ 139 ind++
@@ -153,7 +156,7 @@ class UML2TGF {
153 var Slot s = null 156 var Slot s = null
154 try { 157 try {
155 for (node : nodes) { 158 for (node : nodes) {
156 if (node instanceof EnumerationLiteral != true) { 159// if (node instanceof EnumerationLiteral != true) {
157 val n = node as InstanceSpecification 160 val n = node as InstanceSpecification
158 val nind = map.get(n) 161 val nind = map.get(n)
159 for (slot : n.slots) { 162 for (slot : n.slots) {
@@ -164,8 +167,9 @@ class UML2TGF {
164 if (v instanceof InstanceValue) { 167 if (v instanceof InstanceValue) {
165 val value = v as InstanceValue 168 val value = v as InstanceValue
166 if (map.containsKey(value.instance)) { 169 if (map.containsKey(value.instance)) {
167 val vind = map.get(value.instance) 170 if (value.instance instanceof EnumerationLiteral != true) {
168 writer.append(''' edge 171 val vind = map.get(value.instance)
172 writer.append(''' edge
169 [ 173 [
170 source «nind» 174 source «nind»
171 target «vind» 175 target «vind»
@@ -173,7 +177,10 @@ class UML2TGF {
173 ] 177 ]
174 ''') 178 ''')
175// writer.append(nind + " " + vind + " " + fname + "\n") 179// writer.append(nind + " " + vind + " " + fname + "\n")
176 numEdges++ 180 numEdges++
181 } else {
182 enums.add(value + " -> " + value.instance)
183 }
177 } else { 184 } else {
178 unidentified.add(value + " -> " + value.instance) 185 unidentified.add(value + " -> " + value.instance)
179 } 186 }
@@ -182,11 +189,8 @@ class UML2TGF {
182 } 189 }
183 } 190 }
184 } 191 }
185 } 192// }
186 else{ 193
187 enums.add(node)
188 }
189
190 } 194 }
191 } catch (Exception e) { 195 } catch (Exception e) {
192 println(s.definingFeature) 196 println(s.definingFeature)
@@ -194,7 +198,7 @@ class UML2TGF {
194// printset("All types", allTypes) 198// printset("All types", allTypes)
195 printset("Unhandled Edges", set) 199 printset("Unhandled Edges", set)
196 printset("Unidentified trgs", unidentified) 200 printset("Unidentified trgs", unidentified)
197// printset("Enums:", enums) 201 printset("Enums:", enums)
198 writer.append("]") 202 writer.append("]")
199 writer.close 203 writer.close
200 println("End") 204 println("End")