|
@@ -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);
|
|
|
}
|