Example #1
0
 /**
  * @return QueryBuilder
  */
 public function getQueryBuilder()
 {
     if ($this->qb === null) {
         $this->qb = $this->createQueryBuilder();
     }
     $this->qb->reset();
     return $this->qb;
 }
 /**
  * Add array construct parts to qb
  * @param array $arrayConstruct
  * @param QueryBuilder $qb
  */
 protected function addConstructParts($arrayConstruct, $qb)
 {
     foreach ($arrayConstruct as $queryPart) {
         if (is_string($queryPart)) {
             $qb->addConstruct($queryPart);
         } else {
             if (is_array($queryPart)) {
                 $this->addConstructParts($queryPart, $qb);
             }
         }
     }
 }
Example #3
0
 /**
  * With correspondant frames found, contruct a query to find resources that contains the updated resource
  * @param $typesToReIndex
  * @param $resourceType
  * @param $propertiesUpdated
  * @param QueryBuilder $qb
  * @param $uriResourceUpdated
  * @return array
  */
 protected function getQueryBuilderByIndex($typesToReIndex, $resourceType, $propertiesUpdated, QueryBuilder $qb, $uriResourceUpdated)
 {
     $arrayOfTypes = array();
     foreach ($typesToReIndex as $index => $types) {
         $arrayUnion = array();
         foreach ($types as $type => $pathToResourceType) {
             $stringWhere = '?uri a ?typeName; rdf:type ?allTypes;';
             $arrayWhere = array();
             $this->fillPathToResource($pathToResourceType, $resourceType, $propertiesUpdated, $arrayWhere);
             $i = 0;
             foreach ($arrayWhere as $key) {
                 if ($i === 0) {
                     $stringWhere .= ' ' . $key;
                 } else {
                     $stringWhere .= ' / ' . $key;
                 }
                 $i++;
             }
             $stringWhere .= ' <' . $uriResourceUpdated . '>';
             $stringWhere .= " . VALUES ?typeName { {$type} }";
             $arrayUnion[] = $stringWhere;
         }
         if (count($arrayUnion) > 0) {
             $_qb = clone $qb->reset()->select('?uri ?allTypes')->setDistinct(true);
             if (count($arrayUnion) > 1) {
                 $_qb->addUnion($arrayUnion);
             } else {
                 $_qb->where($arrayUnion[0]);
             }
             $arrayOfTypes[$index] = $_qb;
         } else {
             $arrayOfTypes[$index] = null;
         }
     }
     return $arrayOfTypes;
 }