Commit e7a7057a authored by Fabien Amarger's avatar 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
......@@ -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()
......
......@@ -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 %}
......
......@@ -6,3 +6,10 @@
subject = "*"
object = ("ExternalUri",)
cardinality = "*?"
class label(RelationDefinition):
subject = "*"
object = "String"
cardinality = "?1"
final = True
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment