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

Use target_class instead of uri as default

parent c424ad41
No related branches found
No related tags found
No related merge requests found
......@@ -659,6 +659,20 @@ class ApplicationProfile(ApplicationProfileInfo):
profile = self.client.application_profile(str(row[0]))
self.graph += profile.graph
@property
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
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]
def query(self, query: str, **kwargs) -> list:
"""
Performs a SPARQL query on the application profile and
......@@ -1005,7 +1019,7 @@ class MetadataForm:
graph.add((
root,
rdflib.RDF.type,
rdflib.URIRef(self.resource.application_profile.uri)
rdflib.URIRef(self.resource.application_profile.target_class)
))
for field in self._fields:
if field.values:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment