Browse Source

Merged in FD3-505 (pull request #72)

FD3-505

Approved-by: Guillermo Espinoza <guillermo@interlink.com.ar>
Approved-by: Maximiliano Schvindt <maximiliano@interlink.com.ar>
Gabriel Gosparo 7 years ago
parent
commit
4ab4629894

+ 36 - 0
app/DoctrineMigrations/Version20180321184546.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+use MigrationsBundle\Migrations\MigrationsBase;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+class Version20180321184546 extends MigrationsBase
+{
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        // this up() migration is auto-generated, please modify it to your needs
+        if (!$this->existFieldInTable("nap", "capacity")) {
+            $this->addSql("ALTER TABLE nap ADD capacity INT NOT NULL;");
+        }
+        if (!$this->existFieldInTable("nap_audit", "capacity")) {
+            $this->addSql("ALTER TABLE nap_audit ADD capacity INT DEFAULT NULL;");
+        }
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+
+    }
+}

+ 10 - 17
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "565dd89e0b7c3c9a029906b040ae0214",
+    "content-hash": "fcbd13ca73fa10dbb3b83febccc2f3f2",
     "packages": [
         {
             "name": "behat/gherkin",
@@ -260,16 +260,16 @@
         },
         {
             "name": "codeception/phpunit-wrapper",
-            "version": "6.0.8",
+            "version": "6.0.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/Codeception/phpunit-wrapper.git",
-                "reference": "e18f3ea1f841bfd2cecaf6e183e584127b9d467b"
+                "reference": "412645f52bf67bb2b8e2282e3fe71e526e7af7e9"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/e18f3ea1f841bfd2cecaf6e183e584127b9d467b",
-                "reference": "e18f3ea1f841bfd2cecaf6e183e584127b9d467b",
+                "url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/412645f52bf67bb2b8e2282e3fe71e526e7af7e9",
+                "reference": "412645f52bf67bb2b8e2282e3fe71e526e7af7e9",
                 "shasum": ""
             },
             "require": {
@@ -278,13 +278,6 @@
                 "sebastian/comparator": ">1.1 <3.0",
                 "sebastian/diff": ">=1.4 <4.0"
             },
-            "replace": {
-                "codeception/phpunit-wrapper": "*"
-            },
-            "require-dev": {
-                "codeception/specify": "*",
-                "vlucas/phpdotenv": "^2.4"
-            },
             "type": "library",
             "autoload": {
                 "psr-4": {
@@ -302,7 +295,7 @@
                 }
             ],
             "description": "PHPUnit classes used by Codeception",
-            "time": "2018-03-16T10:17:47+00:00"
+            "time": "2018-02-18T20:05:08+00:00"
         },
         {
             "name": "codeception/stub",
@@ -2003,11 +1996,11 @@
         },
         {
             "name": "ik/extra-data-bundle",
-            "version": "dev-master",
+            "version": "dev-FD3-505",
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/ExtraDataBundle.git",
-                "reference": "06741a4abbe823cc750f3b1d746745a1ab934a60"
+                "reference": "3edde915ed7f3a02a10640913c3a33bda72aaa2b"
             },
             "type": "library",
             "autoload": {
@@ -2022,7 +2015,7 @@
                 "bundle",
                 "extra-data"
             ],
-            "time": "2018-03-15T12:49:20+00:00"
+            "time": "2018-03-22T18:09:25+00:00"
         },
         {
             "name": "ik/leaflet-bundle",
@@ -6753,7 +6746,7 @@
         "voryx/restgeneratorbundle": 20
     },
     "prefer-stable": false,
-    "prefer-lowest": false,
+    "prefer-lowest": true,
     "platform": {
         "php": ">=5.5.9"
     },

+ 30 - 20
src/FTTHBundle/Admin/NAPAdmin.php

@@ -23,7 +23,7 @@ class NAPAdmin extends BaseAdmin
             ->add('slot')
             ->add('link')
             ->add('address')
