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'),
|
||||
eventBus = diagram.get('eventBus');
|
||||
|
||||
var warnings = [];
|
||||
var error,
|
||||
warnings = [];
|
||||
|
||||
var visitor = {
|
||||
function parse(definitions) {
|
||||
|
||||
root: function(element) {
|
||||
return importer.add(element);
|
||||
},
|
||||
var visitor = {
|
||||
|
||||
element: function(element, parentShape) {
|
||||
return importer.add(element, parentShape);
|
||||
},
|
||||
root: function(element) {
|
||||
return importer.add(element);
|
||||
},
|
||||
|
||||
error: function(message, context) {
|
||||
warnings.push({ message: message, context: context });
|
||||
}
|
||||
};
|
||||
element: function(element, parentShape) {
|
||||
return importer.add(element, parentShape);
|
||||
},
|
||||
|
||||
var walker = new BpmnTreeWalker(visitor);
|
||||
error: function(message, context) {
|
||||
warnings.push({ message: message, context: context });
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
eventBus.fire('import.start');
|
||||
var walker = new BpmnTreeWalker(visitor);
|
||||
|
||||
// import
|
||||
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;
|
Loading…
Reference in New Issue