getPsrRequest()->getQueryParams(); $parsedBody = $this->getPsrRequest()->getParsedBody(); if ( !isset( $parsedBody['structure'], $parsedBody['query'], $queryParams['rootNode'], $parsedBody['parentNode'] ) ) { $this->setErrorJsonResponse('Request is missing required params'); } try { $promiseModel = $this->getResultSetMapper()->map($parsedBody['structure']); } catch (Exception $exception) { $this->setErrorJsonResponse($exception->getMessage()); return; } $this->setSuccessJsonResponse([ 'url' => _url('search'), 'params' => [ 'query' => $parsedBody['query'], 'rootNode' => $queryParams['rootNode'], 'parentNode' => $parsedBody['parentNode'], 'structure' => $parsedBody['structure'], ], 'filter' => [], 'model' => $promiseModel, 'result' => true ]); } /** * Search results * The search is paginated and initiated by the datatable component. */ public function search(): void { try { $this->returnJson( $this->getSearchProxy()->search( $this->getPsrRequest() ) ); } catch (Exception $exception) { $this->setErrorJsonResponse( $exception->getMessage() ); } } public function getIndexes(): void { if ($this->hasRequestParameter('rootNode') === true) { $rootNodeUri = $this->getRequestParameter('rootNode'); $indexes = OntologyIndexService::getIndexesByClass($this->getClass($rootNodeUri)); $json = []; foreach ($indexes as $propertyUri => $index) { foreach ($index as $i) { $json[] = [ 'identifier' => $i->getIdentifier(), 'fuzzyMatching' => $i->isFuzzyMatching(), 'propertyId' => $propertyUri, ]; } } $this->setSuccessJsonResponse($json, 200); } else { $this->returnJson("The 'rootNode' parameter is missing.", 500); } } private function getSearchProxy(): SearchProxy { return $this->getServiceLocator()->get(SearchProxy::SERVICE_ID); } private function getResultSetMapper(): ResultSetMapper { return $this->getServiceLocator()->get(ResultSetMapper::SERVICE_ID); } }