Skip to content

Commit

Permalink
enhancement: uke/pit: implemented network node flags and services sup…
Browse files Browse the repository at this point in the history
…port (used among others for BSA and LLU flaging)
  • Loading branch information
chilek committed Jul 22, 2024
1 parent 8a87d86 commit e31bf43
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 27 deletions.
4 changes: 3 additions & 1 deletion doc/lms.mysql
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,8 @@ CREATE TABLE netnodes (
address_id int(11) DEFAULT NULL,
info text DEFAULT NULL,
ownerid int(11) DEFAULT NULL,
flags smallint NOT NULL DEFAULT 0,
services varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (id),
CONSTRAINT netnodes_address_id_fkey
FOREIGN KEY (address_id) REFERENCES addresses (id) ON DELETE SET NULL ON UPDATE CASCADE,
Expand Down Expand Up @@ -4371,4 +4373,4 @@ INSERT INTO netdevicemodels (name, alternative_name, netdeviceproducerid) VALUES
('XR7', 'XR7 MINI PCI PCBA', 2),
('XR9', 'MINI PCI 600MW 900MHZ', 2);

INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2024071900');
INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2024072200');
4 changes: 3 additions & 1 deletion doc/lms.pgsql
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,8 @@ CREATE TABLE netnodes (
info text DEFAULT NULL,
ownerid integer DEFAULT NULL
CONSTRAINT netnodes_ownerid_fkey REFERENCES customers (id) ON DELETE SET NULL ON UPDATE CASCADE,
flags smallint NOT NULL DEFAULT 0,
services varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY(id)
);

Expand Down Expand Up @@ -4418,6 +4420,6 @@ INSERT INTO netdevicemodels (name, alternative_name, netdeviceproducerid) VALUES
('XR7', 'XR7 MINI PCI PCBA', 2),
('XR9', 'MINI PCI 600MW 900MHZ', 2);

INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2024071900');
INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2024072200');

COMMIT;
2 changes: 1 addition & 1 deletion lib/LMSDB_common.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

// here should be always the newest version of database!
define('DBVERSION', '2024071900');
define('DBVERSION', '2024072200');

/**
*
Expand Down
59 changes: 59 additions & 0 deletions lib/LMSManagers/LMSNetNodeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class LMSNetNodeManager extends LMSManager implements LMSNetNodeManagerInterface

public function GetNetNodeList($search = array(), $order = 'name,asc')
{
global $NETWORK_NODE_FLAGS, $NETWORK_NODE_SERVICES;

$search = $search ?? array();
$order = $order ?? 'name,asc';

Expand Down Expand Up @@ -128,6 +130,8 @@ public function GetNetNodeList($search = array(), $order = 'name,asc')
'SELECT n.id, n.name' . ($short ? ''
: ', n.type, n.status, n.invprojectid, n.info, n.lastinspectiontime, p.name AS project,
n.divisionid, d.shortname AS division, longitude, latitude, ownership, coowner, uip, miar,
n.flags,
n.services,
netdevcount.netdevcount,
lc.ident AS location_city_ident,
(CASE WHEN lst.ident IS NULL
Expand Down Expand Up @@ -167,6 +171,23 @@ public function GetNetNodeList($search = array(), $order = 'name,asc')
);
}

foreach ($nlist as &$netnode) {
$flags = $netnode['flags'];
$netnode['flags'] = array();
foreach ($NETWORK_NODE_FLAGS as $flag => $label) {
if ($flags & $flag) {
$netnode['flags'][$flag] = $flag;
}
}

$services = explode(',', $netnode['services']);
$netnode['services'] = array();
foreach ($services as $service) {
$netnodes['services'][$service] = $service;
}
}
unset($netnode);

if (!$short && $nlist) {
$filecontainers = $this->db->GetAllByKey(
'SELECT fc.netnodeid
Expand Down Expand Up @@ -234,6 +255,17 @@ public function NetNodeAdd($netnodedata)
'ownerid' => !empty($netnodedata['ownerid']) && !empty($netnodedata['ownership']) ? $netnodedata['ownerid'] : null
);

if (array_key_exists('flags', $netnodedata)) {
$args['flags'] = 0;
foreach ($netnodedata['flags'] as $flag) {
$args['flags'] += $flag;
}
}

if (array_key_exists('services', $netnodedata)) {
$args['services'] = implode(',', $netnodedata['services']);
}

$this->db->Execute("INSERT INTO netnodes (" . implode(', ', array_keys($args))
. ") VALUES (" . implode(', ', array_fill(0, count($args), '?')) . ")", array_values($args));

Expand Down Expand Up @@ -310,6 +342,17 @@ public function NetNodeUpdate($netnodedata)
$args['ownerid'] = empty($netnodedata['ownerid']) || empty($netnodedata['ownership']) ? null : $netnodedata['ownerid'];
}

if (array_key_exists('flags', $netnodedata)) {
$args['flags'] = 0;
foreach ($netnodedata['flags'] as $flag) {
$args['flags'] += $flag;
}
}

if (array_key_exists('services', $netnodedata)) {
$args['services'] = implode(',', $netnodedata['services']);
}

if (empty($args)) {
return null;
}
Expand Down Expand Up @@ -359,6 +402,8 @@ public function NetNodeUpdate($netnodedata)

public function GetNetNode($id)
{
global $NETWORK_NODE_FLAGS;

$result = $this->db->GetRow("SELECT n.*, p.name AS projectname,
addr.location, addr.name as location_name, addr.id as address_id,
addr.state as location_state_name, addr.state_id as location_state,
Expand All @@ -380,6 +425,20 @@ public function GetNetNode($id)
LEFT JOIN location_states ls ON ls.id = ld.stateid
WHERE n.id=?", array($id));

$flags = $result['flags'];
$result['flags'] = array();
foreach ($NETWORK_NODE_FLAGS as $flag => $label) {
if ($flags & $flag) {
$result['flags'][$flag] = $flag;
}
}

$services = explode(',', $result['services']);
$result['services'] = array();
foreach ($services as $service) {
$result['services'][$service] = $service;
}

if (!empty($result['location_city'])) {
$result['teryt'] = 1;
}
Expand Down
25 changes: 25 additions & 0 deletions lib/definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,29 @@
RTMESSAGE_ASSIGNED_EVENT_CHANGE = 4194304,
RTMESSAGE_ASSIGNED_EVENT_DELETE = 8388608;

const NETWORK_NODE_FLAG_BSA = 1,
NETWORK_NODE_FLAG_INTERFACE_COUNT_INCREASE_POSSIBILITY = 2,
NETWORK_NODE_FLAG_CRITICAL_INFRASTRUCTURE = 4;

$NETWORK_NODE_FLAGS = array(
NETWORK_NODE_FLAG_BSA => trans('<!uke-pit>BSA service'),
NETWORK_NODE_FLAG_INTERFACE_COUNT_INCREASE_POSSIBILITY => trans('<!uke-pit>interface count increase possibility'),
NETWORK_NODE_FLAG_CRITICAL_INFRASTRUCTURE => trans('<!uke-pit>critical infrastructure'),
);

$NETWORK_NODE_SERVICES = array(
1 => trans('<!uke-pit-service>access to cable ducting'),
2 => trans('<!uke-pit-service>access to dark fibers'),
3 => trans('<!uke-pit-service>LLU'),
4 => trans('<!uke-pit-service>VULA'),
5 => trans('<!uke-pit-service>access to pole substructure, towers and masts'),
6 => trans('<!uke-pit-service>collocation'),
7 => trans('<!uke-pit-service>network connection in collocation mode'),
8 => trans('<!uke-pit-service>network connection in linear mode'),
9 => trans('<!uke-pit-service>provided to end user'),
10 => trans('<!uke-pit-service>other'),
);

const NETWORK_INTERFACE_TYPE_UNI = 0,
NETWORK_INTERFACE_TYPE_NNI = 1;

Expand Down Expand Up @@ -1685,6 +1708,8 @@ function ($link_technology) {
if (isset($SMARTY)) {
$SMARTY->assign(
array(
'_NETWORK_NODE_FLAGS' => $NETWORK_NODE_FLAGS,
'_NETWORK_NODE_SERVICES' => $NETWORK_NODE_SERVICES,
'_NETWORK_INTERFACE_TYPES' => $NETWORK_INTERFACE_TYPES,
'_CTYPES' => $CTYPES,
'_CSTATUSES' => $CSTATUSES,
Expand Down
14 changes: 14 additions & 0 deletions lib/locale/pl_PL/strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -5937,3 +5937,17 @@
$_LANG['Mark as LLU service'] = 'Oznacz jako usługę LLU';
$_LANG['BSA service'] = 'Usługa BSA';
$_LANG['Mark as BSA service'] = 'Oznacz jako usługę BSA';

$_LANG['<!uke-pit>BSA service'] = 'usługa BSA';
$_LANG['<!uke-pit>critical infrastructure'] = 'infrastruktura krytyczna';
$_LANG['<!uke-pit>interface count increase possibility'] = 'możliwość zwiększenia liczby interfejsów';
$_LANG['<!uke-pit-service>access to cable ducting'] = 'dostęp do kanalizacji kablowej';
$_LANG['<!uke-pit-service>access to dark fibers'] = 'dostęp do ciemnych włókien';
$_LANG['<!uke-pit-service>LLU'] = 'LLU';
$_LANG['<!uke-pit-service>VULA'] = 'VULA';
$_LANG['<!uke-pit-service>access to pole substructure, towers and masts'] = 'dostęp do podbudowy słupowej, wież i masztów';
$_LANG['<!uke-pit-service>collocation'] = 'kolokacja';
$_LANG['<!uke-pit-service>network connection in collocation mode'] = 'połączenie sieci w trybie kolokacji';
$_LANG['<!uke-pit-service>network connection in linear mode'] = 'połączenie sieci w trybie liniowym';
$_LANG['<!uke-pit-service>provided to end user'] = 'świadczona dla użytkowników końcowych';
$_LANG['<!uke-pit-service>other'] = 'inna';
36 changes: 36 additions & 0 deletions lib/upgradedb/mysql.2024072200.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* LMS version 1.11-git
*
* (C) Copyright 2001-2024 LMS Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
*/

$this->BeginTrans();

if (!$this->ResourceExists('netnodes.flags', LMSDB::RESOURCE_TYPE_COLUMN)) {
$this->Execute("ALTER TABLE netnodes ADD COLUMN flags smallint NOT NULL DEFAULT 0");
}

if (!$this->ResourceExists('netnodes.services', LMSDB::RESOURCE_TYPE_COLUMN)) {
$this->Execute("ALTER TABLE netnodes ADD COLUMN services varchar(100) NOT NULL DEFAULT ''");
}

$this->Execute("UPDATE dbinfo SET keyvalue = ? WHERE keytype = ?", array('2024072200', 'dbversion'));

$this->CommitTrans();
36 changes: 36 additions & 0 deletions lib/upgradedb/postgres.2024072200.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* LMS version 1.11-git
*
* (C) Copyright 2001-2024 LMS Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
*/

$this->BeginTrans();

if (!$this->ResourceExists('netnodes.flags', LMSDB::RESOURCE_TYPE_COLUMN)) {
$this->Execute("ALTER TABLE netnodes ADD COLUMN flags smallint NOT NULL DEFAULT 0");
}

if (!$this->ResourceExists('netnodes.services', LMSDB::RESOURCE_TYPE_COLUMN)) {
$this->Execute("ALTER TABLE netnodes ADD COLUMN services varchar(100) NOT NULL DEFAULT ''");
}

$this->Execute("UPDATE dbinfo SET keyvalue = ? WHERE keytype = ?", array('2024072200', 'dbversion'));

$this->CommitTrans();
Loading

0 comments on commit e31bf43

Please sign in to comment.