From 2d7cfd3eb3a76872733decda19ab16066072fe86 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 25 Jun 2011 09:46:26 +1000 Subject: [PATCH] Added drive to library view --- application/classes/database/tsm/show.php | 34 +++++++++++++- application/classes/model/drive.php | 25 ++++++++++ application/classes/model/filespace.php | 4 +- application/classes/model/library.php | 1 + application/classes/model/mgmtclass.php | 4 +- application/classes/model/path.php | 24 ++++++++++ application/classes/model/schedule/client.php | 4 +- application/classes/slot.php | 9 ++++ application/config/database.php | 3 ++ application/views/library/detail.php | 47 +++++++++++++++++-- 10 files changed, 144 insertions(+), 11 deletions(-) create mode 100644 application/classes/model/drive.php create mode 100644 application/classes/model/path.php diff --git a/application/classes/database/tsm/show.php b/application/classes/database/tsm/show.php index cecaae1..9337cbd 100644 --- a/application/classes/database/tsm/show.php +++ b/application/classes/database/tsm/show.php @@ -11,17 +11,22 @@ * @license http://phptsmadmin.sf.net/license.html */ class Database_TSM_Show extends Database_Result { + private $data = array(); + public function __construct($result, $sql, $as_object = FALSE, array $params = NULL) { parent::__construct($result, $sql, $as_object, $params); $sql = strtolower($sql); $start = FALSE; + $barcodewarn = FALSE; foreach ($result as $line) { if (! trim($line)) continue; - if (preg_match('/^show slots /',$sql)) + if (preg_match('/^show slots /',$sql)) { + $library = strtoupper(preg_replace('/^show slots /','',$sql)); + if (preg_match('/^Slot /',$line)) { if ($start) $this->_internal_row++; @@ -39,10 +44,20 @@ class Database_TSM_Show extends Database_Result { elseif (preg_match('/^barcode\s+/',$val)) $slot['barcode'] = preg_replace('/^barcode /','',$val); - $slot['library'] = preg_replace('/^show slots /','',$sql); + $slot['library'] = $library; $this->_rows[$this->_internal_row] = new Slot($slot); $start = TRUE; + if (! $barcodewarn AND $slot['status'] == 'Allocated' AND $slot['barcode'] == 'not present') { + SystemMessage::add(array( + 'title'=>_('Missing Bar Code Labels'), + 'type'=>'warning', + 'body'=>sprintf(_('Some allocated slots do not have a bar code label, you may need to run "AUDIT LIBRARY %s CHECKLABEL=BARCODE"'),$library), + )); + + $barcodewarn = TRUE; + } + } elseif (preg_match('/busy.$/',$line)) { SystemMessage::add(array( 'title'=>_('Library is Busy'), @@ -51,11 +66,26 @@ class Database_TSM_Show extends Database_Result { )); return; + + } elseif (preg_match('/:/',$line)) { + $line = str_replace(' ','',$line); + list($k,$v) = explode(':',$line,2); + + $this->data[$k] = $v; + } else { } + } } $this->_total_rows = $this->_internal_row; $this->_internal_row = 0; } + + public function __get($key) { + if (isset($this->data[$key])) + return $this->data[$key]; + else + return NULL; + } } ?> diff --git a/application/classes/model/drive.php b/application/classes/model/drive.php new file mode 100644 index 0000000..2280fff --- /dev/null +++ b/application/classes/model/drive.php @@ -0,0 +1,25 @@ +'ASC', + ); + + protected $_has_one = array( + ); + protected $_has_many = array( + 'PATH'=>array('foreign_key'=>array('LIBRARY_NAME'=>'LIBRARY_NAME','DRIVE_NAME'=>'DESTINATION_NAME')), + ); +} +?> diff --git a/application/classes/model/filespace.php b/application/classes/model/filespace.php index 0584214..9e83a1d 100644 --- a/application/classes/model/filespace.php +++ b/application/classes/model/filespace.php @@ -18,8 +18,8 @@ class Model_FILESPACE extends ORMTSM { ); protected $_has_many = array( - 'VOLUMEUSAGE'=>array('foreign_key'=>array('NODE_NAME','FILESPACE_NAME'),'far_key'=>'FILESPACE_NAME'), - 'OCCUPANCY'=>array('foreign_key'=>array('NODE_NAME','FILESPACE_NAME'),'far_key'=>'FILESPACE_NAME'), + 'VOLUMEUSAGE'=>array('foreign_key'=>array('NODE_NAME'=>'NODE_NAME','FILESPACE_NAME'=>'FILESPACE_NAME')), + 'OCCUPANCY'=>array('foreign_key'=>array('NODE_NAME'=>'NODE_NAME','FILESPACE_NAME'=>'FILESPACE_NAME')), ); protected $_display_filters = array( diff --git a/application/classes/model/library.php b/application/classes/model/library.php index 740b698..1e33815 100644 --- a/application/classes/model/library.php +++ b/application/classes/model/library.php @@ -19,6 +19,7 @@ class Model_LIBRARY extends ORMTSM { protected $_has_one = array( ); protected $_has_many = array( + 'DRIVE'=>array('foreign_key'=>'LIBRARY_NAME','far_key'=>'LIBRARY_NAME'), ); } ?> diff --git a/application/classes/model/mgmtclass.php b/application/classes/model/mgmtclass.php index e9d917d..486b612 100644 --- a/application/classes/model/mgmtclass.php +++ b/application/classes/model/mgmtclass.php @@ -19,8 +19,8 @@ class Model_MGMTCLASS extends ORMTSM { ); protected $_has_one = array( - 'COPYGROUP_BU'=>array('foreign_key'=>array('DOMAIN_NAME','SET_NAME','CLASS_NAME')), - 'COPYGROUP_AR'=>array('foreign_key'=>array('DOMAIN_NAME','SET_NAME','CLASS_NAME')), + 'COPYGROUP_BU'=>array('foreign_key'=>array('DOMAIN_NAME'=>'DOMAIN_NAME','SET_NAME'=>'SET_NAME','CLASS_NAME'=>'CLASS_NAME')), + 'COPYGROUP_AR'=>array('foreign_key'=>array('DOMAIN_NAME'=>'DOMAIN_NAME','SET_NAME'=>'SET_NAME','CLASS_NAME'=>'CLASS_NAME')), ); } ?> diff --git a/application/classes/model/path.php b/application/classes/model/path.php new file mode 100644 index 0000000..e9e520b --- /dev/null +++ b/application/classes/model/path.php @@ -0,0 +1,24 @@ +'ASC', + ); + + protected $_has_one = array( + ); + protected $_has_many = array( + ); +} +?> diff --git a/application/classes/model/schedule/client.php b/application/classes/model/schedule/client.php index a083807..2a09dff 100644 --- a/application/classes/model/schedule/client.php +++ b/application/classes/model/schedule/client.php @@ -16,8 +16,8 @@ class Model_SCHEDULE_CLIENT extends ORMTSM { 'SCHEDULE_NAME'=>'ASC', ); - protected $_has_many = array( - 'ASSOCIATION'=>array('foreign_key'=>'SCHEDULE_NAME','far_key'=>'SCHEDULE_NAME'), + protected $_has_many = array( + 'ASSOCIATION'=>array('foreign_key'=>'SCHEDULE_NAME','far_key'=>'SCHEDULE_NAME'), ); protected $_display_filters = array( diff --git a/application/classes/slot.php b/application/classes/slot.php index 8b6fc9c..edb2758 100644 --- a/application/classes/slot.php +++ b/application/classes/slot.php @@ -34,5 +34,14 @@ class Slot { public function __toString() { return $this->slot; } + + public function barcodelabel() { + if ($this->status == 'Allocated' AND $this->barcode == 'not present') + return _('No Label'); + elseif ($this->status == 'Unallocated') + return _('Slot Empty'); + else + return $this->barcodelabel; + } } ?> diff --git a/application/config/database.php b/application/config/database.php index 15d8d87..ed37780 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -45,6 +45,7 @@ return array 'CLIENTOPTS' => 1200, 'DEVCLASSES' => 1200, 'DOMAINS' => 1200, + 'DRIVES' => 1200, 'EVENTS' => 1200, 'FILESPACES' => 1200, 'LIBRARIES' => 1200, @@ -52,6 +53,7 @@ return array 'MGMTCLASSES' => 1200, 'NODES' => 1200, 'OCCUPANCY' => 1200, + 'PATHS' => 1200, 'SCHEMA' => 604800, 'STGPOOLS' => 1200, 'SUMMARY' => 180, @@ -62,6 +64,7 @@ return array 'cachepreload' => array( 'DEVCLASSES' => 1200, 'DOMAINS' => 1200, + 'DRIVES' => 1200, 'LIBVOLUMES' => 1200, 'LIBRARIES' => 1200, 'NODES' => 1200, diff --git a/application/views/library/detail.php b/application/views/library/detail.php index 61c22c3..cdee94b 100644 --- a/application/views/library/detail.php +++ b/application/views/library/detail.php @@ -10,7 +10,8 @@ Name - display('LIBRARY_NAME'); ?> + display('LIBRARY_NAME'),$slots->ProductId); ?> + Serial Number display('LIBRARY_SERIAL'); ?> @@ -19,6 +20,14 @@ Type display('LIBRARY_TYPE'); ?> + + Drives + Drives; ?> + + + Slots/Changers + Slots,$slots->Changers); ?> + Shared display('SHARED'); ?> @@ -34,7 +43,39 @@ -   + + + + + + + + + + + + + + + DRIVE->find_all() as $do) { ?> + + + + + + + + PATH->find_all() as $po) { ?> + + + + + + + + + +
Drives in this Library
 
NameSerial NumberOnlineStateVolume
display('DRIVE_NAME'); ?>display('DRIVE_SERIAL'); ?>display('ONLINE'); ?>display('DRIVE_STATE'); ?>display('VOLUME_NAME'); ?>
 display('SOURCE_NAME'); ?>display('SOURCE_TYPE'); ?>display('DESTINATION_TYPE'); ?>display('DEVICE'); ?>
@@ -60,7 +101,7 @@ - barcodelabel; ?> + barcodelabel()); ?> LIBVOLUME->volusage(); ?> LIBVOLUME->status()); ?> LIBVOLUME->access()); ?>