chore(importer): attempt optimization

This commit is contained in:
Nico Rehwaldt 2014-09-08 19:04:18 +02:00
parent 179121880f
commit b5483b2565

View File

@ -17,7 +17,10 @@ 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 = [];
function parse(definitions) {
var visitor = { var visitor = {
@ -36,19 +39,20 @@ function importBpmnDiagram(diagram, definitions, done) {
var walker = new BpmnTreeWalker(visitor); var walker = new BpmnTreeWalker(visitor);
try {
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;