Commit 5986c560 authored by Fabien Amarger's avatar Fabien Amarger
Browse files

fix(entities): Change the default rdf type triple with the cwuri from CWEtype

The e_schema.type was something like "http://ns.cubicweb.org/v1/FirstClass" which is not
referencable. Using the base-url instead is the best way to have a referencable URI
parent 818aeb7115a7
......@@ -347,7 +347,8 @@
all_in_one_path.write_text(
all_in_one_content.replace(
"#anonymous-user=", f"anonymous-user={os.environ['CW_ANONYMOUS_USER']}"
).replace(
)
.replace(
"#anonymous-password=",
f"anonymous-password={os.environ['CW_ANONYMOUS_PASSWORD']}",
)
......@@ -351,6 +352,7 @@
"#anonymous-password=",
f"anonymous-password={os.environ['CW_ANONYMOUS_PASSWORD']}",
)
.replace("#base-url=", f"base-url={args.base_url}")
)
create_db_instance = (
......
......@@ -10,7 +10,6 @@
from cubicweb.rdf import NAMESPACES
from rdflib import URIRef
def owl2yams_triples(self):
OWL = self._use_namespace("owl")
CW = self._use_namespace("cubicweb")
......@@ -24,7 +23,6 @@
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() %}
class {{fragment}}RDFAdapter(EntityRDFAdapter):
......@@ -38,5 +36,14 @@
return self.label
return super().dc_title()
def filter_rdf_type(self, triples):
RDF = self._use_namespace("rdf")
CW = self._use_namespace("cubicweb")
for triple in triples:
if triple == (self.uri, RDF.type, CW[self.entity.e_schema.type]):
yield (self.uri, RDF.type, URIRef(self.entity.is_instance_of[0].cwuri))
else:
yield triple
def triples(self):
yield from owl2yams_triples(self)
......@@ -41,5 +48,6 @@
def triples(self):
yield from owl2yams_triples(self)
yield from self.filter_rdf_type(super().triples())
{% endfor %}
......
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