[icinga-checkins] icinga.org: icingaweb2-module-director/feature-ddo-playground: ImportedrowsTable: benefit from new ImportRun

git at icinga.org git at icinga.org
Tue Jul 19 10:31:51 CEST 2016


Module: icingaweb2-module-director
Branch: feature-ddo-playground
Commit: 70f8a8986e2f212f9efe112c71cb81c75d722c59
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=70f8a8986e2f212f9efe112c71cb81c75d722c59

Author: Thomas Gelf <thomas at gelf.net>
Date:   Wed Jul 13 21:36:45 2016 +0200

ImportedrowsTable: benefit from new ImportRun

---

 application/tables/ImportedrowsTable.php |   53 +++++++++++++-----------------
 1 file changed, 22 insertions(+), 31 deletions(-)

diff --git a/application/tables/ImportedrowsTable.php b/application/tables/ImportedrowsTable.php
index bd327cb..8e69719 100644
--- a/application/tables/ImportedrowsTable.php
+++ b/application/tables/ImportedrowsTable.php
@@ -2,26 +2,39 @@
 
 namespace Icinga\Module\Director\Tables;
 
-use Icinga\Module\Director\Web\Table\QuickTable;
 use Icinga\Data\DataArray\ArrayDatasource;
+use Icinga\Module\Director\Objects\ImportRun;
+use Icinga\Module\Director\Web\Table\QuickTable;
 
 class ImportedrowsTable extends QuickTable
 {
-    protected $checksum;
+    protected $columns;
 
-    public function getColumns()
+    protected $importRun;
+
+    public function setImportRun(ImportRun $run)
     {
-        $db = $this->connection();
-        $cols = $db->listImportedRowsetColumnNames($this->checksum);
-        return array_combine($cols, $cols);
+        $this->importRun = $run;
+        return $this;
     }
 
-    public function setChecksum($checksum)
+    public function setColumns($columns)
     {
-        $this->checksum = $checksum;
+        $this->columns = $columns;
         return $this;
     }
 
+    public function getColumns()
+    {
+        if ($this->columns === null) {
+            $cols = $this->importRun->listColumnNames();
+        } else {
+            $cols = $this->columns;
+        }
+
+        return array_combine($cols, $cols);
+    }
+
     public function getTitles()
     {
         $cols = $this->getColumns();
@@ -39,21 +52,6 @@ class ImportedrowsTable extends QuickTable
             $query->limit($this->getLimit(), $this->getOffset());
         }
 
-        // TODO: move to dedicated method in parent class
-        $filter = null;
-        $enforced = $this->enforcedFilters;
-        if ($this->filter && ! $this->filter->isEmpty()) {
-            $filter = $this->filter;
-        } elseif (! empty($enforced)) {
-            $filter = array_shift($enforced);
-        }
-        if ($filter) {
-            foreach ($enforced as $f) {
-                $filter->andFilter($f);
-            }
-            $query->where($this->renderFilter($filter));
-        }
-
         return $query->fetchAll();
     }
 
@@ -65,16 +63,9 @@ class ImportedrowsTable extends QuickTable
     public function getBaseQuery()
     {
         $ds = new ArrayDatasource(
-            $this->connection()->fetchImportedRowsetRows(
-                $this->checksum,
-                null
-            )
+            $this->importRun->fetchRows($this->columns, $this->filter)
         );
 
         return $ds->select()->order('object_name');
-        // TODO: Remove? ->
-        return $this->connection()->createImportedRowsetRowsQuery(
-            $this->checksum
-        )->order('object_name');
     }
 }



More information about the icinga-checkins mailing list