Controller for editing / creating Workflows
@param $scope
@param workflowService
@param $stateParams
@param $q
@param $timeout
@constructor
554698
function WorkflowFormController($scope, workflowService, workflowFlowService, $stateParams, $q, $timeout) {
  var self = this;
  self.model = false;
  self.submitted = false;

  //If there is no workflow ID, then we are creating a new workflow.
  var workflowPromise = $stateParams.workflowId ? workflowService.read($stateParams.workflowId) : $q.when({
    steps: []
  });

  workflowPromise.then(function(workflow) {
    $timeout(function() {
      self.model = workflow;
    });
  });

  self.done = function(isValid) {
    self.submitted = true;
    if (isValid) {
      var hasId = self.model.id;
      var createUpdatePromise;
      if (hasId) {
        createUpdatePromise = workflowService.update(self.model);
      } else {
        createUpdatePromise = workflowService.create(self.model);
      }
      createUpdatePromise.then(function(workflow) {
        workflowFlowService.goToWorkflowDetails(workflow);
      });
    }
  };

  self.selectWorkflow = function(event, workflow) {
    if (workflow.id) {
      workflowFlowService.goToWorkflowDetails(workflow);
    } else {
      workflowFlowService.goToWorkflowList();
    }
    event.preventDefault();
    event.stopPropagation();
  };
}
566992
function ($scope, element, attrs) {
      var opts = {};
      if (attrs.uiAnimate) {
        opts = $scope.$eval(attrs.uiAnimate);
        if (angular.isString(opts)) {
          opts = {'class': opts};
        }
      }
      opts = angular.extend({'class': 'ui-animate'}, options, opts);

      element.addClass(opts['class']);
      $timeout(function () {
        element.removeClass(opts['class']);
      }, 20, false);
    }
948507
function(name, datasetId) {
            name = name || '$stateChangeSuccess';
            datasetId = datasetId || 'default';
            $rootScope.$on(name, function (event, args) {
                visible.setActive(args.name, datasetId);
            });
        }
475697
function PageDirectiveController ($scope) {
  var ctrl = this;

  ctrl.isActive = function isActive () {
    return !!$scope.isActive;
  };

  ctrl.activate = function activate () {
    $scope.pagesCtrl.activate($scope);
  };

  $scope.internalControl = {
    activate: ctrl.activate,
    isActive: ctrl.isActive
  };
}
890770
function MainController($timeout) {
  /**
   * @type {import("ol/Map.js").default}
   */
  this.map = new olMap({
    layers: [
      new olLayerTile({
        source: new olSourceOSM()
      })
    ],
    view: new olView({
      center: [0, 0],
      zoom: 4
    })
  });

  /**
   * @type {boolean}
   */
  this.open = false;

  // We want the sidebar to be open at application launch so we set the `open`
  // property to true at startup.
  // But we need to do it asynchronously in order to have the `resizemap`
  // directive working. If we don't, the `ng-class` directive doesn't fire the
  // animation hooks.
  const self = this;
  $timeout(() => {
    self.open = true;
  }, 0);
}
607422
private function runTask($workflow, $taskServiceId, $taskId)
    {
        $task = $this->container->get("{$workflow}.task.{$taskServiceId}");

        if (!$task instanceof ExecutableTaskInterface) {
            throw new InvalidTaskClassException(
                "The service {$taskServiceId} must implement the ExecutableTaskInterface interface."
            );
        }

        if ($task instanceof ContainerAwareInterface) {
            $task->setContainer($this->container);
        }

        if ($task instanceof LoggerAwareInterface) {
            /** @var LoggerInterface $logger */
            $logger = $this->container->get('logger');
            $task->setLogger($logger);
        }

        $parameters = new ParameterBag();
        $parameterBagId = "{$workflow}{$taskId}";

        /** @var ProviderInterface $stateStorage */
        $stateStorage = $this->container->get('state_storage');

        // Try to load the state file.
        try {
            $stateStorage->load($parameterBagId, $parameters);
        } catch (IOException $ignored) {
        }

        if ($task instanceof ParameterAwareInterface) {
            $task->setParameters($parameters);
        }

        $task->execute();

        $stateStorage->persist($parameterBagId, $parameters);
    }
