author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Fri, 30 Jan 2009 16:57:20 +0100 | |
changeset 543 | c0f2b6378f70 |
parent 537 | f16da6c874da |
child 550 | 2300370b8edd |
permissions | -rw-r--r-- |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
1 |
from logilab.mtconverter import html_escape |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
2 |
|
503
a2fca6cdc5ff
OWLView correction (namespace)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
502
diff
changeset
|
3 |
#from cubicweb.common.uilib import ureport_as_html, unormalize, ajax_replace_url |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
4 |
from cubicweb.common.view import StartupView |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
5 |
from cubicweb.common.view import EntityView |
503
a2fca6cdc5ff
OWLView correction (namespace)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
502
diff
changeset
|
6 |
#from cubicweb.web.httpcache import EtagHTTPCacheManager |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
7 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
8 |
_ = unicode |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
9 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
10 |
OWL_CARD_MAP = {'1': '<rdf:type rdf:resource="&owl;FunctionalProperty"/>', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
11 |
'?': '<owl:maxCardinality rdf:datatype="&xsd;int">1</owl:maxCardinality>', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
12 |
'+': '<owl:minCardinality rdf:datatype="&xsd;int">1</owl:minCardinality>', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
13 |
'*': '' |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
14 |
} |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
15 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
16 |
OWL_CARD_MAP_DATA = {'String': 'xsd:string', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
17 |
'Datetime': 'xsd:dateTime', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
18 |
'Bytes': 'xsd:byte', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
19 |
'Float': 'xsd:float', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
20 |
'Boolean': 'xsd:boolean', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
21 |
'Int': 'xsd:int', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
22 |
'Date':'xsd:date', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
23 |
'Time': 'xsd:time', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
24 |
'Password': 'xsd:byte', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
25 |
'Decimal' : 'xsd:decimal', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
26 |
'Interval': 'xsd:duration' |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
27 |
} |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
28 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
29 |
class OWLView(StartupView): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
30 |
id = 'owl' |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
31 |
title = _('owl') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
32 |
templatable =False |
537
f16da6c874da
small corrections
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
517
diff
changeset
|
33 |
content_type = 'application/xml' # 'text/xml' |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
34 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
35 |
def call(self): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
36 |
skipmeta = int(self.req.form.get('skipmeta', True)) |
506
f60de0a5ef95
cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
503
diff
changeset
|
37 |
self.visit_schema(display_relations=True, |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
38 |
skiprels=('is', 'is_instance_of', 'identity', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
39 |
'owned_by', 'created_by'), |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
40 |
skipmeta=skipmeta) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
41 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
42 |
|
506
f60de0a5ef95
cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
503
diff
changeset
|
43 |
def visit_schema(self, display_relations=0, |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
44 |
skiprels=(), skipmeta=True): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
45 |
"""get a layout for a whole schema""" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
46 |
self.w(u'''<?xml version="1.0" encoding="UTF-8"?> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
47 |
<!DOCTYPE rdf:RDF [ |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
48 |
<!ENTITY owl "http://www.w3.org/2002/07/owl#" > |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
49 |
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
50 |
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" > |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
51 |
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" > |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
52 |
<!ENTITY %s "http://logilab.org/owl/ontologies/%s#" > |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
53 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
54 |
]> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
55 |
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
56 |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
57 |
xmlns:xsd="http://www.w3.org/2001/XMLSchema#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
58 |
xmlns:owl="http://www.w3.org/2002/07/owl#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
59 |
xmlns="http://logilab.org/owl/ontologies/%s#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
60 |
xmlns:%s="http://logilab.org/owl/ontologies/%s#" |
503
a2fca6cdc5ff
OWLView correction (namespace)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
502
diff
changeset
|
61 |
xmlns:base="http://logilab.org/owl/ontologies/%s"> |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
62 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
63 |
<owl:Ontology rdf:about=""> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
64 |
<rdfs:comment> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
65 |
%s Cubicweb OWL Ontology |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
66 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
67 |
</rdfs:comment> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
68 |
</owl:Ontology> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
69 |
''' % (self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name)) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
70 |
entities = [eschema for eschema in self.schema.entities() |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
71 |
if not eschema.is_final()] |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
72 |
if skipmeta: |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
73 |
entities = [eschema for eschema in entities |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
74 |
if not eschema.meta] |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
75 |
keys = [(eschema.type, eschema) for eschema in entities] |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
76 |
self.w(u'<!-- classes definition -->') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
77 |
for key, eschema in sorted(keys): |
506
f60de0a5ef95
cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
503
diff
changeset
|
78 |
self.visit_entityschema(eschema, skiprels) |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
79 |
self.w(u'<!-- property definition -->') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
80 |
self.w(u'<!-- object property -->') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
81 |
for key, eschema in sorted(keys): |
506
f60de0a5ef95
cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
503
diff
changeset
|
82 |
self.visit_property_schema(eschema, skiprels) |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
83 |
self.w(u'<!-- datatype property -->') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
84 |
for key, eschema in sorted(keys): |
506
f60de0a5ef95
cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
503
diff
changeset
|
85 |
self.visit_property_object_schema(eschema, skiprels) |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
86 |
self.w(u'</rdf:RDF>') |
506
f60de0a5ef95
cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
503
diff
changeset
|
87 |
|
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
88 |
def stereotype(self, name): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
89 |
return Span((' <<%s>>' % name,), klass='stereotype') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
90 |
|
506
f60de0a5ef95
cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
503
diff
changeset
|
91 |
def visit_entityschema(self, eschema, skiprels=()): |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
92 |
"""get a layout for an entity OWL schema""" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
93 |
etype = eschema.type |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
94 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
95 |
if eschema.meta: |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
96 |
self.stereotype('meta') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
97 |
self.w(u'''<owl:Class rdf:ID="%s"><rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
98 |
'''%eschema, stereotype) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
99 |
else: |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
100 |
self.w(u'''<owl:Class rdf:ID="%s"><rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
101 |
'''% eschema) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
102 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
103 |
self.w(u'<!-- relations -->') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
104 |
for rschema, targetschemas, role in eschema.relation_definitions(): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
105 |
if rschema.type in skiprels: |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
106 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
107 |
if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
108 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
109 |
for oeschema in targetschemas: |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
110 |
label = rschema.type |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
111 |
if role == 'subject': |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
112 |
card = rschema.rproperty(eschema, oeschema, 'cardinality')[0] |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
113 |
else: |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
114 |
card = rschema.rproperty(oeschema, eschema, 'cardinality')[1] |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
115 |
self.w(u'''<rdfs:subClassOf> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
116 |
<owl:Restriction> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
117 |
<owl:onProperty rdf:resource="#%s"/> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
118 |
%s |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
119 |
</owl:Restriction> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
120 |
</rdfs:subClassOf> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
121 |
''' % (label, OWL_CARD_MAP[card])) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
122 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
123 |
self.w(u'<!-- attributes -->') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
124 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
125 |
for rschema, aschema in eschema.attribute_definitions(): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
126 |
if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
127 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
128 |
aname = rschema.type |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
129 |
if aname == 'eid': |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
130 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
131 |
card_data = aschema.type |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
132 |
self.w(u'''<rdfs:subClassOf> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
133 |
<owl:Restriction> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
134 |
<owl:onProperty rdf:resource="#%s"/> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
135 |
<rdf:type rdf:resource="&owl;FunctionalProperty"/> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
136 |
</owl:Restriction> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
137 |
</rdfs:subClassOf>''' |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
138 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
139 |
% aname) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
140 |
self.w(u'</owl:Class>') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
141 |
|
506
f60de0a5ef95
cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
503
diff
changeset
|
142 |
def visit_property_schema(self, eschema, skiprels=()): |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
143 |
"""get a layout for property entity OWL schema""" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
144 |
etype = eschema.type |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
145 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
146 |
for rschema, targetschemas, role in eschema.relation_definitions(): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
147 |
if rschema.type in skiprels: |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
148 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
149 |
if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
150 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
151 |
for oeschema in targetschemas: |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
152 |
label = rschema.type |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
153 |
self.w(u'''<owl:ObjectProperty rdf:ID="%s"> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
154 |
<rdfs:domain rdf:resource="#%s"/> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
155 |
<rdfs:range rdf:resource="#%s"/> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
156 |
</owl:ObjectProperty> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
157 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
158 |
''' % (label, eschema, oeschema.type )) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
159 |
|
506
f60de0a5ef95
cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
503
diff
changeset
|
160 |
def visit_property_object_schema(self, eschema, skiprels=()): |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
161 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
162 |
for rschema, aschema in eschema.attribute_definitions(): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
163 |
if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
164 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
165 |
aname = rschema.type |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
166 |
if aname == 'eid': |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
167 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
168 |
card_data = aschema.type |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
169 |
self.w(u'''<owl:DatatypeProperty rdf:ID="%s"> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
170 |
<rdfs:domain rdf:resource="#%s"/> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
171 |
<rdfs:range rdf:resource="%s"/> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
172 |
</owl:DatatypeProperty>''' |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
173 |
% (aname, eschema, OWL_CARD_MAP_DATA[card_data])) |
506
f60de0a5ef95
cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
503
diff
changeset
|
174 |
|
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
175 |
class OWLABOXView(EntityView): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
176 |
id = 'owlabox' |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
177 |
title = _('owlabox') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
178 |
templatable =False |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
179 |
accepts = ('Any',) |
537
f16da6c874da
small corrections
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
517
diff
changeset
|
180 |
content_type = 'application/xml' # 'text/xml' |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
181 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
182 |
def call(self): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
183 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
184 |
skipmeta = int(self.req.form.get('skipmeta', True)) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
185 |
self.w(u'''<?xml version="1.0" encoding="UTF-8"?> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
186 |
<!DOCTYPE rdf:RDF [ |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
187 |
<!ENTITY owl "http://www.w3.org/2002/07/owl#" > |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
188 |
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
189 |
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" > |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
190 |
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" > |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
191 |
<!ENTITY %s "http://logilab.org/owl/ontologies/%s#" > |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
192 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
193 |
]> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
194 |
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
195 |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
196 |
xmlns:xsd="http://www.w3.org/2001/XMLSchema#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
197 |
xmlns:owl="http://www.w3.org/2002/07/owl#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
198 |
xmlns="http://logilab.org/owl/ontologies/%s#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
199 |
xmlns:%s="http://logilab.org/owl/ontologies/%s#" |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
200 |
xmlns:base="http://logilab.org/owl/ontologies/%s"> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
201 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
202 |
<owl:Ontology rdf:about=""> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
203 |
<rdfs:comment> |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
204 |
%s Cubicweb OWL Ontology |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
205 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
206 |
</rdfs:comment> |
512 | 207 |
</owl:Ontology>''' % (self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, |
208 |
self.schema.name, self.schema.name)) |
|
209 |
||
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
210 |
for i in xrange(self.rset.rowcount): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
211 |
self.cell_call(i, 0, skiprels=('is', 'is_instance_of', 'identity', |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
212 |
'owned_by', 'created_by'), |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
213 |
skipmeta=skipmeta) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
214 |
self.w(u'</rdf:RDF>') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
215 |
|
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
216 |
def cell_call(self, row, col, skiprels=(), skipmeta=True): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
217 |
entity = self.complete_entity(row, col) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
218 |
eschema = entity.e_schema |
516 | 219 |
self.w(u'<%s rdf:ID="%s">' % (eschema, entity.eid)) |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
220 |
self.w(u'<!--attributes-->') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
221 |
for rschema, aschema in eschema.attribute_definitions(): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
222 |
if rschema.type in skiprels: |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
223 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
224 |
if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
225 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
226 |
aname = rschema.type |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
227 |
if aname == 'eid': |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
228 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
229 |
attr = getattr(entity, aname) |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
230 |
if attr is not None: |
516 | 231 |
self.w(u'<%s>%s</%s>' % (aname, html_escape(unicode(attr)), aname)) |
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
232 |
self.w(u'<!--relations -->') |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
233 |
for rschema, targetschemas, role in eschema.relation_definitions(): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
234 |
if rschema.type in skiprels: |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
235 |
continue |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
236 |
if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')): |
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
237 |
continue |
516 | 238 |
if role == 'object': |
239 |
attr = 'reverse_%s' % rschema.type |
|
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
240 |
else: |
516 | 241 |
attr = rschema.type |
517 | 242 |
for x in getattr(entity, attr): |
516 | 243 |
self.w(u'<%s>%s %s</%s>' % (attr, x.id, x.eid, attr)) |
244 |
self.w(u'</%s>'% eschema) |
|
502
7882941d3530
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff
changeset
|
245 |