isSubClassOf($this->getClass(TaoOntology::CLASS_URI_LIST)) && $listClass->getUri() !== tao_models_classes_LanguageService::CLASS_URI_LANGUAGES; } public function getListElement(RdfClass $listClass, $uri) { $request = new ValueCollectionSearchRequest(); $request->setValueCollectionUri($listClass->getUri())->setUris($uri); $result = $this->getValueService()->findAll( new ValueCollectionSearchInput($request) ); return $result->count() === 0 ? null : iterator_to_array($result->getIterator())[0]; } public function getListElements(RdfClass $listClass, $sort = true, $limit = 0) { $request = new ValueCollectionSearchRequest(); $request->setValueCollectionUri($listClass->getUri()); if ($limit) { $request->setLimit($limit); } $result = $this->getValueService()->findAll( new ValueCollectionSearchInput($request) ); return $result->getIterator(); } /** * @param RdfClass $listClass * * @return bool */ public function removeList(RdfClass $listClass) { $this->getValueService()->delete( new ValueCollectionDeleteInput($listClass->getUri()) ); if ($this->isRemote($listClass)) { $this->getParentPropertyListCachedRepository()->deleteCache( [ 'listUri' => $listClass->getUri() ] ); } return $listClass->delete(); } public function createListElement(RdfClass $listClass, $label = '') { $newUri = $this->createUri(); $valueCollection = new ValueCollection( $listClass->getUri(), new Value(null, $newUri, $label) ); $this->getValueService()->persist($valueCollection); } private function getValueService(): ValueCollectionService { return $this->getServiceLocator()->get(ValueCollectionService::class); } private function createUri(): string { return $this->getServiceLocator()->get(UriProvider::class)->provide(); } /** * @param RdfClass $listClass * * @return bool * @throws core_kernel_persistence_Exception */ public function isRemote(RdfClass $listClass): bool { $type = $listClass->getOnePropertyValue( $listClass->getProperty(RemoteSourcedListOntology::PROPERTY_LIST_TYPE) ); return $type && ($type->getUri() === RemoteSourcedListOntology::LIST_TYPE_REMOTE); } private function getParentPropertyListCachedRepository(): ParentPropertyListCachedRepository { return $this->getServiceLocator()->get(ParentPropertyListCachedRepository::class); } }