-                ;
+            ->add('capacity');
     }
 
     /**
@@ -38,6 +38,7 @@ class NAPAdmin extends BaseAdmin
             ->add('slot')
             ->add('link')
             ->add('address')
+            ->add('capacity')
             ->add('onus')
             ->add('extraData')
             ->add('_action', null, array(
@@ -55,24 +56,24 @@ class NAPAdmin extends BaseAdmin
     protected function configureFormFields(FormMapper $formMapper)
     {
         $formMapper
-        ->tab('default')
-        ->with('')
-        ->add('name')
-        ->add('parent')
-        ->add('olt')
-        ->add('slot')
-        ->add('link')
-        ->add('address', 'text', [
-            'required' => false,
-        ])
-        ->end()
-        ->end()
-        ->tab('Avanzado')
-        ->with('Config')
-        ->add('extraData')
-        ->end()
-        ->end()
-            ;
+            ->tab('default')
+            ->with('')
+            ->add('name')
+            ->add('parent')
+            ->add('olt')
+            ->add('slot')
+            ->add('capacity')
+            ->add('link')
+            ->add('address', 'text', [
+                'required' => false,
+            ])
+            ->end()
+            ->end()
+            ->tab('Avanzado')
+            ->with('Config')
+            ->add('extraData')
+            ->end()
+            ->end();
     }
 
     /**
@@ -81,14 +82,23 @@ class NAPAdmin extends BaseAdmin
     protected function configureShowFields(ShowMapper $showMapper)
     {
         $showMapper
+            ->tab('default')
+            ->with('')
             ->add('name')
             ->add('parent')
             ->add('olt')
             ->add('slot')
+            ->add('capacity')
             ->add('link')
             ->add('address')
             ->add('onus')
-            ->add('extraData');
+            ->end()
+            ->end()
+            ->tab('Avanzado')
+            ->with('Config')
+            ->add('extraData')
+            ->end()
+            ->end();
     }
 
 }

+ 81 - 26
src/FTTHBundle/Entity/NAP.php

@@ -4,7 +4,9 @@ namespace FTTHBundle\Entity;
 
 use Base\AdminBundle\Traits\TenancyIdTrait;
 use Base\AdminBundle\Traits\TenancyIdTraitInterface;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
 use Doctrine\ORM\Mapping as ORM;
+use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
 use ExtraDataBundle\Entity\Traits\ExtraDataWithParentTrait;
 use JMS\Serializer\Annotation as JMS;
 use MapBundle\Entity\Interfaces\LocationInterface;
@@ -15,6 +17,7 @@ use Symfony\Component\Validator\Constraints as Assert;
 /**
  * @ORM\Table
  * @ORM\Entity
+ * @HasLifecycleCallbacks
  */
 class NAP implements TenancyIdTraitInterface, LocationInterface
 {
@@ -96,7 +99,12 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
      * @ORM\Column(type="string", length=255, nullable=true)
      */
     protected $address;
-
+    /**
+     * @var int
+     *
+     * @ORM\Column(type="integer")
+     */
+    protected $capacity;
 
     /**
      * @return string
@@ -196,9 +204,31 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
      */
     public function getCapacity()
     {
-        return $this->getData('capacity') ? $this->getData('capacity') : self::MAX_NUMBER_ONU;
+
+        if ($this->capacity) {
+            $capacity = $this->capacity;
+        } else {
+            if ($this->getData('capacity')) {
+                $capacity = $this->getData('capacity');
+            } else {
+                $capacity = self::MAX_NUMBER_ONU;
+            }
+        }
+        $this->setCapacity($capacity);
+        return $capacity;
     }
 
+    /**
+     * @param int $capacity
+     * @return NAP
+     */
+    public function setCapacity($capacity)
+    {
+        $this->capacity = $capacity;
+        return $this;
+    }
+
+
     /**
      * @return OLT
      */
@@ -258,41 +288,43 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
         return $this;
     }
 
