public function execute($response) { $this->getCache()->resetCache(); $result = null; $jsonObj = json_decode($response); $scrollId = $jsonObj->_scroll_id; $total = $jsonObj->hits->total; foreach ($jsonObj->hits->hits as $index => $tmpObj) { $this->getCache()->add($tmpObj); } if ($this->getCache()->getCount() != $total) { $cmdb = new CMDB(null); $queryObj = new QueryObj(); $queryObj->setQueryUrl(self::SCROLL_URL); $queryObj->setQueryString('{"scroll_id":"' . $scrollId . '"}'); $queryObj->setExecutorName(self::EXECUTOR_NAME); $cmdb->addObserver($queryObj); do { $results = $cmdb->fetch($queryObj); $tmpjsonObj = json_decode($results); foreach ($tmpjsonObj->hits->hits as $index => $tmpObj) { $this->getCache()->add($tmpObj); } unset($tmpjsonObj); } while ($this->getCache()->getCount() != $total); } if (!!($executor = GlobalArgParser::getExecutor())) { $executorObj = new $executor(); $result = $executorObj->execute($this->getCache()->get()); } return $result; }
/** * execute * Main wrapper command for executing cmdb fetches * * @param mixed $className * @static * @access public * @return void */ public static function execute($className) { if (!preg_match(self::CLASSNAME_REGEX, $className)) { $className = CMDB_LOC_PREFIX . $className; } if (!class_exists($className)) { throw new QueryWrapperException($className . self::MISSING_CLASS); } else { if ($className == CMDB_LOC_PREFIX) { throw new QueryWrapperException(self::CMDB_COLLISION . CMDB_LOC_PREFIX); } } $queryObj = new QueryObj(); $queryObj->setQueryUrl(self::QUERY_URL); new $className($queryObj); $cmdb = new CMDB(NULL); $cmdb->addObserver($queryObj); return $cmdb->fetch($queryObj); }