Commit ea52d351 authored by Fabien Amarger's avatar Fabien Amarger
Browse files

[rdf] Move SIOC namespace to entities.py

Btw introduce SIOCT types
parent cb3adef19cb0
......@@ -9,7 +9,7 @@
from logilab.common.date import todate
from rdflib import URIRef, Literal
from rdflib import URIRef, Literal, Namespace
from cubicweb.entities import AnyEntity, fetch_config
from cubicweb.entities.adapters import (
......@@ -17,6 +17,11 @@ from cubicweb.entities.adapters import (
)
from cubicweb.view import EntityAdapter
from cubicweb.predicates import is_instance
from cubicweb.rdf import NAMESPACES
NAMESPACES["sioc"] = Namespace("http://rdfs.org/sioc/ns#")
NAMESPACES["sioct"] = Namespace("http://rdfs.org/sioc/types#")
NAMESPACES["dcterms"] = Namespace("http://purl.org/dc/terms/")
__docformat__ = "restructuredtext en"
......@@ -37,10 +42,11 @@ class BlogRDFAdapter(EntityRDFAdapter):
def triples(self):
SIOC = self._use_namespace("sioc")
SIOCT = self._use_namespace("sioct")
RDF = self._use_namespace("rdf")
DCTERMS = self._use_namespace("dcterms")
uri = URIRef(self.uri)
yield (uri, RDF.type, SIOC.Weblog)
yield (uri, RDF.type, SIOCT.Weblog)
yield (uri, DCTERMS.title, Literal(self.entity.dc_title()))
yield (uri, DCTERMS.description, Literal(self.entity.description))
yield (uri, SIOC.num_items, Literal(len(self.entity.reverse_entry_of)))
......@@ -59,10 +65,11 @@ class BlogEntryRDFAdapter(EntityRDFAdapter):
def triples(self):
SIOC = self._use_namespace("sioc")
SIOCT = self._use_namespace("sioct")
RDF = self._use_namespace("rdf")
DCTERMS = self._use_namespace("dcterms")
uri = URIRef(self.uri)
yield (uri, RDF.type, SIOC.BlogPost)
yield (uri, RDF.type, SIOCT.BlogPost)
yield (uri, DCTERMS.title, Literal(self.entity.dc_title()))
yield (uri, DCTERMS.date, Literal(self.entity.creation_date))
yield (uri, DCTERMS.modified, Literal(self.entity.modification_date))
......@@ -79,10 +86,10 @@ class MicroBlogRDFAdapter(BlogRDFAdapter):
def triples(self):
yield from super().triples()
SIOC = self._use_namespace("sioc")
SIOCT = self._use_namespace("sioct")
RDF = self._use_namespace("rdf")
uri = URIRef(self.uri)
yield(uri, RDF.type, SIOC.Microblog)
yield(uri, RDF.type, SIOCT.Microblog)
class MicroBlogEntryRDFAdapter(BlogEntryRDFAdapter):
......@@ -91,10 +98,10 @@ class MicroBlogEntryRDFAdapter(BlogEntryRDFAdapter):
def triples(self):
yield from super().triples()
SIOC = self._use_namespace("sioc")
SIOCT = self._use_namespace("sioct")
RDF = self._use_namespace("rdf")
uri = URIRef(self.uri)
yield (uri, RDF.type, SIOC.MicroblogPost)
yield (uri, RDF.type, SIOCT.MicroblogPost)
###################################################
......
#!/usr/bin/env python3
# coding: utf-8
from rdflib import Namespace
from cubicweb.rdf import NAMESPACES
NAMESPACES["sioc"] = Namespace("http://rdfs.org/sioc/types#")
NAMESPACES["dcterms"] = Namespace("http://purl.org/dc/terms/")
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