mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-11 17:44:12 +00:00
chore(importer): attempt optimization
This commit is contained in:
parent
179121880f
commit
b5483b2565
@ -17,38 +17,42 @@ function importBpmnDiagram(diagram, definitions, done) {
|
|||||||
var importer = diagram.get('bpmnImporter'),
|
var importer = diagram.get('bpmnImporter'),
|
||||||
eventBus = diagram.get('eventBus');
|
eventBus = diagram.get('eventBus');
|
||||||
|
|
||||||
var warnings = [];
|
var error,
|
||||||
|
warnings = [];
|
||||||
|
|
||||||
var visitor = {
|
function parse(definitions) {
|
||||||
|
|
||||||
root: function(element) {
|
var visitor = {
|
||||||
return importer.add(element);
|
|
||||||
},
|
|
||||||
|
|
||||||
element: function(element, parentShape) {
|
root: function(element) {
|
||||||
return importer.add(element, parentShape);
|
return importer.add(element);
|
||||||
},
|
},
|
||||||
|
|
||||||
error: function(message, context) {
|
element: function(element, parentShape) {
|
||||||
warnings.push({ message: message, context: context });
|
return importer.add(element, parentShape);
|
||||||
}
|
},
|
||||||
};
|
|
||||||
|
|
||||||
var walker = new BpmnTreeWalker(visitor);
|
error: function(message, context) {
|
||||||
|
warnings.push({ message: message, context: context });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
var walker = new BpmnTreeWalker(visitor);
|
||||||
eventBus.fire('import.start');
|
|
||||||
|
|
||||||
// import
|
// import
|
||||||
walker.handleDefinitions(definitions);
|
walker.handleDefinitions(definitions);
|
||||||
|
|
||||||
eventBus.fire('import.success', { warnings: warnings });
|
|
||||||
|
|
||||||
done(null, warnings);
|
|
||||||
} catch (e) {
|
|
||||||
eventBus.fire('import.error', { error: e });
|
|
||||||
done(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventBus.fire('import.start');
|
||||||
|
|
||||||
|
try {
|
||||||
|
parse(definitions);
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventBus.fire(error ? 'import.error' : 'import.success', { error: error, warnings: warnings });
|
||||||
|
done(error, warnings);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.importBpmnDiagram = importBpmnDiagram;
|
module.exports.importBpmnDiagram = importBpmnDiagram;
|
Loading…
x
Reference in New Issue
Block a user