Luciano Andrade пре 7 година
родитељ
комит
8425e4b88b

+ 2 - 2
composer.json

@@ -206,9 +206,9 @@
             "@symfony-scripts",
             "@mkdir-dir-cache-sessions-logs",
             "@chmod-dir-cache-sessions-logs",
+            "@doctrine-migrations",
             "@doctrine-update",
-            "@auto-increment",
-            "@doctrine-migrations"
+            "@auto-increment"
         ],
         "post-update-cmd": [
             "@workflows-commands",

+ 5 - 1
src/FTTHBundle/Admin/ONUAdmin.php

@@ -89,12 +89,16 @@ class ONUAdmin extends WorkflowBaseAdmin
                     ->add('mac')
                     ->add('olt')
                     ->add('position')
-	                ->add('service_port',CollectionType::class, array(
+	            ->add('service_port',CollectionType::class, array(
 		            	'entry_type' => "FTTHBundle\\Form\\ServicePortType",
 		            	'allow_add' => true,
 		            	'allow_delete' => true,
 		            	'required' => false,
 		            ))
+
+                    ->add('vlan')
+                    ->add('traffic_profile')
+                    ->add('tcontprofile')
                 ->end()
             ->end()
             ->setHelps(array(

+ 10 - 0
src/FTTHBundle/Admin/TContProfileAdmin.php

@@ -31,6 +31,14 @@ class TContProfileAdmin extends BaseAdmin
         $listMapper
             ->add('name')
             ->add('value')
+            ->add('used_by_default')
+            ->add('_action', null, array(
+                'actions' => array(
+                    'show' => array(),
+                    'edit' => array(),
+                    'delete' => array(),
+                )))
+  
         ;
     }
 
@@ -42,6 +50,7 @@ class TContProfileAdmin extends BaseAdmin
         $formMapper
             ->add('name')
             ->add('value')
+            ->add('used_by_default')
         ;
     }
 
@@ -53,6 +62,7 @@ class TContProfileAdmin extends BaseAdmin
         $showMapper
             ->add('name')
             ->add('value')
+            ->add('used_by_default')
         ;
     }
 

+ 10 - 1
src/FTTHBundle/Admin/TrafficProfileAdmin.php

@@ -31,7 +31,14 @@ class TrafficProfileAdmin extends BaseAdmin
         $listMapper
             ->add('name')
             ->add('value')
-        ;
+            ->add('used_by_default')
+            ->add('_action', null, array(
+                'actions' => array(
+                    'show' => array(),
+                    'edit' => array(),
+                    'delete' => array(),
+                )))
+         ;
     }
 
     /**
@@ -42,6 +49,7 @@ class TrafficProfileAdmin extends BaseAdmin
         $formMapper
             ->add('name')
             ->add('value')
+            ->add('used_by_default')
         ;
     }
 
@@ -53,6 +61,7 @@ class TrafficProfileAdmin extends BaseAdmin
         $showMapper
             ->add('name')
             ->add('value')
+            ->add('used_by_default')
         ;
     }
 

+ 9 - 0
src/FTTHBundle/Admin/VLanIDAdmin.php

@@ -31,6 +31,13 @@ class VLanIDAdmin extends BaseAdmin
         $listMapper
             ->add('name')
             ->add('value')
+            ->add('used_by_default')
+            ->add('_action', null, array(
+                'actions' => array(
+                    'show' => array(),
+                    'edit' => array(),
+                    'delete' => array(),
+                )))
         ;
     }
 
@@ -42,6 +49,7 @@ class VLanIDAdmin extends BaseAdmin
         $formMapper
             ->add('name')
             ->add('value')
+            ->add('used_by_default')
         ;
     }
 
@@ -53,6 +61,7 @@ class VLanIDAdmin extends BaseAdmin
         $showMapper
             ->add('name')
             ->add('value')
+            ->add('used_by_default')
         ;
     }
 

+ 31 - 0
src/FTTHBundle/Entity/NAP.php

@@ -355,4 +355,35 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
             $this->setExtraData(json_encode($json));
         }
     }
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        $this->onus = new \Doctrine\Common\Collections\ArrayCollection();
+    }
+
+    /**
+     * Add onus
+     *
+     * @param \FTTHBundle\Entity\ONU $onus
+     *
+     * @return NAP
+     */
+    public function addOnus(\FTTHBundle\Entity\ONU $onus)
+    {
+        $this->onus[] = $onus;
+
+        return $this;
+    }
+
+    /**
+     * Remove onus
+     *
+     * @param \FTTHBundle\Entity\ONU $onus
+     */
+    public function removeOnus(\FTTHBundle\Entity\ONU $onus)
+    {
+        $this->onus->removeElement($onus);
+    }
 }