332158
function $WebSocketProvider($rootScope, $q, $timeout, $websocketBackend) {

  function $WebSocket(url, protocols, options, wsOptions = {}) {
    if (!options && isObject(protocols) && !isArray(protocols)) {
      options = protocols;
      protocols = undefined;
    }
    this.wsOptions = wsOptions;
    this.protocols = protocols;
    this.url = url || 'Missing URL';
    this.ssl = /(wss)/i.test(this.url);

    // this.binaryType = '';
    // this.extensions = '';
    // this.bufferedAmount = 0;
    // this.trasnmitting = false;
    // this.buffer = [];

    // TODO: refactor options to use isDefined
    this.scope                       = options && options.scope                      || $rootScope;
    this.rootScopeFailover           = options && options.rootScopeFailover          && true;
    this.useApplyAsync               = options && options.useApplyAsync              || false;
    this.initialTimeout              = options && options.initialTimeout             || 500; // 500ms
    this.maxTimeout                  = options && options.maxTimeout                 || 5 * 60 * 1000; // 5 minutes
    this.reconnectIfNotNormalClose   = options && options.reconnectIfNotNormalClose  || false;
    this.binaryType                  = options && options.binaryType                 || 'blob';

    this._reconnectAttempts = 0;
    this.sendQueue          = [];
    this.onOpenCallbacks    = [];
    this.onMessageCallbacks = [];
    this.onErrorCallbacks   = [];
    this.onCloseCallbacks   = [];

    objectFreeze(this._readyStateConstants);

    if (url) {
      this._connect();
    } else {
      this._setInternalState(0);
    }

  }


  $WebSocket.prototype._readyStateConstants = {
    'CONNECTING': 0,
    'OPEN': 1,
    'CLOSING': 2,
    'CLOSED': 3,
    'RECONNECT_ABORTED': 4
  };

  $WebSocket.prototype._normalCloseCode = 1000;

  $WebSocket.prototype._reconnectableStatusCodes = [
    4000
  ];

  $WebSocket.prototype.safeDigest = function safeDigest(autoApply) {
    if (autoApply && !this.scope.$$phase) {
      this.scope.$digest();
    }
  };

  $WebSocket.prototype.bindToScope = function bindToScope(scope) {
    var self = this;
    if (scope) {
      this.scope = scope;
      if (this.rootScopeFailover) {
        this.scope.$on('$destroy', function() {
          self.scope = $rootScope;
        });
      }
    }
    return self;
  };

  $WebSocket.prototype._connect = function _connect(force) {
    if (force || !this.socket || this.socket.readyState !== this._readyStateConstants.OPEN) {
      this.socket = $websocketBackend.create(this.url, this.protocols, this.wsOptions);
      this.socket.onmessage = angular.bind(this, this._onMessageHandler);
      this.socket.onopen  = angular.bind(this, this._onOpenHandler);
      this.socket.onerror = angular.bind(this, this._onErrorHandler);
      this.socket.onclose = angular.bind(this, this._onCloseHandler);
      this.socket.binaryType = this.binaryType;
    }
  };

  $WebSocket.prototype.fireQueue = function fireQueue() {
    while (this.sendQueue.length && this.socket.readyState === this._readyStateConstants.OPEN) {
      var data = this.sendQueue.shift();

      this.socket.send(
        isString(data.message) || this.binaryType != 'blob' ? data.message : JSON.stringify(data.message)
      );
      data.deferred.resolve();
    }
  };

  $WebSocket.prototype.notifyOpenCallbacks = function notifyOpenCallbacks(event) {
    for (var i = 0; i < this.onOpenCallbacks.length; i++) {
      this.onOpenCallbacks[i].call(this, event);
    }
  };

  $WebSocket.prototype.notifyCloseCallbacks = function notifyCloseCallbacks(event) {
    for (var i = 0; i < this.onCloseCallbacks.length; i++) {
      this.onCloseCallbacks[i].call(this, event);
    }
  };

  $WebSocket.prototype.notifyErrorCallbacks = function notifyErrorCallbacks(event) {
    for (var i = 0; i < this.onErrorCallbacks.length; i++) {
      this.onErrorCallbacks[i].call(this, event);
    }
  };

  $WebSocket.prototype.onOpen = function onOpen(cb) {
    this.onOpenCallbacks.push(cb);
    return this;
  };

  $WebSocket.prototype.onClose = function onClose(cb) {
    this.onCloseCallbacks.push(cb);
    return this;
  };

  $WebSocket.prototype.onError = function onError(cb) {
    this.onErrorCallbacks.push(cb);
    return this;
  };


  $WebSocket.prototype.onMessage = function onMessage(callback, options) {
    if (!isFunction(callback)) {
      throw new Error('Callback must be a function');
    }

    if (options && isDefined(options.filter) && !isString(options.filter) && !(options.filter instanceof RegExp)) {
      throw new Error('Pattern must be a string or regular expression');
    }

    this.onMessageCallbacks.push({
      fn: callback,
      pattern: options ? options.filter : undefined,
      autoApply: options ? options.autoApply : true
    });
    return this;
  };

  $WebSocket.prototype._onOpenHandler = function _onOpenHandler(event) {
    this._reconnectAttempts = 0;
    this.notifyOpenCallbacks(event);
    this.fireQueue();
  };

  $WebSocket.prototype._onCloseHandler = function _onCloseHandler(event) {
    var self = this;
    if (self.useApplyAsync) {
      self.scope.$applyAsync(function() {
        self.notifyCloseCallbacks(event);
      });
    } else {
      self.notifyCloseCallbacks(event);
      self.safeDigest(true);
    }
    if ((this.reconnectIfNotNormalClose && event.code !== this._normalCloseCode) || this._reconnectableStatusCodes.indexOf(event.code) > -1) {
      this.reconnect();
    }
  };

  $WebSocket.prototype._onErrorHandler = function _onErrorHandler(event) {
    var self = this;
    if (self.useApplyAsync) {
      self.scope.$applyAsync(function() {
        self.notifyErrorCallbacks(event);
      });
    } else {
      self.notifyErrorCallbacks(event);
      self.safeDigest(true);
    }
  };

  $WebSocket.prototype._onMessageHandler = function _onMessageHandler(message) {
    var pattern;
    var self = this;
    var currentCallback;
    for (var i = 0; i < self.onMessageCallbacks.length; i++) {
      currentCallback = self.onMessageCallbacks[i];
      pattern = currentCallback.pattern;
      if (pattern) {
        if (isString(pattern) && message.data === pattern) {
          applyAsyncOrDigest(currentCallback.fn, currentCallback.autoApply, message);
        }
        else if (pattern instanceof RegExp && pattern.exec(message.data)) {
          applyAsyncOrDigest(currentCallback.fn, currentCallback.autoApply, message);
        }
      }
      else {
        applyAsyncOrDigest(currentCallback.fn, currentCallback.autoApply, message);
      }
    }

    function applyAsyncOrDigest(callback, autoApply, args) {
      args = arraySlice.call(arguments, 2);
      if (self.useApplyAsync) {
        self.scope.$applyAsync(function() {
          callback.apply(self, args);
        });
      } else {
        callback.apply(self, args);
        self.safeDigest(autoApply);
      }
    }

  };

  $WebSocket.prototype.close = function close(force) {
    if (force || !this.socket.bufferedAmount) {
      this.socket.close();
    }
    return this;
  };

  $WebSocket.prototype.send = function send(data) {
    var deferred = $q.defer();
    var self = this;
    var promise = cancelableify(deferred.promise);

    if (self.readyState === self._readyStateConstants.RECONNECT_ABORTED) {
      deferred.reject('Socket connection has been closed');
    }
    else {
      self.sendQueue.push({
        message: data,
        deferred: deferred
      });
      self.fireQueue();
    }

    // Credit goes to @btford
    function cancelableify(promise) {
      promise.cancel = cancel;
      var then = promise.then;
      promise.then = function() {
        var newPromise = then.apply(this, arguments);
        return cancelableify(newPromise);
      };
      return promise;
    }

    function cancel(reason) {
      self.sendQueue.splice(self.sendQueue.indexOf(data), 1);
      deferred.reject(reason);
      return self;
    }

    if ($websocketBackend.isMocked && $websocketBackend.isMocked() &&
            $websocketBackend.isConnected(this.url)) {
      this._onMessageHandler($websocketBackend.mockSend());
    }

    return promise;
  };

  $WebSocket.prototype.reconnect = function reconnect() {
    this.close();

    var backoffDelay = this._getBackoffDelay(++this._reconnectAttempts);

    var backoffDelaySeconds = backoffDelay / 1000;
    console.log('Reconnecting in ' + backoffDelaySeconds + ' seconds');

    $timeout(angular.bind(this, this._connect), backoffDelay);

    return this;
  };
  // Exponential Backoff Formula by Prof. Douglas Thain
  // http://dthain.blogspot.co.uk/2009/02/exponential-backoff-in-distributed.html
  $WebSocket.prototype._getBackoffDelay = function _getBackoffDelay(attempt) {
    var R = Math.random() + 1;
    var T = this.initialTimeout;
    var F = 2;
    var N = attempt;
    var M = this.maxTimeout;

    return Math.floor(Math.min(R * T * Math.pow(F, N), M));
  };

  $WebSocket.prototype._setInternalState = function _setInternalState(state) {
    if (Math.floor(state) !== state || state < 0 || state > 4) {
      throw new Error('state must be an integer between 0 and 4, got: ' + state);
    }

    // ie8 wat
    if (!objectDefineProperty) {
      this.readyState = state || this.socket.readyState;
    }
    this._internalConnectionState = state;


    forEach(this.sendQueue, function(pending) {
      pending.deferred.reject('Message cancelled due to closed socket connection');
    });
  };

  // Read only .readyState
  if (objectDefineProperty) {
    objectDefineProperty($WebSocket.prototype, 'readyState', {
      get: function() {
        return this._internalConnectionState || this.socket.readyState;
      },
      set: function() {
        throw new Error('The readyState property is read-only');
      }
    });
  }

  return function(url, protocols, options) {
    return new $WebSocket(url, protocols, options);
  };
}
109679
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $start = microtime(true);

        $this->getContainer()->get('ez_migration_bundle.step_executed_listener.tracing')->setOutput($output);

        $workflowService = $this->getWorkflowService();

        $workflowName = $input->getOption('workflow');
        if ($workflowName != null) {
            $suspendedWorkflow = $workflowService->getWorkflow($workflowName);
            if (!$suspendedWorkflow) {
                throw new \Exception("Workflow '$workflowName' not found");
            }
            if ($suspendedWorkflow->status != Migration::STATUS_SUSPENDED) {
                throw new \Exception("Workflow '$workflowName' is not suspended, can not resume it");
            }

            $suspendedWorkflows = array($suspendedWorkflow);
        } else {
            $suspendedWorkflows = $workflowService->getWorkflowsByStatus(Migration::STATUS_SUSPENDED);
        };

        $output->writeln('<info>Found ' . count($suspendedWorkflows) . ' suspended workflows</info>');

        if (!count($suspendedWorkflows)) {
            $output->writeln('Nothing to do');
            return;
        }

        // ask user for confirmation to make changes
        if ($input->isInteractive() && !$input->getOption('no-interaction')) {
            $dialog = $this->getHelperSet()->get('dialog');
            if (!$dialog->askConfirmation(
                $output,
                '<question>Careful, the database will be modified. Do you want to continue Y/N ?</question>',
                false
            )
            ) {
                $output->writeln('<error>Workflow resuming cancelled!</error>');
                return 0;
            }
        }

        $executed = 0;
        $failed = 0;

        foreach($suspendedWorkflows as $suspendedWorkflow) {
            $output->writeln("<info>Resuming {$suspendedWorkflow->name}</info>");

            try {
                $workflowService->resumeWorkflow($suspendedWorkflow, !$input->getOption('no-transactions'));
                $executed++;
            } catch (\Exception $e) {
                $output->writeln("\n<error>Workflow failed! Reason: " . $e->getMessage() . "</error>\n");
                $failed++;
            }
        }

        $time = microtime(true) - $start;
        $output->writeln("Resumed $executed workflows, failed $failed");
        $output->writeln("Time taken: ".sprintf('%.2f', $time)." secs, memory: ".sprintf('%.2f', (memory_get_peak_usage(true) / 1000000)). ' MB');

        if ($failed) {
            return 2;
        }
    }
