Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
OWL2YAMS
Commits
e7a7057acc16
Commit
e7a7057a
authored
Nov 23, 2021
by
Fabien Amarger
Browse files
feat(rdf): Use a dedicated label relation to import rdfs:label values
parent
596de53f30a0
Pipeline
#95652
passed with stages
in 2 minutes and 54 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
owl2yams/ccplugin.py
View file @
e7a7057a
...
...
@@ -91,7 +91,15 @@
relation_type
=
self
.
get_entity_from_uri
(
cnx
,
predicate_uri
,
"CWRType"
)
except
(
NoResultError
,
MultipleResultsError
):
except
NoResultError
:
if
(
predicate_uri
.
toPython
()
==
"http://www.w3.org/2000/01/rdf-schema#label"
):
relation_type
=
cnx
.
find
(
"CWRType"
,
name
=
"label"
).
one
()
else
:
continue
except
MultipleResultsError
:
continue
if
relation_type
.
final
:
temp_attributes
[
relation_type
.
name
]
=
object_value
.
toPython
()
...
...
owl2yams/generate_entities.py
View file @
e7a7057a
...
...
@@ -4,6 +4,7 @@
entities_template
=
jinja2
.
Template
(
"""
from cubicweb.entities import AnyEntity
from cubicweb.entities.adapters import EntityRDFAdapter
from cubicweb.predicates import is_instance
from cubicweb.rdf import NAMESPACES
...
...
@@ -7,7 +8,7 @@
from cubicweb.entities.adapters import EntityRDFAdapter
from cubicweb.predicates import is_instance
from cubicweb.rdf import NAMESPACES
from rdflib import URIRef, OWL
from rdflib import URIRef, OWL
, RDFS
class OWL2YamsGenericRDFAdapter(EntityRDFAdapter):
...
...
@@ -18,9 +19,10 @@
{% for fragment, uri in relationtype_fragment_to_uri.items() %}
yield(NAMESPACES['cubicweb']["{{fragment}}"], OWL.equivalentProperty, URIRef("{{uri}}"))
{% endfor %}
yield(NAMESPACES["cubicweb"]["name"], OWL.equivalentProperty, RDFS.label)
yield from super().triples()
{% for fragment, uri in entitytype_fragment_to_uri.items() %}
class {{fragment}}RDFAdapter(OWL2YamsGenericRDFAdapter):
__select__ = is_instance("{{fragment}}")
__regid__ = "rdf"
...
...
@@ -21,9 +23,16 @@
yield from super().triples()
{% for fragment, uri in entitytype_fragment_to_uri.items() %}
class {{fragment}}RDFAdapter(OWL2YamsGenericRDFAdapter):
__select__ = is_instance("{{fragment}}")
__regid__ = "rdf"
class {{fragment}}(AnyEntity):
def dc_title(self):
if self.label:
return self.label
return super().dc_title()
{% endfor %}
...
...
owl2yams/schema_uri.py
View file @
e7a7057a
...
...
@@ -6,3 +6,10 @@
subject
=
"*"
object
=
(
"ExternalUri"
,)
cardinality
=
"*?"
class
label
(
RelationDefinition
):
subject
=
"*"
object
=
"String"
cardinality
=
"?1"
final
=
True
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment