alsmanager_lib 2.0.90 → 2.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/modules.js +369 -2
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -11352,7 +11352,364 @@ function insertConnectionsFromTemplateIntoDevice(db_used, id_dev_ref) {
11352
11352
  }
11353
11353
  return query;
11354
11354
  }
11355
+ //
11356
+ function existPCTemplateSQLite(dev_model, dev_manifacturer, dev_type) {
11357
+ var query = "select count(*) as num from tpl_model_pc ";
11358
+ query += "where device_type = '" + dev_type + "' and device_manifacturer = '" + dev_manifacturer + "' and device_model = '" + dev_model + "'";
11359
+ return query;
11360
+ }
11361
+
11362
+ function existPCTemplateMySQL(dev_model, dev_manifacturer, dev_type) {
11363
+ var query = "select count(*) as num from tpl_model_pc ";
11364
+ query += "where device_type = :dev_type and device_manifacturer = :dev_manifacturer and device_model = :dev_model";
11365
+ return query;
11366
+ }
11367
+ function existPCTemplate(db_used, dev_model, dev_manifacturer, dev_type) {
11368
+ var query = "";
11369
+ if (db_used) {
11370
+ switch (db_used) {
11371
+ case 'SQLITE':
11372
+ query = existPCTemplateSQLite(dev_model, dev_manifacturer, dev_type);
11373
+ break;
11374
+ case 'MYSQL':
11375
+ query = existPCTemplateMySQL(dev_model, dev_manifacturer, dev_type);
11376
+ break;
11377
+ case 'MYSQL2':
11378
+ query = existPCTemplateSQLite(dev_model, dev_manifacturer, dev_type);
11379
+ break;
11380
+ }
11381
+ }
11382
+ return query;
11383
+ }
11384
+ function insertPCToTemplateFromIdDeviceSQLite(id_device) {
11385
+ var query = "insert into tpl_model_pc (device_type, device_manifacturer, device_model, CPU, CPU_Arch, RAM_GB) ";
11386
+ query += "select d.type, d.manifacturer, d.model, dp.CPU, dp.CPU_Arch, dp.RAM_GB from devices d ";
11387
+ query += "left join device_pc dp on d.id = dp.id_device ";
11388
+ query += "where dp.id is not null and d.id = " + id_device + " ";
11389
+ query += "and (select count(*) from tpl_model_pc where device_type = d.type ";
11390
+ query += "and device_manifacturer = d.manifacturer ";
11391
+ query += "and device_model = d.model ";
11392
+ query += "and CPU = dc.CPU ";
11393
+ query += "and CPU_Arch = dc.CPU_Arch ";
11394
+ query += "and RAM_GB = dc.RAM_GB) = 0";
11395
+ return query;
11396
+ }
11397
+
11398
+ function insertPCToTemplateFromIdDeviceMySQL(id_device) {
11399
+ var query = "insert into tpl_model_pc (device_type, device_manifacturer, device_model, CPU, CPU_Arch, RAM_GB) ";
11400
+ query += "select d.type, d.manifacturer, d.model, dp.CPU, dp.CPU_Arch, dp.RAM_GB from devices d ";
11401
+ query += "left join device_pc dp on d.id = dp.id_device ";
11402
+ query += "where dp.id is not null and d.id = :id_device";
11403
+ query += "and (select count(*) from tpl_model_pc where device_type = d.type ";
11404
+ query += "and device_manifacturer = d.manifacturer ";
11405
+ query += "and device_model = d.model ";
11406
+ query += "and CPU = dc.CPU ";
11407
+ query += "and CPU_Arch = dc.CPU_Arch ";
11408
+ query += "and RAM_GB = dc.RAM_GB) = 0";
11409
+ return query;
11410
+ }
11411
+ function insertPCToTemplateFromIdDevice(db_used, id_device) {
11412
+ var query = "";
11413
+ if (db_used) {
11414
+ switch (db_used) {
11415
+ case 'SQLITE':
11416
+ query = insertPCToTemplateFromIdDeviceSQLite(id_device);
11417
+ break;
11418
+ case 'MYSQL':
11419
+ query = insertPCToTemplateFromIdDeviceMySQL(id_device);
11420
+ break;
11421
+ case 'MYSQL2':
11422
+ query = insertPCToTemplateFromIdDeviceSQLite(id_device);
11423
+ break;
11424
+ }
11425
+ }
11426
+ return query;
11427
+ }
11428
+ function insertPCFromTemplateIntoDeviceSQLite(id_dev_ref) {
11429
+ var query = "insert into device_pc (id_device, CPU, CPU_arch, RAM_GB) ";
11430
+ query += "select d.id, tmpc.CPU, tmpc.CPU_Arch, tmpc.RAM_GB from tpl_model_pc tmpc ";
11431
+ query += "join devices d on d.type = tmpc.device_type ";
11432
+ query += "and d.type = tmpc.device_type ";
11433
+ query += "and d.manifacturer = tmpc.device_manifacturer ";
11434
+ query += "and d.model = tmpc.device_model ";
11435
+ query += "where d.id = " + id_dev_ref + " ";
11436
+ query += "and (select count(*) from device_pc where id_device = d.id ";
11437
+ query += "and CPU = tmpc.CPU ";
11438
+ query += "and CPU_arch = tmpc.CPU_Arch ";
11439
+ query += "and RAM_GB = tmpc.RAM_GB) = 0";
11440
+ return query;
11441
+ }
11442
+
11443
+ function insertPCFromTemplateIntoDeviceMySQL(id_dev_ref) {
11444
+ var query = "insert into device_pc (id_device, CPU, CPU_arch, RAM_GB) ";
11445
+ query += "select d.id, tmpc.CPU, tmpc.CPU_Arch, tmpc.RAM_GB from tpl_model_pc tmpc ";
11446
+ query += "join devices d on d.type = tmpc.device_type ";
11447
+ query += "and d.type = tmpc.device_type ";
11448
+ query += "and d.manifacturer = tmpc.device_manifacturer ";
11449
+ query += "and d.model = tmpc.device_model ";
11450
+ query += "where d.id = :id_device ";
11451
+ query += "and (select count(*) from device_pc where id_device = d.id ";
11452
+ query += "and CPU = tmpc.CPU ";
11453
+ query += "and CPU_arch = tmpc.CPU_Arch ";
11454
+ query += "and RAM_GB = tmpc.RAM_GB) = 0";
11455
+ return query;
11456
+ }
11457
+ function insertPCFromTemplateIntoDevice(db_used, id_dev_ref) {
11458
+ var query = "";
11459
+ if (db_used) {
11460
+ switch (db_used) {
11461
+ case 'SQLITE':
11462
+ query = insertPCFromTemplateIntoDeviceSQLite(id_dev_ref);
11463
+ break;
11464
+ case 'MYSQL':
11465
+ query = insertPCFromTemplateIntoDeviceMySQL(id_dev_ref);
11466
+ break;
11467
+ case 'MYSQL2':
11468
+ query = insertPCFromTemplateIntoDeviceSQLite(id_dev_ref);
11469
+ break;
11470
+ }
11471
+ }
11472
+ return query;
11473
+ }
11474
+ //
11475
+ function existStorageTemplateSQLite(dev_model, dev_manifacturer, dev_type) {
11476
+ var query = "select count(*) as num from tpl_model_storage ";
11477
+ query += "where device_type = '" + dev_type + "' and device_manifacturer = '" + dev_manifacturer + "' and device_model = '" + dev_model + "'";
11478
+ return query;
11479
+ }
11480
+
11481
+ function existStorageTemplateMySQL(dev_model, dev_manifacturer, dev_type) {
11482
+ var query = "select count(*) as num from tpl_model_storage ";
11483
+ query += "where device_type = :dev_type and device_manifacturer = :dev_manifacturer and device_model = :dev_model";
11484
+ return query;
11485
+ }
11486
+ function existStorageTemplate(db_used, dev_model, dev_manifacturer, dev_type) {
11487
+ var query = "";
11488
+ if (db_used) {
11489
+ switch (db_used) {
11490
+ case 'SQLITE':
11491
+ query = existStorageTemplateSQLite(dev_model, dev_manifacturer, dev_type);
11492
+ break;
11493
+ case 'MYSQL':
11494
+ query = existStorageTemplateMySQL(dev_model, dev_manifacturer, dev_type);
11495
+ break;
11496
+ case 'MYSQL2':
11497
+ query = existStorageTemplateSQLite(dev_model, dev_manifacturer, dev_type);
11498
+ break;
11499
+ }
11500
+ }
11501
+ return query;
11502
+ }
11503
+ function insertStorageToTemplateFromIdDeviceSQLite(id_device) {
11504
+ var query = "insert into tpl_model_storages (device_type, device_manifacturer, device_model, dm_storage_type, dm_storage_totsize, dm_storage_size_unit, dm_storage_manifacturer, dm_storage_model) ";
11505
+ query += "select d.type, d.manifacturer, d.model, ds.storage_type, ds.storage_totsize, ds.storage_size_unit, ds.storage_manifacturer, ds.storage_model from devices d ";
11506
+ query += "left join device_storages ds on d.id = ds.id_device ";
11507
+ query += "where ds.id is not null and d.id = " + id_device + " ";
11508
+ query += "and (select count(*) from tpl_model_storages where device_type = d.type ";
11509
+ query += "and device_manifacturer = d.manifacturer ";
11510
+ query += "and device_model = d.model ";
11511
+ query += "and dm_storage_type = ds.storage_type ";
11512
+ query += "and dm_storage_totsize = ds.storage_totsize ";
11513
+ query += "and dm_storage_size_unit = ds.storage_size_unit ";
11514
+ query += "and dm_storage_manifacturer = ds.storage_manifacturer ";
11515
+ query += "and dm_storage_model = ds.storage_model) = 0";
11516
+ return query;
11517
+ }
11518
+
11519
+ function insertStorageToTemplateFromIdDeviceMySQL(id_device) {
11520
+ var query = "insert into tpl_model_storages (device_type, device_manifacturer, device_model, dm_storage_type, dm_storage_totsize, dm_storage_size_unit, dm_storage_manifacturer, dm_storage_model) ";
11521
+ query += "select d.type, d.manifacturer, d.model, ds.storage_type, ds.storage_totsize, ds.storage_size_unit, ds.storage_manifacturer, ds.storage_model from devices d ";
11522
+ query += "left join device_storages ds on d.id = ds.id_device ";
11523
+ query += "where ds.id is not null and d.id = :id_device";
11524
+ query += "and (select count(*) from tpl_model_storages where device_type = d.type ";
11525
+ query += "and device_manifacturer = d.manifacturer ";
11526
+ query += "and device_model = d.model ";
11527
+ query += "and dm_storage_type = ds.storage_type ";
11528
+ query += "and dm_storage_totsize = ds.storage_totsize ";
11529
+ query += "and dm_storage_size_unit = ds.storage_size_unit ";
11530
+ query += "and dm_storage_manifacturer = ds.storage_manifacturer ";
11531
+ query += "and dm_storage_model = ds.storage_model) = 0";
11532
+ return query;
11533
+ }
11534
+ function insertStorageToTemplateFromIdDevice(db_used, id_device) {
11535
+ var query = "";
11536
+ if (db_used) {
11537
+ switch (db_used) {
11538
+ case 'SQLITE':
11539
+ query = insertStorageToTemplateFromIdDeviceSQLite(id_device);
11540
+ break;
11541
+ case 'MYSQL':
11542
+ query = insertStorageToTemplateFromIdDeviceMySQL(id_device);
11543
+ break;
11544
+ case 'MYSQL2':
11545
+ query = insertStorageToTemplateFromIdDeviceSQLite(id_device);
11546
+ break;
11547
+ }
11548
+ }
11549
+ return query;
11550
+ }
11551
+ function insertStorageFromTemplateIntoDeviceSQLite(id_dev_ref) {
11552
+ var query = "insert into device_storages (id_device, storage_type, storage_totsize, storage_size_unit, storage_manifacturer, storage_model) ";
11553
+ query += "select d.id, tms.dm_storage_type, tms.dm_storage_totsize, tms.dm_storage_size_unit, tms.dm_storage_manifacturer, tms.dm_storage_model from tpl_model_storages tms ";
11554
+ query += "join devices d on d.type = tms.device_type ";
11555
+ query += "and d.type = tms.device_type ";
11556
+ query += "and d.manifacturer = tms.device_manifacturer ";
11557
+ query += "and d.model = tms.device_model ";
11558
+ query += "where d.id = " + id_dev_ref + " ";
11559
+ query += "and (select count(*) from device_storages where id_device = d.id ";
11560
+ query += "and storage_type = tms.dm_storage_type ";
11561
+ query += "and storage_totsize = tms.dm_storage_totsize ";
11562
+ query += "and storage_size_unit = tms.dm_storage_size_unit ";
11563
+ query += "and storage_manifacturer = tms.dm_storage_manifacturer ";
11564
+ query += "and storage_model = tms.dm_storage_model) = 0";
11565
+ return query;
11566
+ }
11567
+ function insertStorageFromTemplateIntoDeviceMySQL(id_dev_ref) {
11568
+ var query = "insert into device_storages (id_device, storage_type, storage_totsize, storage_size_unit, storage_manifacturer, storage_model) ";
11569
+ query += "select d.id, tms.dm_storage_type, tms.dm_storage_totsize, tms.dm_storage_size_unit, tms.dm_storage_manifacturer, tms.dm_storage_model from tpl_model_storages tms ";
11570
+ query += "join devices d on d.type = tms.device_type ";
11571
+ query += "and d.type = tms.device_type ";
11572
+ query += "and d.manifacturer = tms.device_manifacturer ";
11573
+ query += "and d.model = tms.device_model ";
11574
+ query += "where d.id = :id_device ";
11575
+ query += "and (select count(*) from device_storages where id_device = d.id ";
11576
+ query += "and storage_type = tms.dm_storage_type ";
11577
+ query += "and storage_totsize = tms.dm_storage_totsize ";
11578
+ query += "and storage_size_unit = tms.dm_storage_size_unit ";
11579
+ query += "and storage_manifacturer = tms.dm_storage_manifacturer ";
11580
+ query += "and storage_model = tms.dm_storage_model) = 0";
11581
+ return query;
11582
+ }
11583
+ function insertStorageFromTemplateIntoDevice(db_used, id_dev_ref) {
11584
+ var query = "";
11585
+ if (db_used) {
11586
+ switch (db_used) {
11587
+ case 'SQLITE':
11588
+ query = insertStorageFromTemplateIntoDeviceSQLite(id_dev_ref);
11589
+ break;
11590
+ case 'MYSQL':
11591
+ query = insertStorageFromTemplateIntoDeviceMySQL(id_dev_ref);
11592
+ break;
11593
+ case 'MYSQL2':
11594
+ query = insertStorageFromTemplateIntoDeviceSQLite(id_dev_ref);
11595
+ break;
11596
+ }
11597
+ }
11598
+ return query;
11599
+ }
11600
+ //
11601
+ function existNetworkTemplateSQLite(dev_model, dev_manifacturer, dev_type) {
11602
+ var query = "select count(*) as num from tpl_model_network ";
11603
+ query += "where device_type = '" + dev_type + "' and device_manifacturer = '" + dev_manifacturer + "' and device_model = '" + dev_model + "'";
11604
+ return query;
11605
+ }
11355
11606
 