275632
function webWorkerSearchFactory($q, $rootScope, NG_PAGES) {

    console.log('Using WebWorker Search Index')

    var searchIndex = $q.defer();
    var results;

    var worker = new Worker('js/search-worker.js');

    // The worker will send us a message in two situations:
    // - when the index has been built, ready to run a query
    // - when it has completed a search query and the results are available
    worker.onmessage = function(oEvent) {
      $rootScope.$apply(function() {

        switch(oEvent.data.e) {
          case 'index-ready':
            searchIndex.resolve();
            break;
          case 'query-ready':
            var pages = oEvent.data.d.map(function(path) {
              return NG_PAGES[path];
            });
            results.resolve(pages);
            break;
        }
      });
    };

    // The actual service is a function that takes a query string and
    // returns a promise to the search results
    return function(q) {

      // We only run the query once the index is ready
      return searchIndex.promise.then(function() {

        results = $q.defer();
        worker.postMessage({ q: q });
        return results.promise;
      });
    };
  }
185696
function handleRedirect(redirect, state, params, options) {
      /**
       * @ngdoc event
       * @name ui.router.state.$state#$stateNotFound
       * @eventOf ui.router.state.$state
       * @eventType broadcast on root scope
       * @description
       * Fired when a requested state **cannot be found** using the provided state name during transition.
       * The event is broadcast allowing any handlers a single chance to deal with the error (usually by
       * lazy-loading the unfound state). A special `unfoundState` object is passed to the listener handler,
       * you can see its three properties in the example. You can use `event.preventDefault()` to abort the
       * transition and the promise returned from `go` will be rejected with a `'transition aborted'` value.
       *
       * @param {Object} event Event object.
       * @param {Object} unfoundState Unfound State information. Contains: `to, toParams, options` properties.
       * @param {State} fromState Current state object.
       * @param {Object} fromParams Current state params.
       *
       * @example
       *
       * <pre>
       * // somewhere, assume lazy.state has not been defined
       * $state.go("lazy.state", {a:1, b:2}, {inherit:false});
       *
       * // somewhere else
       * $scope.$on('$stateNotFound',
       * function(event, unfoundState, fromState, fromParams){
       *     console.log(unfoundState.to); // "lazy.state"
       *     console.log(unfoundState.toParams); // {a:1, b:2}
       *     console.log(unfoundState.options); // {inherit:false} + default options
       * })
       * </pre>
       */
      var evt = $rootScope.$broadcast('$stateNotFound', redirect, state, params);

      if (evt.defaultPrevented) {
        $urlRouter.update();
        return TransitionAborted;
      }

      if (!evt.retry) {
        return null;
      }

      // Allow the handler to return a promise to defer state lookup retry
      if (options.$retry) {
        $urlRouter.update();
        return TransitionFailed;
      }
      var retryTransition = $state.transition = $q.when(evt.retry);

      retryTransition.then(function() {
        if (retryTransition !== $state.transition) return TransitionSuperseded;
        redirect.options.$retry = true;
        return $state.transitionTo(redirect.to, redirect.toParams, redirect.options);
      }, function() {
        return TransitionAborted;
      });
      $urlRouter.update();

      return retryTransition;
    }