+ 46 - 0
src/FTTHBundle/Entity/OLT.php

@@ -559,4 +559,50 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
         return $entities;
     }
 
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        $this->onus = new \Doctrine\Common\Collections\ArrayCollection();
+        $this->naps = new \Doctrine\Common\Collections\ArrayCollection();
+    }
+
+    /**
+     * Set libraryVersion
+     *
+     * @param string $libraryVersion
+     *
+     * @return OLT
+     */
+    public function setLibraryVersion($libraryVersion)
+    {
+        $this->libraryVersion = $libraryVersion;
+
+        return $this;
+    }
+
+    /**
+     * Add onus
+     *
+     * @param \FTTHBundle\Entity\ONU $onus
+     *
+     * @return OLT
+     */
+    public function addOnus(\FTTHBundle\Entity\ONU $onus)
+    {
+        $this->onus[] = $onus;
+
+        return $this;
+    }
+
+    /**
+     * Remove onus
+     *
+     * @param \FTTHBundle\Entity\ONU $onus
+     */
+    public function removeOnus(\FTTHBundle\Entity\ONU $onus)
+    {
+        $this->onus->removeElement($onus);
+    }
 }

+ 8 - 0
src/FTTHBundle/Entity/OLTModel.php

@@ -188,4 +188,12 @@ class OLTModel implements TenancyIdTraitInterface
     {
         return $this->library;
     }
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        $this->olts = new \Doctrine\Common\Collections\ArrayCollection();
+    }
+
 }

+ 94 - 0
src/FTTHBundle/Entity/ONU.php

@@ -171,6 +171,28 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
      */
     protected $service_port;
 
+    /**
+     * @ORM\ManyToOne(targetEntity="TContProfile", inversedBy="onus", fetch="EXTRA_LAZY")
+     * @ORM\JoinColumn(name="tcontprofile_id", referencedColumnName="id")
+     * @JMS\MaxDepth(1)
+     */
+    protected $tcontprofile;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="TrafficProfile", inversedBy="onus", fetch="EXTRA_LAZY")
+     * @ORM\JoinColumn(name="traffic_profile_id", referencedColumnName="id")
+     * @JMS\MaxDepth(1)
+     */
+    protected $traffic_profile;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="VLanID", inversedBy="onus", fetch="EXTRA_LAZY")
+     * @ORM\JoinColumn(name="vlan_id", referencedColumnName="id")
+     * @JMS\MaxDepth(1)
+     */
+    protected $vlan;
+
+
     /**
      * Constructor
      */
@@ -672,4 +694,76 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
         $this->service_port = $service_port;
 	return $this;
     }
+
+    /**
+     * Set tcontprofile
+     *
+     * @param \FTTHBundle\Entity\TContProfile $tcontprofile
+     *
+     * @return ONU
+     */
+    public function setTcontprofile(\FTTHBundle\Entity\TContProfile $tcontprofile = null)
+    {
+        $this->tcontprofile = $tcontprofile;
+
+        return $this;
+    }
+
+    /**
+     * Get tcontprofile
+     *
+     * @return \FTTHBundle\Entity\TContProfile
+     */
+    public function getTcontprofile()
+    {
+        return $this->tcontprofile;
+    }
+
+    /**
+     * Set trafficProfile
+     *
+     * @param \FTTHBundle\Entity\TrafficProfile $trafficProfile
+     *
+     * @return ONU
+     */
+    public function setTrafficProfile(\FTTHBundle\Entity\TrafficProfile $trafficProfile = null)
+    {
+        $this->traffic_profile = $trafficProfile;
+
+        return $this;
+    }
+
+    /**
+     * Get trafficProfile
+     *
+     * @return \FTTHBundle\Entity\TrafficProfile
+     */
+    public function getTrafficProfile()
+    {
+        return $this->traffic_profile;
+    }
+
+    /**
+     * Set vlan
+     *
+     * @param \FTTHBundle\Entity\VLanID $vlan
+     *
+     * @return ONU
+     */
+    public function setVlan(\FTTHBundle\Entity\VLanID $vlan = null)
+    {
+        $this->vlan = $vlan;
+
+        return $this;
+    }
+
+    /**
+     * Get vlan
+     *
+     * @return \FTTHBundle\Entity\VLanID
+     */
+    public function getVlan()
+    {
+        return $this->vlan;
+    }
 }

