123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- <?php
- namespace RadiusBundle\Entity;
- use Base\AdminBundle\Traits\TenancyIdTrait;
- use Base\AdminBundle\Traits\TenancyIdTraitInterface;
- use Doctrine\ORM\Mapping as ORM;
- use DeviceBundle\Interfaces\DeviceInterface;
- use DeviceBundle\Validator\Constraints as ValidatorAssert;
- use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
- use MapBundle\Entity\Interfaces\LocationInterface;
- use MapBundle\Entity\Traits\LocationTrait;
- use Symfony\Component\Validator\Constraints as Assert;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- /**
- * @ORM\Table
- * @ORM\Entity
- * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"host", "tenancy_id"})})
- *
- * @UniqueEntity(fields={"host", "tenancyId"}, message="errors.duplicate_key")
- *
- * @ValidatorAssert\Device
- */
- class NAS implements TenancyIdTraitInterface, DeviceInterface, LocationInterface
- {
- use ExtraDataTrait;
- use TenancyIdTrait;
- use LocationTrait;
- /**
- * @var int
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string $description
- *
- * @ORM\Column(type="string", length=50, nullable=true)
- */
- private $description;
- /**
- * @var string $host
- *
- * @ORM\Column(type="string", length=50, unique=true)
- */
- private $host;
- /**
- * @var string $snmpComunity
- *
- * @ORM\Column(type="string", length=50)
- */
- private $snmpComunity;
- /**
- * @var string $snmpVersion
- *
- * @ORM\Column(type="integer")
- */
- private $snmpVersion;
- /**
- * @var string $radiusPassword
- *
- * @ORM\Column(type="string", length=50)
- */
- private $radiusPassword;
- /**
- * @var NASModel $model
- *
- * @ORM\ManyToOne(targetEntity="NASModel", inversedBy="nass", fetch="EXTRA_LAZY")
- * @ORM\JoinColumn(name="model_id", referencedColumnName="id", onDelete="SET NULL")
- */
- private $model;
- /**
- * @var boolean $acctEnabled
- *
- * @ORM\Column(type="boolean", nullable=true)
- */
- private $acctEnabled;
- /**
- * @return string
- */
- public function __toString()
- {
- return (string)$this->description;
- }
- /**
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param int $id
- *
- * @return mixed Retorna el objeto.
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getDescription()
- {
- return $this->description;
- }
- /**
- * @param mixed $description
- *
- * @return mixed Retorna el objeto.
- */
- public function setDescription($description)
- {
- $this->description = $description;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getHost()
- {
- return $this->host;
- }
- /**
- * @param mixed $host
- *
- * @return mixed Retorna el objeto.
- */
- public function setHost($host)
- {
- $this->host = $host;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getSnmpComunity()
- {
- return $this->snmpComunity;
- }
- /**
- * @param mixed $snmpComunity
- *
- * @return mixed Retorna el objeto.
- */
- public function setSnmpComunity($snmpComunity)
- {
- $this->snmpComunity = $snmpComunity;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getSnmpVersion()
- {
- return $this->snmpVersion;
- }
- /**
- * @param mixed $snmpVersion
- *
- * @return mixed Retorna el objeto.
- */
- public function setSnmpVersion($snmpVersion)
- {
- $this->snmpVersion = $snmpVersion;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getRadiusPassword()
- {
- return $this->radiusPassword;
- }
- /**
- * @param mixed $radiusPassword
- *
- * @return mixed Retorna el objeto.
- */
- public function setRadiusPassword($radiusPassword)
- {
- $this->radiusPassword = $radiusPassword;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getModel()
- {
- return $this->model;
- }
- /**
- * @param mixed $model
- *
- * @return mixed Retorna el objeto.
- */
- public function setModel($model)
- {
- $this->model = $model;
- return $this;
- }
- /**
- * @return bool
- */
- public function isAcctEnabled()
- {
- return $this->acctEnabled;
- }
- /**
- * @param bool $acctEnabled
- *
- * @return mixed Retorna el objeto.
- */
- public function setAcctEnabled($acctEnabled)
- {
- $this->acctEnabled = $acctEnabled;
- return $this;
- }
- /**
- * @return array
- */
- public function getDeviceData()
- {
- $deviceData = array();
- $deviceData['deviceType'] = get_class($this);
- $deviceData['deviceId'] = $this->id;
- $deviceData['ip'] = $this->host;
- $deviceData['tenancy'] = $this->tenancyId;
- $deviceExtraData = array('snmpCommunity' => $this->snmpComunity, 'snmpVersion' => $this->snmpVersion, 'radiusPassword' => $this->radiusPassword,
- 'acctEnabled' => $this->acctEnabled, 'description' => $this->description);
- if ($this->model) {
- $model = $this->getModel();
- $deviceExtraData['modelId'] = $model->getId();
- $deviceExtraData['library'] = $model->getLibrary();
- } else {
- $deviceExtraData['modelId'] = null;
- $deviceExtraData['library'] = null;
- }
- $deviceData['extraData'] = json_encode($deviceExtraData);
- return $deviceData;
- }
- }
|