Selaa lähdekoodia

Merged in FD3-744 (pull request #116)

FD3-744

Approved-by: Maximiliano Schvindt <maximiliano@interlink.com.ar>
Guillermo Espinoza 6 vuotta sitten
vanhempi
commit
5b13b60142

+ 2 - 2
app/DoctrineMigrations/Version20180221174411.php

@@ -21,7 +21,7 @@ class Version20180221174411 extends MigrationsBase
 
 
     if (!$schema->hasTable('service_port') == true) {
-        $this->addSql('CREATE TABLE service_port (id INT AUTO_INCREMENT NOT NULL, olt_id BIGINT DEFAULT NULL, onu_id INT DEFAULT NULL, number INT DEFAULT 0 NOT NULL, gemport INT DEFAULT 0 NOT NULL, vlan INT DEFAULT 0 NOT NULL, type VARCHAR(255) NOT NULL, INDEX IDX_8DD2E92069FFAD89 (olt_id), INDEX IDX_8DD2E920AB83998C (onu_id), UNIQUE INDEX sp_unique (olt_id, number), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+        $this->addSql('CREATE TABLE service_port (id INT AUTO_INCREMENT NOT NULL, olt_id BIGINT DEFAULT NULL, onu_id INT DEFAULT NULL, number INT DEFAULT 0 NOT NULL, gemport INT DEFAULT 0 NOT NULL, vlan INT DEFAULT 0 NOT NULL, INDEX IDX_8DD2E92069FFAD89 (olt_id), INDEX IDX_8DD2E920AB83998C (onu_id), UNIQUE INDEX sp_unique (olt_id, number), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
         $this->addSql('ALTER TABLE service_port ADD CONSTRAINT FK_8DD2E92069FFAD89 FOREIGN KEY (olt_id) REFERENCES olt (id)');
         $this->addSql('ALTER TABLE service_port ADD CONSTRAINT FK_8DD2E920AB83998C FOREIGN KEY (onu_id) REFERENCES onu (id)');
         $this->addSql('ALTER TABLE olt CHANGE execute_snmp execute_snmp BOOLEAN DEFAULT TRUE');
@@ -50,7 +50,7 @@ class Version20180221174411 extends MigrationsBase
         foreach($service_port as $type => $number){
             $gemport = $vlangemport_config[$type]['gemport'];
             $vlan = $vlangemport_config[$type]['vlan'];
-            $sql = "REPLACE INTO service_port (olt_id, onu_id, number, type, gemport, vlan) VALUES ($olt_id, $onu_id, $number, '$type', $gemport, $vlan);";
+            $sql = "REPLACE INTO service_port (olt_id, onu_id, number, gemport, vlan) VALUES ($olt_id, $onu_id, $number, $gemport, $vlan);";
             $this->addSql($sql);
         }
     }

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 16 - 2
app/DoctrineMigrations/src/action.yml


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 40 - 35
app/DoctrineMigrations/src/template.yml


+ 2 - 2
composer.lock

@@ -2200,7 +2200,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/WorkflowBundle.git",
-                "reference": "13431443af6cd4038230a15e05f593363a642ad1"
+                "reference": "8919bf2fec49fa73cd31b07a83a542bbd0767136"
             },
             "require": {
                 "php-amqplib/rabbitmq-bundle": "^1.12"
@@ -2230,7 +2230,7 @@
                 "bundle",
                 "workflow"
             ],
-            "time": "2018-11-22T18:10:58+00:00"
+            "time": "2018-11-23T13:16:02+00:00"
         },
         {
             "name": "incenteev/composer-parameter-handler",

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

@@ -1028,5 +1028,15 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
     {
         return $this->onuProfile;
     }
+    
+    /**
+     * @return string
+     */
+    public function getServicePortsNumbers()
+    {
+        return implode(',', array_map(function($servicePort) {
+            return $servicePort->getNumber();
+        }, $this->servicePorts->toArray()));
+    }
 
 }

+ 7 - 2
src/FTTHBundle/EventListener/ONUSubscriber.php

@@ -75,7 +75,9 @@ class ONUSubscriber implements EventSubscriber
         $entity = $args->getEntity();
         if ($entity instanceof ONU) {
             $this->em = $args->getEntityManager();
-            $this->setServicePorts($entity);
+            if (!$entity->isDeleted()) {
+                $this->setServicePorts($entity);
+            }
         }
     }
 
@@ -95,7 +97,10 @@ class ONUSubscriber implements EventSubscriber
         $entity = $args->getEntity();
         if ($entity instanceof ONU) {
             $this->em = $args->getEntityManager();
-            $this->setServicePorts($entity);
+            
+            if (!$entity->isDeleted()) {
+                $this->setServicePorts($entity);
+            }
         }
     }
         

+ 1 - 1
src/FTTHBundle/Repository/ONURepository.php

@@ -30,5 +30,5 @@ class ONURepository extends \Doctrine\ORM\EntityRepository
 
         return $qb->getQuery()->getResult();
     }
-
+    
 }