/** * @param Title|SMWWikiPageValue|DIWikiPage $concept * * @return DIConcept|null */ public function getStatus($concept) { $db = $this->store->getConnection(); $cid = $this->store->smwIds->getSMWPageID($concept->getDBkey(), $concept->getNamespace(), '', '', false); // TODO: catch db exception $row = $db->selectRow('smw_fpt_conc', array('concept_txt', 'concept_features', 'concept_size', 'concept_depth', 'cache_date', 'cache_count'), array('s_id' => $cid), __METHOD__); if ($row === false) { return null; } $dataItem = new DIConcept($concept, null, $row->concept_features, $row->concept_size, $row->concept_depth); if ($row->cache_date) { $dataItem->setCacheStatus('full'); $dataItem->setCacheDate($row->cache_date); $dataItem->setCacheCount($row->cache_count); } else { $dataItem->setCacheStatus('empty'); } return $dataItem; }
protected function performAction(Title $title, DIConcept $concept) { $this->reportMessage("({$this->lines}) "); if ($this->action === 'create') { $this->reportMessage('Creating cache for "' . $title->getPrefixedText() . "\" ...\n"); return $this->store->refreshConceptCache($title); } if ($this->action === 'delete') { $this->reportMessage('Deleting cache for "' . $title->getPrefixedText() . "\" ...\n"); return $this->store->deleteConceptCache($title); } $this->reportMessage('Status for "' . $title->getPrefixedText() . '": '); if ($concept->getCacheStatus() === 'full') { return $this->reportMessage('Cache created at ' . $this->getCacheDateInfo($concept->getCacheDate()) . "{$concept->getCacheCount()} elements in cache\n"); } $this->reportMessage("Not cached.\n"); }
/** * @dataProvider actionProvider */ public function testRebuildSingleFullConceptOnMockStore($action) { $concept = new DIConcept('Foo', '', '', '', ''); $concept->setCacheStatus('full'); $concept->setCacheDate('1358515326'); $concept->setCacheCount('1000'); $instance = $this->acquireInstanceFor($concept); $instance->setParameters(array($action => true, 'old' => 10, 'concept' => 'Bar')); $this->assertTrue($instance->rebuild()); }