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
9af5ea80be28
Commit
9af5ea80
authored
Nov 19, 2021
by
Fabien Amarger
Browse files
fix(entities): Add rdf adapters for CWEType and CWRType
parent
b3563c5b8ea1
Changes
2
Hide whitespace changes
Inline
Side-by-side
owl2yams/__init__.py
View file @
9af5ea80
...
...
@@ -253,7 +253,7 @@
)
create_cube
=
(
f
"cubicweb-ctl newcube
{
args
.
instance_name
}
"
' -s "cube represent
at
ing {args.owl_model}"'
' -s "cube representing {args.owl_model}"'
)
run_and_print_if_error
(
create_cube
)
...
...
owl2yams/generate_entities.py
View file @
9af5ea80
...
...
@@ -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(
OWL2YamsGeneric
RDFAdapter):
class {{fragment}}RDFAdapter(
Entity
RDFAdapter):
__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__, ())
...
...
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