'use strict';

var _ = require('lodash');


function ModelCommand(cli, params, modeling) {

  var aliases = {
    service:     'bpmn:ServiceTask',
    user:        'bpmn:UserTask',
    manual:      'bpmn:ManualTask',
    task:        'bpmn:Task',
    end:         'bpmn:EndEvent',
    transaction: 'bpmn:Transaction',
    sub:         'bpmn:SubProcess',
    call:        'bpmn:CallActivity',
    icatch:      'bpmn:IntermediateCatchEvent',
    ithrow:      'bpmn:IntermediateThrowEvent',
    xor:         'bpmn:ExclusiveGateway',
    or:          'bpmn:InclusiveGateway',
    and:         'bpmn:ParallelGateway'
  };

  return {
    args: [
      params.shape('source'),
      params.string('chain')
    ],
    exec: function(source, chain) {

      var results = [];
      var types = chain.split(/\s*->\s*/);

      _.forEach(types, function(t) {
        if (!t) {
          return;
        }

        t = aliases[t] || t;

        source = cli.append(source, t, '150,0');
        results.push(source);
      });

      return results;
    }
  };
}

ModelCommand.$inject = [ 'cli', 'cli._params', 'modeling' ];

module.exports = ModelCommand;
@@ -12,17 +12,23 @@
 ';%0A%0Avar 
-_
+forEach
  = requi
@@ -37,16 +37,35 @@
 ('lodash
+/collection/forEach
 ');%0A%0A%0Afu
@@ -840,10 +840,8 @@
     
-_.
 forE
@@ -1096,15 +1096,19 @@
  = %5B
+%0A 
  'cli',
+%0A 
  'cl
@@ -1118,16 +1118,18 @@
 params',
+%0A 
  'modeli
@@ -1131,17 +1131,17 @@
 odeling'
- 
+%0A
 %5D;%0A%0Amodu

use lodash util directly