184974
public function setStates($objects, $processes, $onlySuccess)
    {
        $objects = ( ! is_array($objects) && ! $objects instanceof \ArrayAccess) ? array($objects) : $objects;

        if (0 === count($objects)) {
            return;
        }

        $ordersIndexedByWorkflowIdentifier = array();
        foreach ($objects as $object) {
            if (!$object instanceof ModelStateInterface) {
                throw new \InvalidArgumentException();
            }

            $ordersIndexedByWorkflowIdentifier[$object->getWorkflowIdentifier()] = $object;
        }

        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('ms')
            ->from('Lexik\Bundle\WorkflowBundle\Entity\ModelState', 'ms')
            ->andWhere($qb->expr()->in('ms.workflowIdentifier', array_keys($ordersIndexedByWorkflowIdentifier)))
            ->orderBy('ms.id');

        if (count($processes)) {
            $qb->andWhere($qb->expr()->in('ms.processName', $processes));
        }

        if ($onlySuccess) {
            $qb->andWhere('ms.successful = 1');
        }

        $states = $qb->getQuery()->getResult();

        foreach ($states as $state) {
            $ordersIndexedByWorkflowIdentifier[$state->getWorkflowIdentifier()]->addState($state);
        }
    }
1115262
function(callback) {
    // Activate current
    var current = $state.current();

    if(current) {

      // Reset
      _resetActive().then(function() {

        // Render
        var viewsPromised = {};
        var templates = current.templates || {};
        var controllers = current.controllers || {};
        angular.forEach(templates, function(template, id) {
          if(_viewHash[id]) {
            var view = _viewHash[id];
            var controller = controllers[id];
            viewsPromised[id] = _renderView(id, view, template, controller);
            _activeSet[id] = view;
          }
        });

        $q.all(viewsPromised).then(function() {
          callback();
        }, callback);

      }, callback);

    // None
    } else {
      callback();
    }
  }
