-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (33 loc) · 1.32 KB
/
index.js
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
const fs = require('fs');
const parser = require('./app/bpmn/parser')
const measure = require('./app/bpmn/measure')
const suggestion = require('./app/bpmn/suggestion')
const folder = './input/';
var stream = fs.createWriteStream('./out.json');
stream.once('open', function(fd) {
var results = [];
fs.readdirSync(folder).forEach(file => {
let xmlModel = fs.readFileSync(folder + file, 'utf8');
let structure = parser.parse(xmlModel);
for (let process in structure) {
let model = { file: file };
model.process = process;
model.structure = structure[process];
let originalMM = measure.originalMismatch(structure[process]);
let modifiedMM = measure.modifiedMismatch(structure[process]);
model.originalMM = originalMM;
model.modifiedMM = modifiedMM;
model.suggestion = {};
model.estimation = {};
if (modifiedMM > 0) {
let _suggestion = suggestion.suggestChanges(structure[process]);
let estimation = suggestion.estimateCost(_suggestion);
model.suggestion = _suggestion;
model.estimation = estimation;
}
results.push(model);
}
});
stream.write(JSON.stringify(results));
stream.end();
});