Commit 9af5ea80 authored by Fabien Amarger's avatar Fabien Amarger
Browse files

fix(entities): Add rdf adapters for CWEType and CWRType

parent b3563c5b8ea1
......@@ -253,7 +253,7 @@
)
create_cube = (
f"cubicweb-ctl newcube {args.instance_name}"
' -s "cube representating {args.owl_model}"'
' -s "cube representing {args.owl_model}"'
)
run_and_print_if_error(create_cube)
......
......@@ -11,9 +11,8 @@
from rdflib import URIRef
class OWL2YamsGenericRDFAdapter(EntityRDFAdapter):
def triples(self):
OWL = self._use_namespace("owl")
CW = self._use_namespace("cubicweb")
RDFS = self._use_namespace("rdfs")
def owl2yams_triples(self):
OWL = self._use_namespace("owl")
CW = self._use_namespace("cubicweb")
RDFS = self._use_namespace("rdfs")
{% for fragment, uri in entitytype_fragment_to_uri.items() %}
......@@ -19,4 +18,4 @@
{% for fragment, uri in entitytype_fragment_to_uri.items() %}
yield(CW["{{fragment}}"], RDFS.subClassOf, URIRef("{{uri}}"))
yield(CW["{{fragment}}"], RDFS.subClassOf, URIRef("{{uri}}"))
{% endfor %}
{% for fragment, uri in relationtype_fragment_to_uri.items() %}
......@@ -21,4 +20,4 @@
{% endfor %}
{% for fragment, uri in relationtype_fragment_to_uri.items() %}
yield(CW["{{fragment}}"], RDFS.subPropertyOf, URIRef("{{uri}}"))
yield(CW["{{fragment}}"], RDFS.subPropertyOf, URIRef("{{uri}}"))
{% endfor %}
......@@ -24,8 +23,7 @@
{% endfor %}
yield(CW["label"], RDFS.subPropertyOf, RDFS.label)
if self.entity.equivalent_uri:
yield(CW["equivalent_uri"], RDFS.subPropertyOf, OWL.sameAs)
yield (self.uri, OWL.sameAs, URIRef(self.entity.equivalent_uri[0].uri))
yield from super().triples()
yield(CW["label"], RDFS.subPropertyOf, RDFS.label)
if self.entity.equivalent_uri:
yield (self.uri, OWL.sameAs, URIRef(self.entity.equivalent_uri[0].uri))
yield from super().triples()
{% for fragment, uri in entitytype_fragment_to_uri.items() %}
......@@ -30,6 +28,6 @@
{% for fragment, uri in entitytype_fragment_to_uri.items() %}
class {{fragment}}RDFAdapter(OWL2YamsGenericRDFAdapter):
class {{fragment}}RDFAdapter(EntityRDFAdapter):
__select__ = is_instance("{{fragment}}")
__regid__ = "rdf"
......@@ -39,6 +37,9 @@
if self.label:
return self.label
return super().dc_title()
def triples(self):
yield from owl2yams_triples(self)
{% endfor %}
......@@ -42,6 +43,24 @@
{% endfor %}
class CWETypeOWL2YAMSRDFAdapter(EntityRDFAdapter):
__select__ = is_instance("CWEType")
__regid__ = "rdf"
def triples(self):
yield from owl2yams_triples(self)
yield from super().triples()
class CWRTypeOWL2YAMSRDFAdapter(EntityRDFAdapter):
__select__ = is_instance("CWRType")
__regid__ = "rdf"
def triples(self):
yield from owl2yams_triples(self)
yield from super().triples()
def registration_callback(vreg):
vreg.register_all(globals().values(), __name__, ())
......
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