/** * Show a business process tree */ public function showAction() { $this->redirectIfConfigChosen(); if ($this->params->get('unlocked')) { $bp = $this->loadModifiedBpConfig(); $bp->unlock(); } else { $bp = $this->loadBpConfig(); } $this->setTitle('Business Process "%s"', $bp->getTitle()); $this->tabsForShow()->activate('show'); // Do not lock empty configs if ($bp->isEmpty() && !$this->view->compact && $bp->isLocked()) { $this->redirectNow($this->url()->with('unlocked', true)); } if ($node = $this->params->get('node')) { // Render a specific node $this->view->nodeName = $node; $this->view->bp = $bp->getNode($node); } else { // Render a single process $this->view->bp = $bp; if ($bp->hasWarnings()) { $this->view->warnings = $bp->getWarnings(); } } $bp->retrieveStatesFromBackend(); if ($bp->isLocked()) { $this->tabs()->extend(new DashboardAction()); } else { $simulation = new Simulation($bp, $this->session()); if ($this->params->get('dismissSimulations')) { Notification::success(sprintf($this->translate('%d applied simulation(s) have been dropped'), $simulation->count())); $simulation->clear(); $this->redirectNow($this->url()->without('dismissSimulations')->without('unlocked')); } $bp->applySimulation($simulation); } if ($this->isXhr()) { $this->setAutorefreshInterval(10); } else { // This will trigger the very first XHR refresh immediately on page // load. Please not that this may hammer the server in case we would // decide to use autorefreshInterval for HTML meta-refreshes also. $this->setAutorefreshInterval(1); } if ($this->params->get('mode') === 'toplevel') { $this->render('toplevel'); } }
public function applySimulation(Simulation $simulation) { $cnt = 0; foreach ($simulation->simulations() as $node => $s) { if (!$this->hasNode($node)) { continue; } $cnt++; $this->getNode($node)->setState($s->state)->setAck($s->acknowledged)->setDowntime($s->in_downtime)->setMissing(false); } $this->simulationCount = $cnt; }