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
7faa4fabde29
Commit
7faa4fab
authored
Nov 24, 2021
by
Fabien Amarger
Browse files
fix(entities): Use a OWL2YAMSRDFAdapter class and fix CW namespace to use base_url
parent
5986c56080b2
Pipeline
#95846
passed with stages
in 2 minutes and 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
owl2yams/generate_entities.py
View file @
7faa4fab
...
...
@@ -8,5 +8,7 @@
from cubicweb.entities.adapters import EntityRDFAdapter
from cubicweb.predicates import is_instance
from cubicweb.rdf import NAMESPACES
from rdflib import URIRef
from rdflib import URIRef, namespace
from rdflib.namespace import Namespace
...
...
@@ -12,15 +14,3 @@
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() %}
yield(CW["{{fragment}}"], RDFS.subClassOf, URIRef("{{uri}}"))
{% endfor %}
{% for fragment, uri in relationtype_fragment_to_uri.items() %}
yield(CW["{{fragment}}"], RDFS.subPropertyOf, URIRef("{{uri}}"))
{% endfor %}
yield(CW["label"], RDFS.subPropertyOf, RDFS.label)
if self.entity.equivalent_uri:
yield (self.uri, OWL.sameAs, URIRef(self.entity.equivalent_uri[0].uri))
...
...
@@ -26,6 +16,4 @@
{% for fragment, uri in entitytype_fragment_to_uri.items() %}
class {{fragment}}RDFAdapter(EntityRDFAdapter):
__select__ = is_instance("{{fragment}}")
class OWL2YAMSRDFAdapter(EntityRDFAdapter):
__regid__ = "rdf"
...
...
@@ -30,4 +18,6 @@
__regid__ = "rdf"
class {{fragment}}(AnyEntity):
def __init__(self, _cw, **kwargs):
super().__init__(_cw, **kwargs)
NAMESPACES["cubicweb"] = Namespace(self._cw.cnx.base_url())
...
...
@@ -33,8 +23,17 @@
def dc_title(self):
if self.label:
return self.label
return super().dc_title()
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() %}
yield(CW["{{fragment}}"], RDFS.subClassOf, URIRef("{{uri}}"))
{% endfor %}
{% for fragment, uri in relationtype_fragment_to_uri.items() %}
yield(CW["{{fragment}}"], RDFS.subPropertyOf, URIRef("{{uri}}"))
{% endfor %}
yield(CW["label"], RDFS.subPropertyOf, RDFS.label)
if self.entity.equivalent_uri:
yield (self.uri, OWL.sameAs, URIRef(self.entity.equivalent_uri[0].uri))
def filter_rdf_type(self, triples):
RDF = self._use_namespace("rdf")
...
...
@@ -45,4 +44,9 @@
else:
yield triple
{% for fragment, uri in entitytype_fragment_to_uri.items() %}
class {{fragment}}RDFAdapter(OWL2YAMSRDFAdapter):
__select__ = is_instance("{{fragment}}")
def triples(self):
...
...
@@ -48,3 +52,3 @@
def triples(self):
yield from owl2yams_triples(
self
)
yield from
self.
owl2yams_triples()
yield from self.filter_rdf_type(super().triples())
...
...
@@ -50,4 +54,12 @@
yield from self.filter_rdf_type(super().triples())
class {{fragment}}(AnyEntity):
def dc_title(self):
if self.label:
return self.label
return super().dc_title()
{% endfor %}
...
...
@@ -51,8 +63,8 @@
{% endfor %}
class CWETypeOWL2YAMSRDFAdapter(
Entity
RDFAdapter):
class CWETypeOWL2YAMSRDFAdapter(
OWL2YAMS
RDFAdapter):
__select__ = is_instance("CWEType")
__regid__ = "rdf"
def triples(self):
...
...
@@ -55,8 +67,8 @@
__select__ = is_instance("CWEType")
__regid__ = "rdf"
def triples(self):
yield from owl2yams_triples(
self
)
yield from
self.
owl2yams_triples()
yield from super().triples()
...
...
@@ -60,8 +72,8 @@
yield from super().triples()
class CWRTypeOWL2YAMSRDFAdapter(
Entity
RDFAdapter):
class CWRTypeOWL2YAMSRDFAdapter(
OWL2YAMS
RDFAdapter):
__select__ = is_instance("CWRType")
__regid__ = "rdf"
def triples(self):
...
...
@@ -64,8 +76,8 @@
__select__ = is_instance("CWRType")
__regid__ = "rdf"
def triples(self):
yield from owl2yams_triples(
self
)
yield from
self.
owl2yams_triples()
yield from super().triples()
...
...
Write
Preview
Markdown
is supported
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