11607
+ function existNetworkTemplateMySQL(dev_model, dev_manifacturer, dev_type) {
11608
+ var query = "select count(*) as num from tpl_model_network ";
11609
+ query += "where device_type = :dev_type and device_manifacturer = :dev_manifacturer and device_model = :dev_model";
11610
+ return query;
11611
+ }
11612
+ function existNetworkTemplate(db_used, dev_model, dev_manifacturer, dev_type) {
11613
+ var query = "";
11614
+ if (db_used) {
11615
+ switch (db_used) {
11616
+ case 'SQLITE':
11617
+ query = existNetworkTemplateSQLite(dev_model, dev_manifacturer, dev_type);
11618
+ break;
11619
+ case 'MYSQL':
11620
+ query = existNetworkTemplateMySQL(dev_model, dev_manifacturer, dev_type);
11621
+ break;
11622
+ case 'MYSQL2':
11623
+ query = existNetworkTemplateSQLite(dev_model, dev_manifacturer, dev_type);
11624
+ break;
11625
+ }
11626
+ }
11627
+ return query;
11628
+ }
11629
+ function insertNetworkToTemplateFromIdDeviceSQLite(id_device) {
11630
+ var query = "insert into tpl_model_networks (device_type, device_manifacturer, device_model, dm_net_type) ";
11631
+ query += "select d.type, d.manifacturer, d.model, dn.net_type from devices d ";
11632
+ query += "left join device_networks dn on d.id = dn.id_device ";
11633
+ query += "where dn.id is not null and d.id = " + id_device + " ";
11634
+ query += "and (select count(*) from tpl_model_networks where device_type = d.type ";
11635
+ query += "and device_manifacturer = d.manifacturer ";
11636
+ query += "and device_model = d.model ";
11637
+ query += "and dm_net_type = dn.net_type) = 0";
11638
+ return query;
11639
+ }
11640
+ function insertNetworkToTemplateFromIdDeviceMySQL(id_device) {
11641
+ var query = "insert into tpl_model_networks (device_type, device_manifacturer, device_model, dm_net_type) ";
11642
+ query += "select d.type, d.manifacturer, d.model, dn.net_type from devices d ";
11643
+ query += "left join device_networks dn on d.id = dn.id_device ";
11644
+ query += "where dn.id is not null and d.id = :id_device ";
11645
+ query += "and (select count(*) from tpl_model_networks where device_type = d.type ";
11646
+ query += "and device_manifacturer = d.manifacturer ";
11647
+ query += "and device_model = d.model ";
11648
+ query += "and dm_net_type = dn.net_type) = 0";
11649
+ return query;
11650
+ }
11651
+
11652
+ function insertNetworkToTemplateFromIdDevice(db_used, id_device) {
11653
+ var query = "";
11654
+ if (db_used) {
11655
+ switch (db_used) {
11656
+ case 'SQLITE':
11657
+ query = insertNetworkToTemplateFromIdDeviceSQLite(id_device);
11658
+ break;
11659
+ case 'MYSQL':
11660
+ query = insertNetworkToTemplateFromIdDeviceMySQL(id_device);
11661
+ break;
11662
+ case 'MYSQL2':
11663
+ query = insertNetworkToTemplateFromIdDeviceSQLite(id_device);
11664
+ break;
11665
+ }
11666
+ }
11667
+ return query;
11668
+ }
11669
+
11670
+ function insertNetworkFromTemplateIntoDeviceSQLite(id_dev_ref) {
11671
+ var query = "insert into device_networks (id_device, net_type) ";
11672
+ query += "select d.id, tmn.dm_net_type from tpl_model_networks tmn ";
11673
+ query += "join devices d on d.type = tmn.device_type ";
11674
+ query += "and d.type = tmn.device_type ";
11675
+ query += "and d.manifacturer = tmn.device_manifacturer ";
11676
+ query += "and d.model = tmn.device_model ";
11677
+ query += "where d.id = " + id_dev_ref + " ";
11678
+ query += "and (select count(*) from device_networks where id_device = d.id ";
11679
+ query += "and net_type = tmn.dm_net_type) = 0";
11680
+ return query;
11681
+ }
11682
+
11683
+ function insertNetworkFromTemplateIntoDeviceMySQL(id_dev_ref) {
11684
+ var query = "insert into device_networks (id_device, net_type) ";
11685
+ query += "select d.id, tmn.dm_net_type from tpl_model_networks tmn ";
11686
+ query += "join devices d on d.type = tmn.device_type ";
11687
+ query += "and d.type = tmn.device_type ";
11688
+ query += "and d.manifacturer = tmn.device_manifacturer ";
11689
+ query += "and d.model = tmn.device_model ";
11690
+ query += "where d.id = :id_device ";
11691
+ query += "and (select count(*) from device_networks where id_device = d.id ";
11692
+ query += "and net_type = tmn.dm_net_type) = 0";
11693
+ return query;
11694
+ }
11695
+
11696
+ function insertNetworkFromTemplateIntoDevice(db_used, id_dev_ref) {
11697
+ var query = "";
11698
+ if (db_used) {
11699
+ switch (db_used) {
11700
+ case 'SQLITE':
11701
+ query = insertNetworkFromTemplateIntoDeviceSQLite(id_dev_ref);
11702
+ break;
11703
+ case 'MYSQL':
11704
+ query = insertNetworkFromTemplateIntoDeviceMySQL(id_dev_ref);
11705
+ break;
11706
+ case 'MYSQL2':
11707
+ query = insertNetworkFromTemplateIntoDeviceSQLite(id_dev_ref);
11708
+ break;
11709
+ }
11710
+ }
11711
+ return query;
11712
+ }
11356
11713
  // End Manage template models
