Beispiel #1
0
 /**
  * Decode avro message
  *
  * @param Xcom_Xfabric_Model_Message_Abstract $message
  * @return Xcom_Xfabric_Model_Encoder_Avro
  */
 public function decode(Xcom_Xfabric_Model_Message_Abstract $message)
 {
     $rawSchema = $message->getSchema()->getRawSchema();
     $decodedBody = $this->decodeText($message->getBody(), $rawSchema);
     $message->setBody($decodedBody);
     return $this;
 }
Beispiel #2
0
 /**
  * Decode json data and retrieve array.
  *
  * @param Xcom_Xfabric_Model_Message_Abstract $message
  * @return Xcom_Xfabric_Model_Encoder_Json
  */
 public function decode(Xcom_Xfabric_Model_Message_Abstract $message)
 {
     $data = $message->getBody();
     $result = json_decode($data, true);
     $message->setBody($result);
     return $this;
 }
Beispiel #3
0
 protected function _initSchema()
 {
     parent::_initSchema();
     $this->addHeader(self::SCHEMA_VER_HEADER, $this->_schemaVersion);
     $this->addHeader(self::SCHEMA_URI_HEADER, $this->getSchemaUri());
     return $this;
 }
Beispiel #4
0
 /**
  * Get the schema URI.
  *
  * @param Xcom_Xfabric_Model_Message_Abstract $message
  * @return string
  */
 public function getSchemaUri($message)
 {
     $host = Mage::helper('xcom_xfabric')->getOntologyBaseUri();
     return $host . $message->getTopic() . '/' . $message->getSchemaVersion();
 }
Beispiel #5
0
 /**
  * Prepare data after it was loaded from database
  * @return Mage_Core_Model_Abstract
  */
 protected function _afterLoad()
 {
     if ($this->hasData()) {
         $this->setHeaders(unserialize($this->getData('headers')));
         $this->setBody(unserialize($this->getData('body')));
     }
     return parent::_afterLoad();
 }