/** * */ 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 testPossibleValues() { $v = $this->_instances->getPossibleValues("http://abc"); $this->assertEmpty($v); //on a stub store, there should be no results }
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 explorerepoAction() { $this->view->placeholder('main.window.title')->set($this->_owApp->translate->_('Explore Repo')); if (!$this->_erfurt->getAc()->isActionAllowed('ExtensionConfiguration')) { throw new OntoWiki_Exception('config not allowed for this user'); } $repoUrl = $this->_privateConfig->repoUrl; if (($otherRepo = $this->getParam('repoUrl')) != null) { $repoUrl = $otherRepo; } $graph = $this->_privateConfig->graph; if (($otherGraph = $this->getParam('graph')) != null) { $graph = $otherGraph; } $this->view->repoUrl = $repoUrl; $this->view->graph = $graph; $ow = OntoWiki::getInstance(); $ow->appendMessage(new OntoWiki_Message('Repository: ' . $repoUrl, OntoWiki_Message::INFO)); //$ow->appendMessage(new OntoWiki_Message("Graph: ".$graph, OntoWiki_Message::INFO)); //define the list on a new store, that queries a sparql endpoint $adapter = new Erfurt_Store_Adapter_Sparql(array('serviceUrl' => $repoUrl, 'graphs' => array($graph))); $store = new Erfurt_Store(array('adapterInstance' => $adapter), 'sparql'); $listHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('List'); $listName = 'extensions'; if ($listHelper->listExists($listName)) { $list = $listHelper->getList($listName); $list->setStore($store); $list->invalidate(); //remote repo may change data $listHelper->addList($listName, $list, $this->view, 'list_extensions_main'); } else { $rdfGraphObj = new Erfurt_Rdf_Model($graph); $list = new OntoWiki_Model_Instances($store, $rdfGraphObj, array(Erfurt_Store::USE_CACHE => false)); $list->addTypeFilter(self::VERSION_CLASS, null, array('withChilds' => false)); //the version needs to be related to a project (inverse) $projectVar = new Erfurt_Sparql_Query2_Var('project'); $list->addTripleFilter(array(new Erfurt_Sparql_Query2_Triple($projectVar, new Erfurt_Sparql_Query2_IriRef(self::EXTENSION_RELEASE_PROPERTY), $list->getResourceVar()))); //$list->addShownProperty(self::EXTENSION_RELEASE_PROPERTY, 'project', true); //internal name (folder name) $this->addProjectProperty(self::EXTENSION_NAME_PROPERTY, $projectVar, $list, 'name'); //pretty name (label) $this->addProjectProperty(self::EXTENSION_TITLE_PROPERTY, $projectVar, $list, 'title'); $this->addProjectProperty(self::EXTENSION_DESCRIPTION_PROPERTY, $projectVar, $list); $this->addProjectProperty(self::EXTENSION_PAGE_PROPERTY, $projectVar, $list); $this->addProjectProperty(self::EXTENSION_AUTHOR_PROPERTY, $projectVar, $list); $this->addAuthorProperty(self::EXTENSION_AUTHORLABEL_PROPERTY, $projectVar, $list, 'authorLabel'); $this->addAuthorProperty(self::EXTENSION_AUTHORPAGE_PROPERTY, $projectVar, $list); $this->addAuthorProperty(self::EXTENSION_AUTHORMAIL_PROPERTY, $projectVar, $list); //properties of the versions $list->addShownProperty(self::EXTENSION_RELEASELOCATION_PROPERTY, 'zip'); $list->addShownProperty(self::EXTENSION_RELEASE_ID_PROPERTY, 'revision'); $list->addShownProperty(self::EXTENSION_MINOWVERSION_PROPERTY, 'minOwVersion'); $listHelper->addListPermanently($listName, $list, $this->view, 'list_extensions_main'); } //$this->addModuleContext('main.window.list'); //echo htmlentities($list->getResourceQuery()); //echo htmlentities($list->getQuery()); }
/** * * @depends testShownPropertiesAdd */ public function testShownPropertiesAddTitles(OntoWiki_Model_Instances $i) { //verify triple in value query $propertiesWithTitles = $i->getShownProperties(); $this->assertCount(2, $propertiesWithTitles); }
/** * 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')); }