+ 31 - 1
src/FTTHBundle/Entity/ONUModel.php

@@ -83,5 +83,35 @@ class ONUModel implements TenancyIdTraitInterface
         return $this->name;
     }
 
-}
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        $this->onus = new \Doctrine\Common\Collections\ArrayCollection();
+    }
 
+    /**
+     * Add onus
+     *
+     * @param \FTTHBundle\Entity\ONU $onus
+     *
+     * @return ONUModel
+     */
+    public function addOnus(\FTTHBundle\Entity\ONU $onus)
+    {
+        $this->onus[] = $onus;
+
+        return $this;
+    }
+
+    /**
+     * Remove onus
+     *
+     * @param \FTTHBundle\Entity\ONU $onus
+     */
+    public function removeOnus(\FTTHBundle\Entity\ONU $onus)
+    {
+        $this->onus->removeElement($onus);
+    }
+}

+ 31 - 0
src/FTTHBundle/Entity/Profile.php

@@ -151,4 +151,35 @@ class Profile implements TenancyIdTraitInterface
     function getUploadAsK()  {return round($this->getUpload()/1000,2)."k"; }
 
     function getRadiusName()  {return preg_replace("|[^A-Za-z0-9]|", "-", $this->name); }
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        $this->onus = new \Doctrine\Common\Collections\ArrayCollection();
+    }
+
+    /**
+     * Add onus
+     *
+     * @param \FTTHBundle\Entity\ONU $onus
+     *
+     * @return Profile
+     */
+    public function addOnus(\FTTHBundle\Entity\ONU $onus)
+    {
+        $this->onus[] = $onus;
+
+        return $this;
+    }
+
+    /**
+     * Remove onus
+     *
+     * @param \FTTHBundle\Entity\ONU $onus
+     */
+    public function removeOnus(\FTTHBundle\Entity\ONU $onus)
+    {
+        $this->onus->removeElement($onus);
+    }
 }

+ 38 - 4
src/FTTHBundle/Entity/TContProfile.php

@@ -17,8 +17,10 @@ use Symfony\Component\Validator\Constraints as Assert;
  * @ORM\Entity
  * @HasLifecycleCallbacks
  */
