@ Subscribe @ AllowConcurrentEvents public synchronized void handleOntologyDeleted ( OntologyDeletedEvent event ) { log . info ( "Processing Ontology Deleted Event - {}" , event . getOntologyUri ( ) ) ; // Obtain all concepts in the KB Set < URI > conceptUris = this . manager . getKnowledgeBaseManager ( ) . listConcepts ( null ) ; // Cross reference them with those for which we have entries. The ones unmatched were defined in the previous // ontology (note that tse of namespaces could be abused and therefore may not be a guarantee). Set < URI > difference = Sets . difference ( conceptUris , this . indexedMatches . keySet ( ) ) ; for ( URI conceptUri : difference ) { this . indexedMatches . remove ( conceptUri ) ; } for ( URI indexedConcept : indexedMatches . keySet ( ) ) { Map < URI , MatchResult > matchResultMap = indexedMatches . get ( indexedConcept ) ; for ( URI conceptUri : difference ) { matchResultMap . remove ( conceptUri ) ; } indexedMatches . put ( indexedConcept , new ConcurrentHashMap < URI , MatchResult > ( matchResultMap ) ) ; } }
An ontology has been deleted from the KB and we should thus update the indexes . By the time we want to process this event we won t know any longer which concepts need to be removed unless we keep this somewhere .