blob: 870424d8c2accd44c8160216dcaf63995f03efb0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package hu.bme.mit.inf.yakinduModelExtractor;
import java.util.List;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.yakindu.sct.model.sgraph.State;
import org.yakindu.sct.model.sgraph.Statechart;
public class Main {
public static void main(String[] args) {
ModelManager manager = new ModelManager();
Yakindu2CommonModel converter = new Yakindu2CommonModel();
int models = 0;
int objects = 0;
String years[] = {"2015","2016","2017"};
for(String year : years) {
String folderPath = "D:\\Eclipse\\GIT\\RemoHF\\"+year;
// Loading folder
List<String> paths = manager.loadAllModelPathsInDirectory(folderPath);
int index = 1;
for(String path : paths) {
Statechart s = null;
try{
EObject root = manager.loadModel(path);
s = (Statechart) root;
} catch (Exception e) {
System.out.println("unable to load: "+ path);
}
if(s!=null) {
EObject s2 = converter.transform(s);
//manager.saveModel(s2, "output/R"+year+index+".xmi");
int countObjects = countObjects(s2);
System.out.println(countObjects);
objects += countObjects;
models++;
}
//System.out.println(year + " Progress: " + 100.0*index/paths.size() + "%");
index++;
}
System.out.println(year + " done.");
}
System.out.println("All done.");
System.out.println(objects);
System.out.println(models);
System.out.println(1.0*objects/models);
}
private static int countObjects(EObject root) {
int objects = 1;
TreeIterator<EObject> i = root.eAllContents();
while(i.hasNext()) {
i.next();
objects++;
}
return objects;
}
}
|