11357
11714
 
11358
11715
  // Exports
@@ -11639,8 +11996,18 @@ module.exports = {
11639
11996
  insertConnectionsToTemplate,
11640
11997
  updateConnectionsToTemplate,
11641
11998
  removeConnectorFromTemplate,
11642
- insertConnectionsToTemplateFromIdDevice,
11999
+ //
11643
12000
  existConnectionTemplate,
11644
- insertConnectionsFromTemplateIntoDevice
12001
+ insertConnectionsToTemplateFromIdDevice,
12002
+ insertConnectionsFromTemplateIntoDevice,
12003
+ existPCTemplate,
12004
+ insertPCToTemplateFromIdDevice,
12005
+ insertPCFromTemplateIntoDevice,
12006
+ existStorageTemplate,
12007
+ insertStorageToTemplateFromIdDevice,
12008
+ insertStorageFromTemplateIntoDevice,
12009
+ existNetworkTemplate,
12010
+ insertNetworkToTemplateFromIdDevice,
12011
+ insertNetworkFromTemplateIntoDevice
11645
12012
  };
11646
12013
  // end of source
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  ".": "./lib/modules.js",
5
5
  "./dbconn": "./lib/dbconn.js"
6
6
  },
7
- "version": "2.0.90",
7
+ "version": "2.0.92",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",