diff options
Diffstat (limited to 'library/Director/Objects/DirectorJob.php')
-rw-r--r-- | library/Director/Objects/DirectorJob.php | 87 |
1 files changed, 5 insertions, 82 deletions
diff --git a/library/Director/Objects/DirectorJob.php b/library/Director/Objects/DirectorJob.php index 361f764..2a18d52 100644 --- a/library/Director/Objects/DirectorJob.php +++ b/library/Director/Objects/DirectorJob.php @@ -122,8 +122,12 @@ class DirectorJob extends DbObjectWithSettings implements ExportInterface, Insta return false; } + if ($this->get('ts_last_attempt') === null) { + return true; + } + return ( - strtotime((int) $this->get('ts_last_attempt')) + $this->get('run_interval') * 2 + strtotime($this->get('ts_last_attempt')) + $this->get('run_interval') * 2 ) < time(); } @@ -194,87 +198,6 @@ class DirectorJob extends DbObjectWithSettings implements ExportInterface, Insta } /** - * @return object - * @deprecated please use \Icinga\Module\Director\Data\Exporter - * @throws \Icinga\Exception\NotFoundError - */ - public function export() - { - $plain = (object) $this->getProperties(); - $plain->originalId = $plain->id; - unset($plain->id); - unset($plain->timeperiod_id); - if ($this->hasTimeperiod()) { - $plain->timeperiod = $this->timeperiod()->getObjectName(); - } - - foreach ($this->stateProperties as $key) { - unset($plain->$key); - } - $plain->settings = $this->getInstance()->exportSettings(); - - return $plain; - } - - /** - * @param $plain - * @param Db $db - * @param bool $replace - * @return DirectorJob - * @throws DuplicateKeyException - * @throws NotFoundError - */ - public static function import($plain, Db $db, $replace = false) - { - $dummy = new static; - $idCol = $dummy->autoincKeyName; - $keyCol = $dummy->keyName; - $properties = (array) $plain; - if (isset($properties['originalId'])) { - $id = $properties['originalId']; - unset($properties['originalId']); - } else { - $id = null; - } - $name = $properties[$keyCol]; - - if ($replace && $id && static::existsWithNameAndId($name, $id, $db)) { - $object = static::loadWithAutoIncId($id, $db); - } elseif ($replace && static::exists($name, $db)) { - $object = static::load($name, $db); - } elseif (static::exists($name, $db)) { - throw new DuplicateKeyException( - 'Director Job "%s" already exists', - $name - ); - } else { - $object = static::create([], $db); - } - - $settings = (array) $properties['settings']; - - if (array_key_exists('source', $settings) && ! (array_key_exists('source_id', $settings))) { - $val = ImportSource::load($settings['source'], $db)->get('id'); - $settings['source_id'] = $val; - unset($settings['source']); - } - - if (array_key_exists('rule', $settings) && ! (array_key_exists('rule_id', $settings))) { - $val = SyncRule::load($settings['rule'], $db)->get('id'); - $settings['rule_id'] = $val; - unset($settings['rule']); - } - - $properties['settings'] = (object) $settings; - $object->setProperties($properties); - if ($id !== null) { - $object->reallySet($idCol, $id); - } - - return $object; - } - - /** * @param string $name * @param int $id * @param Db $connection |