public function getList($view, $singleResource = true, $limit = null) { $store = $this->_owApp->erfurt->getStore(); $graph = $this->_owApp->selectedModel; $resource = $this->_owApp->selectedResource; $aboutProperty = $this->_privateConfig->about->property; $creatorProperty = $this->_privateConfig->creator->property; $commentType = $this->_privateConfig->comment->type; $contentProperty = $this->_privateConfig->content->property; $dateProperty = $this->_privateConfig->date->property; if ($limit === null) { $limit = $this->_privateConfig->limit; } // get all resource comments // Loading data for list of saved queries $listHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('List'); $list = new OntoWiki_Model_Instances($store, $graph, array()); $list->addTypeFilter($commentType, 'searchcomments'); $list->addShownProperty($aboutProperty, "about", false, null, false); $list->addShownProperty($creatorProperty, "creator", false, null, false); $list->addShownProperty($contentProperty, "content", false, null, false); $list->addShownProperty($dateProperty, "date", false, null, false); $list->setLimit($limit); $list->setOrderProperty($dateProperty, false); if ($singleResource) { $list->addTripleFilter(array(new Erfurt_Sparql_Query2_Triple($list->getResourceVar(), new Erfurt_Sparql_Query2_IriRef($aboutProperty), new Erfurt_Sparql_Query2_IriRef((string) $resource)))); } else { // doesn't work $list->addShownProperty($aboutProperty, "about", false, null, false); $instances = $listHelper->getList('instances'); $query = clone $instances->getResourceQuery(); $resourceVar = $instances->getResourceVar(); $vars = $query->getWhere()->getVars(); foreach ($vars as $var) { if ($var->getName() == $resourceVar->getName()) { $var->setName('listresource'); } } $elements = $query->getWhere()->getElements(); //link old list to elements of the community-list $elements[] = new Erfurt_Sparql_Query2_Triple($list->getResourceVar(), new Erfurt_Sparql_Query2_IriRef($aboutProperty), $var); $list->addTripleFilter($elements, "listfilter"); } $listName = "community"; $other = new stdClass(); $other->singleResource = $singleResource; $other->statusBar = false; if ($list->hasData()) { return $listHelper->addListPermanently($listName, $list, $view, 'list_community_main', $other, true); } else { return null; } }
public function testShownPropertiesAdd() { //add $r = $this->_instances->addShownProperty("http://abc"); //test chaining $this->assertSame($this->_instances, $r); return $this->_instances; }
/** * */ public function testShownPropertiesAddTitles() { //add $r = $this->_instances->addShownProperty("http://abc"); //test chaining $this->assertSame($this->_instances, $r); //verify triple in value query $propertiesWithTitles = $this->_instances->getShownProperties(); $this->assertCount(2, $propertiesWithTitles); }
public function testtShownPropertiesRemove() { //add $p = "http://abc"; $this->_instances->addShownProperty($p); //result of add is checked in testShownPropertiesAdd1 $rA = $this->_instances->removeShownProperty($p, false); $this->assertNoShownProperties($this->_instances); $this->assertTrue($rA); //remove non existing $rB = $this->_instances->removeShownProperty($p, false); $this->assertFalse($rB); }
/** * Action that will show existing saved Queries */ public function listqueryAction() { if ($this->_owApp->selectedModel === null) { $this->_owApp->appendMessage(new OntoWiki_Message($this->view->_('No model selected.'), OntoWiki_Message::ERROR)); $this->view->errorFlag = true; return; } // set the active tab navigation OntoWiki::getInstance()->getNavigation()->setActive('listquery'); $store = $this->_owApp->erfurt->getStore(); $graph = $this->_owApp->selectedModel; //Loading data for list of saved queries $listHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('List'); $listName = 'queries'; if ($listHelper->listExists($listName)) { $list = $listHelper->getList($listName); $list->setStore($store); $listHelper->addList($listName, $list, $this->view, 'list_queries_main'); } else { $list = new OntoWiki_Model_Instances($store, $graph, array()); $list->addTypeFilter($this->_privateConfig->saving->ClassUri, 'searchqueries'); $list->addShownProperty($this->_privateConfig->saving->ModelUri, 'modelUri', false, null, true); $list->addShownProperty($this->_privateConfig->saving->JsonUri, 'json', false, null, true); $list->addShownProperty($this->_privateConfig->saving->NameUri, 'name', false, null, false); $list->addShownProperty($this->_privateConfig->saving->QueryUri, 'query', false, null, true); $list->addShownProperty($this->_privateConfig->saving->GeneratorUri, 'generator', false, null, true); $list->addShownProperty($this->_privateConfig->saving->NumViewsUri, 'numViews', false, null, false); $list->addShownProperty($this->_privateConfig->saving->CreatorUri, 'creator', false, null, false); $listHelper->addListPermanently($listName, $list, $this->view, 'list_queries_main'); } $this->view->placeholder('main.window.title')->set($this->_owApp->translate->_('Saved Queries')); }