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 testFilterAddTriples() { $triples = array(new Erfurt_Sparql_Query2_Triple($this->_instances->getResourceVar(), new Erfurt_Sparql_Query2_IriRef('http://ex.com/'), new Erfurt_Sparql_Query2_Var("sp"))); $this->_instances->addTripleFilter($triples); //verify two triple in value query, alltriple (?resourceuri ?p ?o), filter(isuri) and the optional triple $triplesQuery = $this->_instances->getResourceQuery()->getElements(); $this->assertContains($triples[0], $triplesQuery); $this->assertCount(1, $this->_instances->getFilter()); }
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()); }