<?php
namespace Airavata\Model\Dbevent;

/**
 * Autogenerated by Thrift Compiler (0.10.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
use Thrift\Base\TBase;
use Thrift\Type\TType;
use Thrift\Type\TMessageType;
use Thrift\Exception\TException;
use Thrift\Exception\TProtocolException;
use Thrift\Protocol\TProtocol;
use Thrift\Protocol\TBinaryProtocolAccelerated;
use Thrift\Exception\TApplicationException;


final class CrudType {
  const CREATE = 0;
  const READ = 1;
  const UPDATE = 2;
  const DELETE = 3;
  static public $__names = array(
    0 => 'CREATE',
    1 => 'READ',
    2 => 'UPDATE',
    3 => 'DELETE',
  );
}

final class EntityType {
  const USER_PROFILE = 0;
  const TENANT = 1;
  const GROUP = 2;
  const PROJECT = 3;
  const EXPERIMENT = 4;
  const APPLICATION = 5;
  const SHARING = 6;
  const REGISTRY = 7;
  static public $__names = array(
    0 => 'USER_PROFILE',
    1 => 'TENANT',
    2 => 'GROUP',
    3 => 'PROJECT',
    4 => 'EXPERIMENT',
    5 => 'APPLICATION',
    6 => 'SHARING',
    7 => 'REGISTRY',
  );
}

final class DBEventType {
  const PUBLISHER = 0;
  const SUBSCRIBER = 1;
  static public $__names = array(
    0 => 'PUBLISHER',
    1 => 'SUBSCRIBER',
  );
}

class DBEventPublisherContext {
  static $_TSPEC;

  /**
   * @var int
   */
  public $crudType = null;
  /**
   * @var int
   */
  public $entityType = null;
  /**
   * @var string
   */
  public $entityDataModel = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'crudType',
          'type' => TType::I32,
          ),
        2 => array(
          'var' => 'entityType',
          'type' => TType::I32,
          ),
        3 => array(
          'var' => 'entityDataModel',
          'type' => TType::STRING,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['crudType'])) {
        $this->crudType = $vals['crudType'];
      }
      if (isset($vals['entityType'])) {
        $this->entityType = $vals['entityType'];
      }
      if (isset($vals['entityDataModel'])) {
        $this->entityDataModel = $vals['entityDataModel'];
      }
    }
  }

  public function getName() {
    return 'DBEventPublisherContext';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->crudType);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->entityType);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 3:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->entityDataModel);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('DBEventPublisherContext');
    if ($this->crudType !== null) {
      $xfer += $output->writeFieldBegin('crudType', TType::I32, 1);
      $xfer += $output->writeI32($this->crudType);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->entityType !== null) {
      $xfer += $output->writeFieldBegin('entityType', TType::I32, 2);
      $xfer += $output->writeI32($this->entityType);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->entityDataModel !== null) {
      $xfer += $output->writeFieldBegin('entityDataModel', TType::STRING, 3);
      $xfer += $output->writeString($this->entityDataModel);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class DBEventPublisher {
  static $_TSPEC;

  /**
   * @var \Airavata\Model\Dbevent\DBEventPublisherContext
   */
  public $publisherContext = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'publisherContext',
          'type' => TType::STRUCT,
          'class' => '\Airavata\Model\Dbevent\DBEventPublisherContext',
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['publisherContext'])) {
        $this->publisherContext = $vals['publisherContext'];
      }
    }
  }

  public function getName() {
    return 'DBEventPublisher';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::STRUCT) {
            $this->publisherContext = new \Airavata\Model\Dbevent\DBEventPublisherContext();
            $xfer += $this->publisherContext->read($input);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('DBEventPublisher');
    if ($this->publisherContext !== null) {
      if (!is_object($this->publisherContext)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('publisherContext', TType::STRUCT, 1);
      $xfer += $this->publisherContext->write($output);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class DBEventSubscriber {
  static $_TSPEC;

  /**
   * @var string
   */
  public $subscriberService = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'subscriberService',
          'type' => TType::STRING,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['subscriberService'])) {
        $this->subscriberService = $vals['subscriberService'];
      }
    }
  }

  public function getName() {
    return 'DBEventSubscriber';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->subscriberService);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('DBEventSubscriber');
    if ($this->subscriberService !== null) {
      $xfer += $output->writeFieldBegin('subscriberService', TType::STRING, 1);
      $xfer += $output->writeString($this->subscriberService);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class DBEventMessageContext {
  static $_TSPEC;

  /**
   * @var \Airavata\Model\Dbevent\DBEventPublisher
   */
  public $publisher = null;
  /**
   * @var \Airavata\Model\Dbevent\DBEventSubscriber
   */
  public $subscriber = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'publisher',
          'type' => TType::STRUCT,
          'class' => '\Airavata\Model\Dbevent\DBEventPublisher',
          ),
        2 => array(
          'var' => 'subscriber',
          'type' => TType::STRUCT,
          'class' => '\Airavata\Model\Dbevent\DBEventSubscriber',
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['publisher'])) {
        $this->publisher = $vals['publisher'];
      }
      if (isset($vals['subscriber'])) {
        $this->subscriber = $vals['subscriber'];
      }
    }
  }

  public function getName() {
    return 'DBEventMessageContext';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::STRUCT) {
            $this->publisher = new \Airavata\Model\Dbevent\DBEventPublisher();
            $xfer += $this->publisher->read($input);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::STRUCT) {
            $this->subscriber = new \Airavata\Model\Dbevent\DBEventSubscriber();
            $xfer += $this->subscriber->read($input);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('DBEventMessageContext');
    if ($this->publisher !== null) {
      if (!is_object($this->publisher)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('publisher', TType::STRUCT, 1);
      $xfer += $this->publisher->write($output);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->subscriber !== null) {
      if (!is_object($this->subscriber)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('subscriber', TType::STRUCT, 2);
      $xfer += $this->subscriber->write($output);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class DBEventMessage {
  static $_TSPEC;

  /**
   * @var int
   */
  public $dbEventType = null;
  /**
   * @var \Airavata\Model\Dbevent\DBEventMessageContext
   */
  public $messageContext = null;
  /**
   * @var string
   */
  public $publisherService = null;

  public function __construct($vals=null) {
    if (!isset(self::$_TSPEC)) {
      self::$_TSPEC = array(
        1 => array(
          'var' => 'dbEventType',
          'type' => TType::I32,
          ),
        2 => array(
          'var' => 'messageContext',
          'type' => TType::STRUCT,
          'class' => '\Airavata\Model\Dbevent\DBEventMessageContext',
          ),
        3 => array(
          'var' => 'publisherService',
          'type' => TType::STRING,
          ),
        );
    }
    if (is_array($vals)) {
      if (isset($vals['dbEventType'])) {
        $this->dbEventType = $vals['dbEventType'];
      }
      if (isset($vals['messageContext'])) {
        $this->messageContext = $vals['messageContext'];
      }
      if (isset($vals['publisherService'])) {
        $this->publisherService = $vals['publisherService'];
      }
    }
  }

  public function getName() {
    return 'DBEventMessage';
  }

  public function read($input)
  {
    $xfer = 0;
    $fname = null;
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::I32) {
            $xfer += $input->readI32($this->dbEventType);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::STRUCT) {
            $this->messageContext = new \Airavata\Model\Dbevent\DBEventMessageContext();
            $xfer += $this->messageContext->read($input);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 3:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->publisherService);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write($output) {
    $xfer = 0;
    $xfer += $output->writeStructBegin('DBEventMessage');
    if ($this->dbEventType !== null) {
      $xfer += $output->writeFieldBegin('dbEventType', TType::I32, 1);
      $xfer += $output->writeI32($this->dbEventType);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->messageContext !== null) {
      if (!is_object($this->messageContext)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('messageContext', TType::STRUCT, 2);
      $xfer += $this->messageContext->write($output);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->publisherService !== null) {
      $xfer += $output->writeFieldBegin('publisherService', TType::STRING, 3);
      $xfer += $output->writeString($this->publisherService);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}


