From 18db984057b83ca4962c89b6b79bdce6a660b58f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:42:35 +0200 Subject: Adding upstream version 2.4.0. Signed-off-by: Daniel Baumann --- library/Businessprocess/ImportedNode.php | 135 +++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 library/Businessprocess/ImportedNode.php (limited to 'library/Businessprocess/ImportedNode.php') diff --git a/library/Businessprocess/ImportedNode.php b/library/Businessprocess/ImportedNode.php new file mode 100644 index 0000000..3f0b460 --- /dev/null +++ b/library/Businessprocess/ImportedNode.php @@ -0,0 +1,135 @@ +parentBp = $parentBp; + $this->configName = $object->configName; + $this->nodeName = $object->node; + + parent::__construct((object) [ + 'name' => '@' . $this->configName . ':' . $this->nodeName, + 'operator' => null, + 'child_names' => null + ]); + } + + /** + * @return string + */ + public function getConfigName() + { + return $this->configName; + } + + /** + * @return string + */ + public function getNodeName() + { + return $this->nodeName; + } + + public function getIdentifier() + { + return $this->getName(); + } + + public function getBpConfig() + { + if ($this->bp === null) { + $this->bp = $this->parentBp->getImportedConfig($this->configName); + } + + return $this->bp; + } + + public function getAlias() + { + if ($this->alias === null) { + $this->alias = $this->importedNode()->getAlias(); + } + + return $this->alias; + } + + public function getOperator() + { + if ($this->operator === null) { + $this->operator = $this->importedNode()->getOperator(); + } + + return $this->operator; + } + + public function getChildNames() + { + if ($this->childNames === null) { + $this->childNames = $this->importedNode()->getChildNames(); + } + + return $this->childNames; + } + + /** + * @return BpNode + */ + protected function importedNode() + { + if ($this->importedNode === null) { + try { + $this->importedNode = $this->getBpConfig()->getBpNode($this->nodeName); + } catch (Exception $e) { + return $this->createFailedNode($e); + } + } + + return $this->importedNode; + } + + /** + * @param Exception $e + * + * @return BpNode + */ + protected function createFailedNode(Exception $e) + { + $this->parentBp->addError($e->getMessage()); + $node = new BpNode((object) array( + 'name' => $this->getName(), + 'operator' => '&', + 'child_names' => [] + )); + $node->setBpConfig($this->getBpConfig()); + $node->setState(2); + $node->setMissing(false) + ->setDowntime(false) + ->setAck(false) + ->setAlias($e->getMessage()); + + return $node; + } +} -- cgit v1.2.3