public function getIndexes() { if ($this->hasRequestParameter('rootNode') === true) { $rootNodeUri = $this->getRequestParameter('rootNode'); $indexes = IndexService::getIndexesByClass(new core_kernel_classes_Class($rootNodeUri)); $json = array(); foreach ($indexes as $propertyUri => $index) { foreach ($index as $i) { $json[] = array('identifier' => $i->getIdentifier(), 'fuzzyMatching' => $i->isFuzzyMatching(), 'propertyId' => $propertyUri); } } $this->returnJson($json, 200); } else { $this->returnJson("The 'rootNode' parameter is missing.", 500); } }
/** * @depends testCreateIndex */ public function testCreateSimilar($index) { $this->assertIsA($index, 'oat\\tao\\model\\search\\Index'); $tokenizer = new core_kernel_classes_Resource(RawValue::URI); $similar = IndexService::createIndex($this->property, substr($index->getIdentifier(), 0, -2), $tokenizer, true, true); $this->assertIsA($similar, 'oat\\tao\\model\\search\\Index'); return $similar; }
protected function savePropertyIndex($indexValues) { $values = array(); foreach ($indexValues as $key => $value) { $values[tao_helpers_Uri::decode($key)] = tao_helpers_Uri::decode($value); } $validator = new tao_helpers_form_validators_IndexIdentifier(); // if the identifier is valid $values[INDEX_PROPERTY_IDENTIFIER] = strtolower($values[INDEX_PROPERTY_IDENTIFIER]); if (!$validator->evaluate($values[INDEX_PROPERTY_IDENTIFIER])) { throw new Exception($validator->getMessage()); } //if the property exists edit it, else create one $existingIndex = \oat\tao\model\search\IndexService::getIndexById($values[INDEX_PROPERTY_IDENTIFIER]); $indexProperty = new core_kernel_classes_Property($values['uri']); if (!is_null($existingIndex) && !$existingIndex->equals($indexProperty)) { throw new Exception("The index identifier should be unique"); } unset($values['uri']); $this->bindProperties($indexProperty, $values); }