Exemplo n.º 1
0
 /**
  * Builds the SPARQL query
  */
 private function _buildQueries()
 {
     $query = new Erfurt_Sparql_Query2();
     $uri = new Erfurt_Sparql_Query2_IriRef($this->_uri);
     $predVar = new Erfurt_Sparql_Query2_Var('predicate');
     $objVar = new Erfurt_Sparql_Query2_Var('object');
     $query->addTriple($uri, $predVar, $objVar);
     $query->addFilter(new Erfurt_Sparql_Query2_UnaryExpressionNot(new Erfurt_Sparql_Query2_isBlank($objVar)));
     if (!empty($this->_ignoredPredicates)) {
         $or = new Erfurt_Sparql_Query2_ConditionalAndExpression();
         $filter = new Erfurt_Sparql_Query2_Filter($or);
         foreach ($this->_ignoredPredicates as $ignored) {
             $or->addElement(new Erfurt_Sparql_Query2_UnaryExpressionNot(new Erfurt_Sparql_Query2_sameTerm($predVar, new Erfurt_Sparql_Query2_IriRef($ignored))));
         }
         $query->getWhere()->addElement($filter);
     }
     $query->setDistinct(true)->addProjectionVar($predVar)->addProjectionVar($objVar)->getOrder()->add($predVar);
     $queries = array();
     $closure = Erfurt_App::getInstance()->getStore()->getImportsClosure($this->_model->getModelUri(), true);
     $queryGraphs = array_merge(array($this->_graph), $closure);
     foreach ($queryGraphs as $currentGraph) {
         $query->setFroms(array($currentGraph));
         $queries[$currentGraph] = clone $query;
     }
     return $queries;
 }