diff --git a/webapi/src/main/scala/org/knora/webapi/messages/util/search/gravsearch/transformers/OntologyInferencer.scala b/webapi/src/main/scala/org/knora/webapi/messages/util/search/gravsearch/transformers/OntologyInferencer.scala index 181f037734..0b69c06acf 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/util/search/gravsearch/transformers/OntologyInferencer.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/util/search/gravsearch/transformers/OntologyInferencer.scala @@ -43,7 +43,7 @@ final case class OntologyInferencer( case None => knownSubClasses case Some(relevantOntologyIris) => // filter the known subclasses against the relevant ontologies - knownSubClasses.filter(cache.classDefinedInOntology.get(_).exists(relevantOntologyIris.contains(_))) + knownSubClasses.filter(cache.classDefinedInOntology(_).exists(relevantOntologyIris.contains(_))) } // Searches for a `?v a `, or if multiple subclasses are present, then @@ -68,7 +68,7 @@ final case class OntologyInferencer( // if provided, limit the child properties to those that belong to relevant ontologies val subProps = limitInferenceToOntologies match { case Some(ontologyIris) => - knownSubProps.filter(cache.propertyDefinedInOntology.get(_).exists(ontologyIris.contains(_))) + knownSubProps.filter(cache.propertyDefinedInOntology(_).exists(ontologyIris.contains(_))) case None => knownSubProps } // Searches for a `?v ?b`, or if multiple propertyIRIs are present, then diff --git a/webapi/src/main/scala/org/knora/webapi/slice/ontology/repo/model/OntologyCacheData.scala b/webapi/src/main/scala/org/knora/webapi/slice/ontology/repo/model/OntologyCacheData.scala index c6e152c35e..5257e47ea4 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/ontology/repo/model/OntologyCacheData.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/ontology/repo/model/OntologyCacheData.scala @@ -28,8 +28,8 @@ case class OntologyCacheData( classToSubclassLookup: Map[SmartIri, Set[SmartIri]], subPropertyOfRelations: Map[SmartIri, Set[SmartIri]], superPropertyOfRelations: Map[SmartIri, Set[SmartIri]], - classDefinedInOntology: Map[SmartIri, SmartIri], - propertyDefinedInOntology: Map[SmartIri, SmartIri], + private val classDefinedInOntology: Map[SmartIri, SmartIri], + private val propertyDefinedInOntology: Map[SmartIri, SmartIri], private val entityDefinedInOntology: Map[SmartIri, SmartIri], private val standoffProperties: Set[SmartIri], ) { @@ -44,7 +44,9 @@ case class OntologyCacheData( def getAllStandoffPropertyEntities: Map[SmartIri, ReadPropertyInfoV2] = ontologies.values.flatMap(_.properties.view.filterKeys(standoffProperties)).toMap - def entityDefinedInOntology(propertyIri: SmartIri): Option[SmartIri] = entityDefinedInOntology.get(propertyIri) + def entityDefinedInOntology(propertyIri: SmartIri): Option[SmartIri] = entityDefinedInOntology.get(propertyIri) + def classDefinedInOntology(classIri: SmartIri): Option[SmartIri] = classDefinedInOntology.get(classIri) + def propertyDefinedInOntology(propertyIri: SmartIri): Option[SmartIri] = propertyDefinedInOntology.get(propertyIri) } object OntologyCacheData { val Empty = OntologyCacheData(