public function previewAction()
 {
     $id = $this->params->get('id');
     $this->view->addLink = $this->view->qlink($this->translate('Run'), 'director/importsource/run', array('id' => $id));
     $source = ImportSource::load($id, $this->db());
     $this->prepareTabs($id)->activate('preview');
     $this->view->title = sprintf($this->translate('Import source preview: "%s"'), $source->source_name);
     $this->view->table = $this->applyPaginationLimits($this->loadTable('importsourceHook')->setConnection($this->db())->setImportSource($source));
     $this->render('list/table', null, true);
 }
 protected function getRowClasses($row)
 {
     if (!$this->revalidate) {
         return array();
     }
     try {
         $import = new Import(ImportSource::load($row->id, $this->connection()));
         if ($import->providesChanges()) {
             $row->source_name = sprintf('%s (%s)', $row->source_name, $this->view()->translate('has changes'));
             return 'pending-changes';
         } else {
             return 'in-sync';
         }
     } catch (Exception $e) {
         $row->source_name = $row->source_name . ' (' . $e->getMessage() . ')';
         return 'failing';
     }
 }
Example #3
0
 protected function runScheduledImports()
 {
     foreach (ImportSource::loadAll($this->db()) as $source) {
         Benchmark::measure('Starting with import ' . $source->source_name);
         try {
             $import = new Import($source);
             if ($import->providesChanges()) {
                 printf('Import "%s" provides changes, triggering run... ', $source->source_name);
                 Benchmark::measure('Found changes for ' . $source->source_name);
                 if ($import->run()) {
                     Benchmark::measure('Import succeeded for ' . $source->source_name);
                     print "SUCCEEDED\n";
                 }
             }
         } catch (Exception $e) {
             echo $this->screen->colorize('ERROR: ' . $e->getMessage(), 'red') . "\n";
             Benchmark::measure('FAILED');
         }
     }
     return $this;
 }
Example #4
0
 public function __construct(ImportSource $source)
 {
     $this->source = $source;
     $this->connection = $source->getConnection();
     $this->db = $this->connection->getDbAdapter();
 }
Example #5
0
 protected function perpareImportSources($properties, $db)
 {
     $sources = array();
     foreach ($properties as $p) {
         $sourceId = $p->source_id;
         if (!array_key_exists($sourceId, $sources)) {
             $sources[$sourceId] = ImportSource::load($sourceId, $db);
         }
     }
     return $sources;
 }
 protected function getImportSource()
 {
     if ($this->importSource === null) {
         if ($this->hasObject()) {
             $src = ImportSource::load($this->object->source_id, $this->db);
         } else {
             $src = ImportSource::load($this->getSentValue('source_id'), $this->db);
         }
         $this->importSource = ImportSourceHook::loadByName($src->source_name, $this->db);
     }
     return $this->importSource;
 }