-    public function getlat(){
-	   // if($this->location->lat) return $this->location->lat;
-	if($l = $this->getLocation()){
-		$le = $l->jsonExtraData();
-		if(isset($le["lat"])){
-			return $le["lat"];
-		}
-	}
-	return $this->lat;
+    public function getlat()
+    {
+        // if($this->location->lat) return $this->location->lat;
+        if ($l = $this->getLocation()) {
+            $le = $l->jsonExtraData();
+            if (isset($le["lat"])) {
+                return $le["lat"];
+            }
+        }
+        return $this->lat;
     }
 
-    public function getlng(){
-	    //if($this->location->lng) return $this->location->lng;
-	    if($l = $this->getLocation()){
-		    $le = $l->jsonExtraData();
-		    if(isset($le["lng"])){
-			    return $le["lng"];
-		    }
-	    }
-	    return $this->lng;
+    public function getlng()
+    {
+        //if($this->location->lng) return $this->location->lng;
+        if ($l = $this->getLocation()) {
+            $le = $l->jsonExtraData();
+            if (isset($le["lng"])) {
+                return $le["lng"];
+            }
+        }
+        return $this->lng;
     }
 
     /**
-    * @return string
-    */
+     * @return string
+     */
     public function getAddress()
     {
         return $this->address;
     }
 
     /**
-    * @param string $address
-    *
-    * @return Nap
-    */
+     * @param string $address
+     *
+     * @return Nap
+     */
     public function setAddress($address)
     {
         $this->address = $address;
@@ -300,4 +332,27 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
         return $this;
     }
 
+    /**
+     * @ORM\PrePersist()
+     */
+    public function prePersist()
+    {
+        if ($this->capacity) {
+            $json = json_decode($this->getExtraData(), true);
+            $json['capacity'] = $this->getCapacity();
+            $this->setExtraData(json_encode($json));
+        }
+    }
+
+    /**
+     * @ORM\PreUpdate()
+     */
+    public function preUpdate()
+    {
+        if ($this->capacity) {
+            $json = json_decode($this->getExtraData(), true);
+            $json['capacity'] = $this->getCapacity();
+            $this->setExtraData(json_encode($json));
+        }
+    }
 }

+ 1 - 0
src/FTTHBundle/Form/NAPType.php

@@ -19,6 +19,7 @@ class NAPType extends AbstractType
             ->add('olt')
             ->add('extraData')
             ->add('tenancyId')
+            ->add('capacity')
         ;
     }
 

+ 5 - 2
src/FTTHBundle/Resources/translations/FTTHBundle.es.yml

@@ -46,7 +46,8 @@ filter:
     label_slot: Slot
     label_link: Link
     label_address: Dirección
-    
+    label_capacity: Capacidad
+
 breadcrumb:
     link_o_n_u_list: Listado ONU
     link_o_n_u_create: Crear ONU
@@ -107,7 +108,6 @@ form:
     label_time_onu_stats: Estadísticas de ONUs
     label_time_olt_octets: Tráfico de OLT
     label_map: Mapa
-    label_client: Cliente
     label_slot: Slot
     label_link: Link
     label_enable: Enable
@@ -125,6 +125,7 @@ form:
     label_tr069_ip: IP
     label_tr069_broadcast: Broadcast SSID
     label_tr069_status: Enable SSID
+    label_capacity: Capacidad
 
 list:
     label_id: Id
@@ -168,6 +169,7 @@ list:
     label_address: Dirección
     label_service_port: Service Port
     label_position: Posición
+    label_capacity: Capacidad
 
 show:
     label_id: Id
@@ -220,6 +222,7 @@ show:
     label_tr069_ip: IP
     label_tr069_broadcast: Broadcast SSID
     label_tr069_status: Enable SSID
+    label_capacity: Capacidad
     
 helps:
     check_address: Verifique la dirección para el cálculo de distancias.

+ 1 - 0
src/FTTHBundle/tests/ONURESTControllerTest.php

@@ -109,6 +109,7 @@ class ONURESTControllerTest extends WebTestCaseBase
         $datos['olt'] = 1;
         $datos['name'] = 'NAP';
         $datos['tenancyId'] = 1;
+        $datos['capacity'] = 8;
 
         if ($key == null) {
             return $datos;