Skip to content
Snippets Groups Projects
Commit a67e6e04 authored by Romin's avatar Romin :eye:
Browse files

Fix invalid AP target class

parent e16e210e
Branches
Tags
No related merge requests found
......@@ -725,11 +725,26 @@ class ApplicationProfile(ApplicationProfileInfo):
self.graph.bind("sh", "http://www.w3.org/ns/shacl#")
self.graph.bind("dcterms", "http://purl.org/dc/terms/")
self.graph.parse(data=self.definition, format="ttl")
self._resolve_imports() # FIXME/TODO Is this ok?
self._determine_target_class()
self._resolve_imports()
def __str__(self) -> str:
return str(self.graph.serialize(format="ttl"))
def _determine_target_class(self) -> None:
"""
Figures out the target class of the application profile.
If not target class is present, the application profile URI is used
as a fallback.
"""
results = self.query(
r"SELECT ?targetClass WHERE { ?_ sh:targetClass ?targetClass . }"
)
if len(results) != 1 or len(results[0]) != 1:
self._target_class = self.uri
else:
self._target_class = results[0][0]
def _resolve_imports(self) -> None:
"""
Recursively resolves owl:imports statements
......@@ -750,15 +765,10 @@ class ApplicationProfile(ApplicationProfileInfo):
def target_class(self) -> str:
"""
Returns the target class of the application profile.
If not target class is present, the application profile URI is used
If no target class is present, the application profile URI is used
as a fallback.
"""
results = self.query(
r"SELECT ?targetClass WHERE { ?_ sh:targetClass ?targetClass . }"
)
if len(results) != 1 or len(results[0]) != 1:
return self.uri
return results[0][0]
return self._target_class
def query(self, query: str, **kwargs) -> list:
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment