# Title: 
#    No CCO Class Should Be Outside the BFO Hierarchy
# Constraint Description: 
#     All CCO classes must have a BFO superclass.
# Severity:
#     Error
# Author:
#	 github.com/neilotte

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?class ?label
WHERE {
?class a owl:Class .
FILTER (regex(str(?class),"http://www.ontologyrepository.com/CommonCoreOntologies/"))
FILTER NOT EXISTS {?class rdfs:subClassOf+ <http://purl.obolibrary.org/obo/BFO_0000001> }
OPTIONAL {?class rdfs:label ?label}
}
