/** * This method processes the models and returns the status. * * @access public * @param BT\Exchange $exchange the exchange given to process * @return integer the status code */ public function process(BT\Exchange $exchange) { $body = $exchange->getIn()->getBody(); if ($body instanceof Common\Mutable\HashMap) { $writer = new Config\JSON\Writer($body); $writer->config($this->policy->toDictionary()); $writer->export($exchange->getOut()); return BT\Task\Status::SUCCESS; } return BT\Task\Status::FAILED; }
/** * This method processes the models and returns the status. * * @access public * @param BT\Exchange $exchange the exchange given to process * @return integer the status code */ public function process(BT\Exchange $exchange) { $body = $exchange->getIn()->getBody(); if ($body instanceof IO\File) { try { $reader = new Config\JSON\Reader($body, array('assoc' => false)); $models = new Common\Mutable\HashMap(); $models->putEntry('Order', OrderCalc\Engine\Model\Marshaller::unmarshal($reader)); $exchange->getIn()->setBody($models); return BT\Task\Status::SUCCESS; } catch (Throwable\Runtime\Exception $ex) { $exchange->getOut()->setBody($ex); return BT\Task\Status::ERROR; } } return BT\Task\Status::FAILED; }