657088
private function trySetPageWorkflowState(Page $page, State $workflow = null)
    {
        $page->setWorkflowState(null);
        if (null !== $workflow) {
            if (null === $workflow->getLayout() || $workflow->getLayout()->getUid() === $page->getLayout()->getUid()) {
                $page->setWorkflowState($workflow);
            }
        }
    }
162916
function (option) {

    this.start_time = null;
    this.workflow = option.workflow;
    this.wf_len = this.workflow.length;
    this.timer = null;
    this.interval = option.interval || 15;

    this.onStart = option.onStart || function () { };
    this.onProgress = option.onProgress || function () { };
    this.onEnd = option.onEnd || function () { };

    if (typeof this.workflow[0] === "function") {
        this.stopSeries = false;
        this.isSeries = true;
        this.workIndex = 0;
    } else {
        var i=0,
            j,
            startLen;
        for (; i < this.wf_len; i++) {
            var start =  this.workflow[i].start;
            if (typeof start !== "number") {


                j=0;
                startLen=start.length;
                for (; j < startLen; j++) {
                    this.workflow.splice(i, 0, { work: this.workflow[i].work, start: start[j] });
                }
                i += startLen;
                this.workflow.splice(i--, 1);
                this.wf_len--;
                this.wf_len += startLen;

            }
        }
    }
}
687320
static function startJob($workflow_job_key, $workflow_job_config, $start_state) {

        $workflow_key = self::createWorkflowKeyFromConfig($workflow_job_config);

        $workflow_name = $workflow_job_config["name"];
        /**
         * Checking if a flow is already running
         */
        if (self::isWorkflowRunning($workflow_key)) {
            throw new \Exception("A job for $workflow_name is already running.");
        }

        /**
         *  Check how long its since last job run... we just don't want to spam errors.
         */
        $error_ttl = Util::isDevServer() ? 60 : Moment::ONEDAY;

        if (self::isWorkflowInErrorState($workflow_key, $error_ttl)) {
            throw new \Exception("A job for $workflow_name have failed less than $error_ttl seconds ago, skipping.");
        }

        $workflow_job_config = array_merge($workflow_job_config, [
            "status" => self::STATUS_RUNNING,
            "start_state" => $start_state,
            "end_state" => $start_state,
            "finished" => new \DateTime(),
        ]);

        DataStore::saveWorkflowJob($workflow_job_key, $workflow_job_config);
        return $workflow_job_config;
    }
