Пример #1
0
 protected function getResources($class, $options, $done)
 {
     $options['offset'] = $done;
     $select = $this->resourceManager->getQueryBuilder()->select('?uri')->where('?uri a ' . $class);
     $select->orderBy('?uri');
     $select->setOffset($done);
     $select->setMaxResults($options['slice']);
     $select = $select->setMaxResults(isset($options['slice']) ? $options['slice'] : null)->getQuery();
     $selectStr = $select->getCompleteSparqlQuery();
     $qb = $this->resourceManager->getRepository($class)->getQueryBuilder();
     $qb->reset()->construct("?uri a {$class}")->addConstruct('?uri rdf:type ?type')->where('?uri a ' . $class)->andWhere('?uri rdf:type ?type')->andWhere('{' . $selectStr . '}');
     return $qb->getQuery()->execute(Query::HYDRATE_COLLECTION, array('rdf:type' => $class));
 }
Пример #2
0
 public function constructOne(array $criteria, array $options)
 {
     $qb = $this->_rm->getQueryBuilder();
     //getting "SELECT" part of the query
     $select = $qb->select('?uri')->where('?uri a ' . $criteria['rdf:type']);
     foreach ($criteria as $property => $value) {
         if ($property !== 'uri') {
             $select->andWhere('?uri ' . $property . ' ' . $this->LiteralToSparqlTerm($value));
         }
     }
     $this->bindVariableAsUri($select, "?uri", $criteria);
     $select = $select->setMaxResults(1)->getQuery();
     $selectStr = $select->getCompleteSparqlQuery();
     //getting whole "CONSTRUCT" query
     $query = $qb->setMaxResults(null)->construct('?uri ?p ?o; a ' . $criteria['rdf:type'])->where('?uri ?p ?o; a ' . $criteria['rdf:type'])->andWhere('{' . $selectStr . '}');
     $result = $query->getQuery()->execute(Query::HYDRATE_ARRAY, array('rdf:type' => $criteria['rdf:type']));
     if (count($result) === 0) {
         return;
     }
     reset($result);
     return current($result);
 }
Пример #3
0
 /**
  * Search all documents containing the updated resource
  * @param $uri
  * @param $resourceType
  * @param $propertiesUpdated
  * @param Manager $rm
  * @return array
  */
 protected function search($uri, $resourceType, $propertiesUpdated, Manager $rm)
 {
     $qb = $rm->getQueryBuilder();
     $typesToReIndex = $this->getAllResourceTypesIndexingThisResourceType($resourceType, $propertiesUpdated);
     $qbByIndex = $this->getQueryBuilderByIndex($typesToReIndex, $resourceType, $propertiesUpdated, $qb, $uri);
     return $qbByIndex;
 }