123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- <?php
- namespace CablemodemBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Gedmo\Mapping\Annotation as Gedmo;
- use JMS\Serializer\Annotation as JMS;
- use Symfony\Component\Validator\Constraints as Assert;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use Base\AdminBundle\Traits\TenancyIdTrait;
- use Base\AdminBundle\Traits\TenancyIdTraitInterface;
- use DeviceBundle\Interfaces\DeviceInterface;
- use DeviceBundle\Validator\Constraints as ValidatorAssert;
- use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
- use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity as SoftDeleteable;
- use Base\AdminBundle\Interfaces\SoftDeleteInterface;
- use MapBundle\Entity\Interfaces\LocationInterface;
- use MapBundle\Entity\Traits\LocationTrait;
- /**
- * @ORM\Entity
- * @ORM\Table(indexes={@ORM\Index(name="host", columns={"host"})})
- *
- * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true)
- *
- * @UniqueEntity(fields={"host"})
- *
- * @ValidatorAssert\Device
- */
- class CMTS implements DeviceInterface, TenancyIdTraitInterface, SoftDeleteInterface, LocationInterface
- {
- use ExtraDataTrait;
- use TenancyIdTrait;
- use SoftDeleteable;
- use LocationTrait;
- /**
- * @ORM\Column(name="id", type="bigint", nullable=false)
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="IDENTITY")
- */
- protected $id;
- /**
- * @ORM\Column(type="string", length=50)
- *
- * @Assert\NotNull
- */
- protected $name;
- /**
- * @ORM\Column(type="string", unique=true, length=50, nullable=false)
- *
- * @Assert\NotNull
- * @Assert\NotBlank
- */
- protected $host;
- /**
- * @ORM\Column(type="string")
- *
- * @Assert\NotNull
- */
- protected $snmpCommunity;
- /**
- * @ORM\Column(type="integer")
- *
- * @Assert\NotNull
- */
- protected $snmpVersion;
- /**
- * @ORM\Column(type="boolean", nullable=true, columnDefinition="BOOLEAN DEFAULT TRUE")
- */
- protected $executeSnmp = true;
- /**
- * @ORM\Column(type="integer")
- *
- * @Assert\NotNull
- */
- protected $docsVersion;
- /**
- * @ORM\ManyToOne(targetEntity="CMTSModel", fetch="EXTRA_LAZY")
- *
- * @JMS\MaxDepth(1)
- */
- protected $model;
- /**
- * @ORM\Column(type="integer", options={"unsigned":true, "default":10})
- */
- protected $timeScan = 10;
- /**
- * @ORM\Column(type="integer", options={"unsigned":true, "default":5})
- */
- protected $timeCmtsOctets = 5;
- /**
- * @ORM\Column(type="integer", options={"unsigned":true, "default":10})
- */
- protected $timeCmStats = 10;
- /**
- * @return string
- */
- public function __toString()
- {
- return (string)$this->name;
- }
- /**
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * @return string
- */
- public function getHost()
- {
- return $this->host;
- }
- /**
- * @return string
- */
- public function getSnmpCommunity()
- {
- return $this->snmpCommunity;
- }
- /**
- * @return int
- */
- public function getSnmpVersion()
- {
- return $this->snmpVersion;
- }
- /**
- * @return boolean
- */
- public function getExecuteSnmp()
- {
- return $this->executeSnmp;
- }
- /**
- * @return CMTSModel
- */
- public function getModel()
- {
- return $this->model;
- }
- /**
- * @param string $name
- *
- * @return $this
- */
- public function setName($name)
- {
- $this->name = $name;
- return $this;
- }
- /**
- * @param string $host
- *
- * @return $this
- */
- public function setHost($host)
- {
- $this->host = $host;
- return $this;
- }
- /**
- * @param string $snmpCommunity
- *
- * @return $this
- */
- public function setSnmpCommunity($snmpCommunity)
- {
- $this->snmpCommunity = $snmpCommunity;
- return $this;
- }
- /**
- * @param int $snmpVersion
- *
- * @return $this
- */
- public function setSnmpVersion($snmpVersion)
- {
- $this->snmpVersion = $snmpVersion;
- return $this;
- }
- /**
- * @param boolean $executeSnmp
- *
- * @return $this
- */
- public function setExecuteSnmp($executeSnmp)
- {
- $this->executeSnmp = $executeSnmp;
- return $this;
- }
- /**
- * @param CMTSModel $model
- *
- * @return $this
- */
- public function setModel($model)
- {
- $this->model = $model;
- return $this;
- }
- /**
- * @return array
- */
- public function getDeviceData()
- {
- $extraData = [
- 'name' => $this->name,
- 'host' => $this->host,
- 'modelId' => $this->model ? $this->model->getId() : null,
- 'mark' => null,
- 'library' => null,
- 'snmpCommunity' => $this->snmpCommunity,
- 'snmpVersion' => $this->snmpVersion,
- 'docsVersion' => $this->docsVersion,
- 'executeSnmp' => $this->executeSnmp,
- 'timeScan' => $this->timeScan,
- 'timeCmtsOctets' => $this->timeCmtsOctets,
- 'timeCmStats' => $this->timeCmStats,
- ];
- if($this->model) {
- $extraData['mark'] = $this->model->getMark();
- $extraData['library'] = $this->model->getLibrary();
- }
- return [
- 'deviceType' => get_class($this),
- 'deviceId' => $this->id,
- 'ip' => $this->host,
- 'tenancy' => $this->tenancyId,
- 'extraData' => json_encode($extraData),
- ];
- }
- /**
- * @return array
- */
- public function getSoftDeleteCriteria()
- {
- return array('host' => $this->host);
- }
- /**
- * Set timeScan
- *
- * @param integer $timeScan
- */
- public function setTimeScan($timeScan)
- {
- $this->timeScan = $timeScan;
- }
- /**
- * Get timeScan
- *
- * @return integer
- */
- public function getTimeScan()
- {
- return $this->timeScan;
- }
- /**
- * Set timeCmtsOctets
- *
- * @param integer $timeCmtsOctets
- */
- public function setTimeCmtsOctets($timeCmtsOctets)
- {
- $this->timeCmtsOctets = $timeCmtsOctets;
- }
- /**
- * Get timeCmtsOctets
- *
- * @return integer
- */
- public function getTimeCmtsOctets()
- {
- return $this->timeCmtsOctets;
- }
- /**
- * Set timeCmStats
- *
- * @param integer $timeCmStats
- */
- public function setTimeCmStats($timeCmStats)
- {
- $this->timeCmStats = $timeCmStats;
- }
- /**
- * Get timeCmStats
- *
- * @return integer
- */
- public function getTimeCmStats()
- {
- return $this->timeCmStats;
- }
- /**
- * @return int
- */
- public function getDocsVersion()
- {
- return $this->docsVersion;
- }
- /**
- * @param int $docsVersion
- *
- * @return $this
- */
- public function setDocsVersion($docsVersion)
- {
- $this->docsVersion = $docsVersion;
- return $this;
- }
- }
|