From 00b027b1a49e10c5684e36a62cf4928f9789375c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Marsza=C5=82?= Date: Tue, 21 May 2024 15:58:07 +0200 Subject: [PATCH] fix: allow performing only class search --- core/kernel/persistence/smoothsql/class.Class.php | 4 +++- .../smoothsql/search/ComplexSearchService.php | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/kernel/persistence/smoothsql/class.Class.php b/core/kernel/persistence/smoothsql/class.Class.php index ef613f70d..3be8f14f1 100644 --- a/core/kernel/persistence/smoothsql/class.Class.php +++ b/core/kernel/persistence/smoothsql/class.Class.php @@ -563,6 +563,7 @@ public function getFilteredQuery(core_kernel_classes_Class $resource, $propertyF $limit = (isset($options['limit']) === false) ? 0 : $options['limit']; $order = (isset($options['order']) === false) ? '' : $options['order']; $orderdir = (isset($options['orderdir']) === false) ? 'ASC' : $options['orderdir']; + $onlyClass = (isset($options['onlyClass']) === false) ? false : $options['onlyClass']; if ($this->getServiceLocator()->has(ComplexSearchService::SERVICE_ID)) { $search = $this->getModel()->getSearchInterface(); @@ -576,7 +577,8 @@ public function getFilteredQuery(core_kernel_classes_Class $resource, $propertyF $offset, $limit, $order, - $orderdir + $orderdir, + $onlyClass ); } else { $query = core_kernel_persistence_smoothsql_Utils::buildFilterQuery( diff --git a/core/kernel/persistence/smoothsql/search/ComplexSearchService.php b/core/kernel/persistence/smoothsql/search/ComplexSearchService.php index e730352d2..f698d5e1d 100755 --- a/core/kernel/persistence/smoothsql/search/ComplexSearchService.php +++ b/core/kernel/persistence/smoothsql/search/ComplexSearchService.php @@ -238,7 +238,8 @@ public function getQuery( $offset = 0, $limit = 0, $order = '', - $orderDir = 'ASC' + $orderDir = 'ASC', + $onlyClass = false ) { $query = $this->getGateway()->query()->setLimit($limit)->setOffset($offset); @@ -248,9 +249,15 @@ public function getQuery( $this->setLanguage($query, $lang); - $criteria = $query->newQuery() + if ($onlyClass === true) { + $criteria = $query->newQuery() + ->add('http://www.w3.org/2000/01/rdf-schema#subClassOf') + ->in($classUri); + } else { + $criteria = $query->newQuery() ->add('http://www.w3.org/1999/02/22-rdf-syntax-ns#type') ->in($classUri); + } $query->setCriteria($criteria); $count = 0;