-class TContProfile
-{
+class TContProfile implements UseOneDefaultInterface, TenancyIdTraitInterface {
+    use ONUTrait;
+    use TenancyIdTrait;
+
     /**
      * @var int
      *
@@ -46,13 +48,19 @@ class TContProfile
      */
     private $value;
 
-
+    /**
+     * @var boolean
+     *
+     * @ORM\Column(type="boolean")
+     *
+     */
+    private $used_by_default;
 
     /**
      * Get id
      *
      * @return integer
-     */
+
     public function getId()
     {
         return $this->id;
@@ -105,4 +113,30 @@ class TContProfile
     {
         return $this->value;
     }
+
+    function __toString() { return $this->name; }
+
+    /**
+     * Set usedByDefaul
+     *
+     * @param boolean $usedByDefaul
+     *
+     * @return TContProfile
+     */
+    public function setUsedByDefault($usedByDefault)
+    {
+        $this->used_by_default = $usedByDefault;
+
+        return $this;
+    }
+
+    /**
+     * Get usedByDefaul
+     *
+     * @return boolean
+     */
+    public function getUsedByDefault()
+    {
+        return $this->used_by_default;
+    }
 }

+ 37 - 2
src/FTTHBundle/Entity/TrafficProfile.php

@@ -17,8 +17,10 @@ use Symfony\Component\Validator\Constraints as Assert;
  * @ORM\Entity
  * @HasLifecycleCallbacks
  */
-class TrafficProfile 
-{
+class TrafficProfile implements TenancyIdTraitInterface {
+    use ONUTrait;
+    use TenancyIdTrait;
+
     /**
      * @var int
      *
@@ -46,6 +48,13 @@ class TrafficProfile
      */
     private $value;
 
+    /**
+     * @var boolean
+     *
+     * @ORM\Column(type="boolean")
+     *
+     */
+    private $used_by_default;
 
 
     /**
@@ -105,4 +114,30 @@ class TrafficProfile
     {
         return $this->value;
     }
+
+    function __toString() { return $this->name; }
+
+    /**
+     * Set usedByDefaul
+     *
+     * @param boolean $usedByDefaul
+     *
+     * @return TrafficProfile
+     */
+    public function setUsedByDefault($usedByDefault)
+    {
+        $this->used_by_default = $usedByDefault;
+
+        return $this;
+    }
+
+    /**
+     * Get usedByDefaul
+     *
+     * @return boolean
+     */
+    public function getUsedByDefault()
+    {
+        return $this->used_by_default;
+    }
 }

+ 6 - 0
src/FTTHBundle/Entity/UseOneDefaultInterface.php

@@ -0,0 +1,6 @@
+<?php
+
+namespace FTTHBundle\Entity;
+
+interface UseOneDefaultInterface {
+}

+ 37 - 2
src/FTTHBundle/Entity/VLanID.php

@@ -17,8 +17,11 @@ use Symfony\Component\Validator\Constraints as Assert;
  * @ORM\Entity
  * @HasLifecycleCallbacks
  */
-class VLanID 
+class VLanID implements TenancyIdTraitInterface
 {
+    use ONUTrait;
+    use TenancyIdTrait;
+
     /**
      * @var int
      *
@@ -46,7 +49,13 @@ class VLanID
      */
     private $value;
 
-
+    /**
+     * @var boolean
+     *
+     * @ORM\Column(type="boolean")
+     *
+     */
+    private $used_by_default;
 
 
     /**
@@ -106,4 +115,30 @@ class VLanID
     {
         return $this->value;
     }
+
+    function __toString() { return $this->name; }
+
+    /**
+     * Set usedByDefaul
+     *
+     * @param boolean $usedByDefaul
+     *
+     * @return VLanID
+     */
+    public function setUsedByDefault($usedByDefault)
+    {
+        $this->used_by_default = $usedByDefault;
+
+        return $this;
+    }
+
+    /**
+     * Get usedByDefaul
+     *
+     * @return boolean
+     */
+    public function getUsedByDefault()
+    {
+        return $this->used_by_default;
+    }
 }

+ 21 - 1
src/FTTHBundle/EventListener/ONUSubscriber.php

@@ -58,6 +58,12 @@ class ONUSubscriber implements EventSubscriber
     public function prePersist(LifecycleEventArgs $args)
     {
         $this->execute($args, DoctrineEvents::PRE_PERSIST);
+
+        if ($entity instanceof ONU) {
+		$this->assignTrafficProfile($args, DoctrineEvents::PRE_PERSIST)
+		$this->assignTConProfile($args, DoctrineEvents::PRE_PERSIST)
+		$this->assignVLanId($args, DoctrineEvents::PRE_PERSIST)
+	}
     }
 
     /**
@@ -67,7 +73,6 @@ class ONUSubscriber implements EventSubscriber
     {
 	$entity = $args->getEntity();
         if ($entity instanceof ONU) {
-
                 $this->em = $args->getEntityManager();
  		$this->setSerivcePorts($entity);
 	}
@@ -81,6 +86,21 @@ class ONUSubscriber implements EventSubscriber
     public function preUpdate(LifecycleEventArgs $args)
     {
         $this->execute($args, DoctrineEvents::PRE_UPDATE);
+
+        if ($entity instanceof ONU) {
+		$this->assignTrafficProfile($args, DoctrineEvents::PRE_UPDATE)
+		$this->assignTConProfile($args, DoctrineEvents::PRE_UPDATE)
+		$this->assignVLanId($args, DoctrineEvents::PRE_UPDATE)
+	}
+    }
+
+    public function assignTrafficProfile(LifecycleEventArgs $args, $eventName = DoctrineEvents::PRE_PERSIST)
+    }
+
+    public function assignTConProfile(LifecycleEventArgs $args, $eventName = DoctrineEvents::PRE_PERSIST)
+    }
+
+    public function assignVLanId(LifecycleEventArgs $args, $eventName = DoctrineEvents::PRE_PERSIST)
     }
 
     /**

+ 65 - 0
src/FTTHBundle/EventListener/UseOneDefaultListener.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace FTTHBundle\EventListener;
+
+use Doctrine\Common\EventSubscriber;
+use Doctrine\ORM\Event\LifecycleEventArgs;
+use FTTHBundle\Entity\UseOneDefaultInterface;
+use Base\AdminBundle\Traits\TenancyIdTraitInterface;
+
+class UseOneDefaultListener implements EventSubscriber
+{
+
+    /**
+     * @return array
+     */
+    public function getSubscribedEvents()
+    {
+        return array(
+            'prePersist',
+            'preUpdate',
+        );
+    }
+
+    /**
+     * @param LifecycleEventArgs $args
+     */
+    public function prePersist(LifecycleEventArgs $args)
+    {
+        $this->execute($args);
+    }
+
+    /**
+     * @param LifecycleEventArgs $args
+     */
+    public function preUpdate(LifecycleEventArgs $args)
+    {
+        $this->execute($args, 'preUpdate');
+    }
+
+    /**
+     * @param LifecycleEventArgs $args
+     * @param string $eventName
+     */
+    public function execute(LifecycleEventArgs $args, $eventName = 'prePersist')
+    {
+        $entity = $args->getEntity();
+	$impl = class_implements($entity);
+        if ($entity instanceof UseOneDefaultInterface){
+
+		if((bool)$entity->getUsedByDefault()){
+			$dql = "UPDATE ". get_class($entity) . " u SET u.used_by_default = 0";	
+			$query = $args->getEntityManager()->createQuery($dql);
+			$query->execute();
+		}else{
+			$dql = "SELECT count(u) as c FROM ". get_class($entity) . " u WHERE u.used_by_default = 1";	
+			$query = $args->getEntityManager()->createQuery($dql);
+			$rtr = $query->getSingleScalarResult();
+			if($rtr == 0){
+				$entity->setUsedByDefault(true);
+			}
+		}
+	}
+    }
+
+}

+ 5 - 0
src/FTTHBundle/Resources/config/services.yml

@@ -96,4 +96,9 @@ services:
         calls:
             - [setTranslationDomain, [FTTHBundle]]
 
+    ftth.default.subscriber:
+        class: FTTHBundle\EventListener\UseOneDefaultListener
+        tags:
+            - { name: doctrine.event_subscriber, connection: default }
+
 

+ 16 - 1
src/FTTHBundle/Resources/translations/FTTHBundle.es.yml

@@ -49,6 +49,9 @@ filter:
     label_capacity: Capacidad
 
 breadcrumb:
+    link_t_cont_profile_list: Listado Perfiles tcon
+    link_traffic_profile_list : Listado Perfiles de Tráfico
+    link_v_lan_i_d_list: Listado VLan IDs
     link_o_n_u_list: Listado ONU
     link_o_n_u_create: Crear ONU
     link_o_n_u_delete: Eliminar ONU
@@ -127,6 +130,10 @@ form:
     label_tr069_status: Enable SSID
     label_capacity: Capacidad
     label_value: Valor
+    label_vlan: VLAN ID
+    label_traffic_profile: Perfil de Tráfico
+    label_tcontprofile: Perfil tcont
+    label_used_by_default: Default
 
 list:
     label_id: Id
@@ -171,6 +178,8 @@ list:
     label_service_port: Service Port
     label_position: Posición
     label_capacity: Capacidad
+    label_value: Valor
+    label_used_by_default: Default
 
 show:
     label_id: Id
@@ -224,6 +233,8 @@ show:
     label_tr069_broadcast: Broadcast SSID
     label_tr069_status: Enable SSID
     label_capacity: Capacidad
+    label_value: Valor
+    abel_used_by_default: Default
     
 helps:
     check_address: Verifique la dirección para el cálculo de distancias.
@@ -263,4 +274,8 @@ onu_distance_nap_not_configurated: Requiere configuración de distancia
 nap_not_positioned: NAP no posicionada
 unique_field_ponserialnumber: Existe una ONU creada con el identificador %ponSerialNumber%
 
-tcontprofile: Perfil tCont
+tcontprofile: Perfil tcont
+vlan_id: VLan ID
+traffic_profile : Perfil de Tráfico
+
+

+ 6 - 0
src/FTTHBundle/Resources/translations/messages.es.yml

@@ -2,3 +2,9 @@ form.service_port.type:  Tipo de servicio, a modo de referencia
 form.service_port.number:  Número de puerto de servicio
 form.service_port.vlan: VLAN
 form.service_port.gemport: gemport
+
+tcontprofile: Perfil tcont
+vlan_id: VLan ID
+traffic_profile : Perfil de Tráfico
+
+