瀏覽代碼

update entidades

Guillermo Espinoza 7 年之前
父節點
當前提交
302d74532e
共有 2 個文件被更改,包括 86 次插入77 次删除
  1. 40 34
      src/CablemodemBundle/Entity/CMTS.php
  2. 46 43
      src/CablemodemBundle/Entity/Cablemodem.php

+ 40 - 34
src/CablemodemBundle/Entity/CMTS.php

@@ -10,22 +10,28 @@ 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;
 
 /**
  * @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
 {
-    
+
     use ExtraDataTrait;
     use TenancyIdTrait;
     use SoftDeleteable;
-    
+
     /**
      * @ORM\Column(name="id", type="bigint", nullable=false)
      * @ORM\Id
@@ -35,14 +41,14 @@ class CMTS implements DeviceInterface, TenancyIdTraitInterface, SoftDeleteInterf
 
     /**
      * @ORM\Column(type="string", length=50)
-     * 
+     *
      * @Assert\NotNull
      */
     protected $name;
 
     /**
      * @ORM\Column(type="string", unique=true, length=50, nullable=false)
-     * 
+     *
      * @Assert\NotNull
      * @Assert\NotBlank
      */
@@ -50,18 +56,18 @@ class CMTS implements DeviceInterface, TenancyIdTraitInterface, SoftDeleteInterf
 
     /**
      * @ORM\Column(type="string")
-     * 
+     *
      * @Assert\NotNull
      */
     protected $snmpCommunity;
 
     /**
      * @ORM\Column(type="integer")
-     * 
+     *
      * @Assert\NotNull
      */
-    protected $snmpVersion;  
-    
+    protected $snmpVersion;
+
     /**
      * @ORM\Column(type="boolean", nullable=true, columnDefinition="BOOLEAN DEFAULT TRUE")
      */
@@ -69,14 +75,14 @@ class CMTS implements DeviceInterface, TenancyIdTraitInterface, SoftDeleteInterf
 
     /**
      * @ORM\Column(type="integer")
-     * 
+     *
      * @Assert\NotNull
      */
     protected $docsVersion;
-    
+
     /**
      * @ORM\ManyToOne(targetEntity="CMTSModel", fetch="EXTRA_LAZY")
-     * 
+     *
      * @JMS\MaxDepth(1)
      */
     protected $model;
@@ -91,7 +97,7 @@ class CMTS implements DeviceInterface, TenancyIdTraitInterface, SoftDeleteInterf
      */
     protected $timeCmtsOctets = 5;
 
-    
+
     /**
      * @return string
      */
@@ -99,7 +105,7 @@ class CMTS implements DeviceInterface, TenancyIdTraitInterface, SoftDeleteInterf
     {
         return (string)$this->name;
     }
-    
+
     /**
      * @return int
      */
@@ -158,84 +164,84 @@ class CMTS implements DeviceInterface, TenancyIdTraitInterface, SoftDeleteInterf
 
     /**
      * @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, 
+        $extraData = [
+            'name' => $this->name,
+            'host' => $this->host,
             'modelId' => $this->model ? $this->model->getId() : null,
             'mark' => null,
             'library' => null,
@@ -251,7 +257,7 @@ class CMTS implements DeviceInterface, TenancyIdTraitInterface, SoftDeleteInterf
             $extraData['mark'] = $this->model->getMark();
             $extraData['library'] = $this->model->getLibrary();
         }
-        
+
         return [
             'deviceType' => get_class($this),
             'deviceId' => $this->id,
@@ -264,7 +270,7 @@ class CMTS implements DeviceInterface, TenancyIdTraitInterface, SoftDeleteInterf
     /**
     * @return array
     */
-    public function getSoftDeleteCriteria() 
+    public function getSoftDeleteCriteria()
     {
         return array('host' => $this->host);
     }
@@ -319,14 +325,14 @@ class CMTS implements DeviceInterface, TenancyIdTraitInterface, SoftDeleteInterf
 
     /**
      * @param int $docsVersion
-     * 
+     *
      * @return $this
      */
     public function setDocsVersion($docsVersion)
     {
         $this->docsVersion = $docsVersion;
-        
+
         return $this;
     }
 
-}
+}

+ 46 - 43
src/CablemodemBundle/Entity/Cablemodem.php

@@ -10,6 +10,7 @@ use Symfony\Component\Validator\Constraints as Assert;
 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 MapBundle\Entity\Interfaces\LocationInterface;
 use MapBundle\Entity\Traits\LocationTrait;