553464
function ClientModelDocItemsController($state) {
    var vm = this;

    // the selected item id
    var curClientModelDocId = null;

    // check if this item is selected
    vm.isSelected = isSelected;
    // switch to the detail state
    vm.showInDetails = showInDetails;

    /**
     * Check if the passed item is the current selected item
     *
     * @param {Object} clientModelDoc - The object to check for selection
     */
    function isSelected(clientModelDoc) {
      return curClientModelDocId === clientModelDoc._id;
    }

    /**
     * Open the detail state with the selected item
     *
     * @param {Object} clientModelDoc - The clientModelDoc to edit
     */
    function showInDetails(clientModelDoc) {
      curClientModelDocId = clientModelDoc._id;
      $state.go('clientModelDoc.list.detail', {'id': curClientModelDocId});
    }
  }
5829
def create
      @workflow = Workflow.new(workflow_params)


      respond_to do |format|
        if @workflow.save
          format.html {
            if(@workflow.stages.count > 1)
              redirect_to configure_stages_workflow_path(@workflow), notice: 'Workflow was successfully created. Please configure transitions.'
            else
              redirect_to @workflow, notice: 'Workflow was successfully created.'
            end

          }
          format.json { render json: @workflow, status: :created, location: @workflow }
        else
          format.html { render action: "new" }
          format.json { render json: @workflow.errors, status: :unprocessable_entity }
        end
      end
    end