public static function construct(BusinessProcess $bp, Session $session)
 {
     $key = 'changes.' . $bp->getName();
     $changes = new ProcessChanges();
     $changes->sessionKey = $key;
     if ($actions = $session->get($key)) {
         foreach ($actions as $string) {
             $changes->push(NodeAction::unserialize($string));
         }
     }
     $changes->session = $session;
     return $changes;
 }
 public function onSuccess()
 {
     $name = $this->getValue('name');
     $title = $this->getValue('title');
     $backend = $this->getValue('backend');
     if ($this->config === null) {
         // New config
         $config = new BusinessProcess();
         $config->setName($name);
         if ($title) {
             $config->setTitle($title);
         }
         if ($backend) {
             $config->setBackendName($backend);
         }
         if ($this->getValue('state_type') === 'soft') {
             $config->useSoftStates();
         } else {
             $config->useHardStates();
         }
         $this->storage->storeProcess($config);
         $config->clearAppliedChanges();
         $this->setRedirectUrl($this->getRedirectUrl()->setParams(array('config' => $name, 'unlocked' => true)));
         Notification::success(sprintf('Process %s has been created', $name));
     } else {
         // Existing config
         $config = $this->config;
         if ($title) {
             $config->setTitle($title);
         }
         if ($backend) {
             $config->setBackendName($backend);
         }
         if ($this->getValue('state_type') === 'soft') {
             $config->useSoftStates();
         } else {
             $config->useHardStates();
         }
         $this->storage->storeProcess($config);
         $config->clearAppliedChanges();
         $this->getRedirectUrl()->setParam('config', $name);
         Notification::success(sprintf('Process %s has been stored', $name));
     }
 }
 /**
  * @return BusinessProcess
  */
 public function loadProcess($name)
 {
     Benchmark::measure('Loading business process ' . $name);
     $bp = new BusinessProcess();
     $bp->setName($name);
     $this->parseFile($name, $bp);
     $this->loadHeader($name, $bp);
     Benchmark::measure('Business process ' . $name . ' loaded');
     return $bp;
 }
 public function __construct(BusinessProcess $bp, SessionNamespace $session)
 {
     $this->bp = $bp;
     $this->session = $session;
     $this->key = 'simulations.' . $bp->getName();
 }
 public function isEditMode()
 {
     return $this->bp->isEditMode();
 }