@@ -21,11 +22,13 @@ use Base\AdminBundle\Interfaces\SoftDeleteInterface;
 /**
  * @ORM\Entity
  * @ORM\Table(indexes={@ORM\Index(name="mac", columns={"mac"})})
- * 
+ *
  * @UniqueEntity(fields={"mac"})
- * 
+ *
  * @Gedmo\Loggable
  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true)
+ *
+ * @ValidatorAssert\Device
  */
 class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationInterface, WorkflowInterface, SoftDeleteInterface
 {
@@ -35,7 +38,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     use LocationTrait;
     use WorkflowTrait;
     use SoftDeleteable;
-    
+
     /**
      * @var bigint $id
      *
@@ -44,12 +47,12 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
      * @ORM\GeneratedValue(strategy="IDENTITY")
      */
     protected $id;
-    
+
     /**
      * @var int
      *
      * @ORM\Column(type="integer")
-     * 
+     *
      * @Assert\NotNull
      */
     protected $clientId;
@@ -58,66 +61,66 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
      * @var string $mac
      *
      * @ORM\Column(type="string", length=12, nullable=false, unique=true)
-     * 
+     *
      * @Gedmo\Versioned
-     * 
+     *
      * @Assert\Regex(pattern="/^[a-z0-9]+$/")
      * @Assert\Length(min=12, max=12)
      * @Assert\NotBlank()
      * @Assert\NotNull
      */
     protected $mac;
-        
+
     /**
      * @ORM\Column(type="string", length=100, nullable=true)
-     * 
+     *
      * @Gedmo\Versioned
      */
     protected $activationCode;
 
     /**
      * @ORM\ManyToOne(targetEntity="Node", fetch="EXTRA_LAZY", cascade={"persist"})
-     * 
+     *
      * @JMS\MaxDepth(1)
      */
     protected $node;
 
     /**
      * @ORM\ManyToOne(targetEntity="Profile", fetch="EXTRA_LAZY")
-     * 
+     *
      * @JMS\MaxDepth(1)
      */
     protected $profile;
 
     /**
      * @ORM\ManyToOne(targetEntity="CablemodemModel", fetch="EXTRA_LAZY")
-     * 
+     *
      * @JMS\MaxDepth(1)
      */
     protected $model;
 
     /**
      * @Gedmo\Timestampable(on="create")
-     * 
+     *
      * @ORM\Column(type="datetime")
      */
     protected $created;
 
     /**
      * @Gedmo\Timestampable(on="update")
-     * 
+     *
      * @ORM\Column(type="datetime")
      */
     protected $updated;
-        
+
     /**
      * @ORM\ManyToOne(targetEntity="\WorkflowBundle\Entity\Workflow", fetch="EXTRA_LAZY")
      * @ORM\JoinColumn(name="workflow_id", referencedColumnName="id", onDelete="SET NULL")
-     * 
+     *
      * @JMS\MaxDepth(1)
      */
     protected $workflow;
-    
+
     /**
      * @ORM\Column(type="string", nullable=true)
      */
@@ -132,8 +135,8 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
      * @ORM\Column(type="string", options={"default": "success"})
      */
     protected $transitionState = 'success';
-            
-    
+
+
     /**
      * @return string
      */
@@ -141,7 +144,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     {
         return (string) ($this->mac ?: $this->activationCode);
     }
-       
+
     /**
      * @return int
      */
@@ -216,114 +219,114 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
 
     /**
      * @param int $clientId
-     * 
+     *
      * @return $this
      */
     public function setClientId($clientId)
     {
         $this->clientId = $clientId;
-        
+
         return $this;
     }
 
     /**
      * @param string $mac
-     * 
+     *
      * @return $this
      */
     public function setMac($mac)
     {
         $this->mac = $mac;
-        
+
         return $this;
     }
-    
+
     /**
      * @param string $activationCode
-     * 
+     *
      * @return $this
      */
     public function setActivationCode($activationCode)
     {
         $this->activationCode = $activationCode;
-        
+
         return $this;
     }
 
     /**
      * @param Node $node
-     * 
+     *
      * @return $this
      */
     public function setNode($node)
     {
         $this->node = $node;
-        
+
         return $this;
     }
 
     /**
      * @param Profile $profile
-     * 
+     *
      * @return $this
      */
     public function setProfile($profile)
     {
         $this->profile = $profile;
-        
+
         return $this;
     }
 
     /**
      * @param CablemodemModel $model
-     * 
+     *
      * @return $this
      */
     public function setModel($model)
     {
         $this->model = $model;
-        
+
         return $this;
     }
 
     /**
      * @param \DateTime $created
-     * 
+     *
      * @return $this
      */
     public function setCreated($created)
     {
         $this->created = $created;
-        
+
         return $this;
     }
 
     /**
      * @param \DateTime $updated
-     * 
+     *
      * @return $this
      */
     public function setUpdated($updated)
     {
         $this->updated = $updated;
-        
+
         return $this;
     }
-    
+
     /**
      * @return array
      */
     public function getDeviceData()
     {
-        $extraData = [            
-            'mac' => $this->mac, 
-            'activationCode' => $this->activationCode, 
+        $extraData = [
+            'mac' => $this->mac,
+            'activationCode' => $this->activationCode,
             'clientId' => $this->clientId,
             'modelId' => $this->model ? $this->model->getId() : null,
             'nodeId' => $this->node ? $this->node->getId() : null,
             'profileId' => $this->profile ? $this->profile->getId() : null,
         ];
-        
+
         return [
             'deviceType' => get_class($this),
             'deviceId' => $this->id,
@@ -335,7 +338,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     /**
      * @return array
      */
-    public function getSoftDeleteCriteria() 
+    public function getSoftDeleteCriteria()
     {
         return array('mac' => $this->mac);
     }