author | Nicolas Chauvat <nicolas.chauvat@logilab.fr> |
Sun, 08 Nov 2009 19:37:08 +0100 | |
branch | stable |
changeset 3807 | 8ae53322ffcc |
parent 3689 | deb13e88e037 |
child 3720 | 5376aaadd16b |
child 3877 | 7ca53fc72a0a |
child 4212 | ab6573088b4a |
permissions | -rw-r--r-- |
984 | 1 |
"""produces some Ontology Web Language schema and views |
2 |
||
3 |
:organization: Logilab |
|
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
4 |
:copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
984 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
984 | 7 |
""" |
8 |
__docformat__ = "restructuredtext en" |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
9 |
_ = unicode |
984 | 10 |
|
814 | 11 |
from logilab.mtconverter import TransformError, xml_escape |
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
|
12 |
|
984 | 13 |
from cubicweb.view import StartupView, EntityView |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
14 |
from cubicweb.selectors import none_rset, match_view |
1263 | 15 |
from cubicweb.web.action import Action |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
16 |
from cubicweb.web.views import schema |
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
|
17 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
18 |
OWL_CARD_MAP = {'1': '<rdf:type rdf:resource="&owl;FunctionalProperty"/>', |
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
|
19 |
'?': '<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
|
20 |
'+': '<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
|
21 |
'*': '' |
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 |
} |
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 |
|
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
24 |
OWL_TYPE_MAP = {'String': 'xsd:string', |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
25 |
'Datetime': 'xsd:dateTime', |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
26 |
'Bytes': 'xsd:byte', |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
27 |
'Float': 'xsd:float', |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
28 |
'Boolean': 'xsd:boolean', |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
29 |
'Int': 'xsd:int', |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
30 |
'Date':'xsd:date', |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
31 |
'Time': 'xsd:time', |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
32 |
'Password': 'xsd:byte', |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
33 |
'Decimal' : 'xsd:decimal', |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
34 |
'Interval': 'xsd:duration' |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
35 |
} |
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
|
36 |
|
550
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
37 |
OWL_OPENING_ROOT = u'''<?xml version="1.0" encoding="UTF-8"?> |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
38 |
<!DOCTYPE rdf:RDF [ |
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
|
39 |
<!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
|
40 |
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" > |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
41 |
]> |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
42 |
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
43 |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
44 |
xmlns:xsd="http://www.w3.org/2001/XMLSchema#" |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
45 |
xmlns:owl="http://www.w3.org/2002/07/owl#" |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
46 |
xmlns="http://logilab.org/owl/ontologies/%(appid)s#" |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
47 |
xmlns:%(appid)s="http://logilab.org/owl/ontologies/%(appid)s#" |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
48 |
xmlns:base="http://logilab.org/owl/ontologies/%(appid)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
|
49 |
|
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
50 |
<owl:Ontology rdf:about=""> |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
51 |
<rdfs:comment> |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
52 |
%(appid)s Cubicweb OWL Ontology |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
53 |
</rdfs:comment> |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
54 |
</owl:Ontology>''' |
550
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
55 |
|
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
56 |
OWL_CLOSING_ROOT = u'</rdf:RDF>' |
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
57 |
|
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
58 |
|
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
59 |
class OWLView(StartupView): |
551 | 60 |
"""This view export in owl format schema database. It is the TBOX""" |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
61 |
id = 'owl' |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
62 |
title = _('owl') |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
63 |
templatable = False |
550
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
64 |
content_type = 'application/xml' # 'text/xml' |
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
65 |
|
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
66 |
def call(self, writeprefix=True): |
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
67 |
skipmeta = int(self.req.form.get('skipmeta', True)) |
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
68 |
if writeprefix: |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
69 |
self.w(OWL_OPENING_ROOT % {'appid': self.schema.name}) |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
70 |
self.visit_schema(skiptypes=skipmeta and schema.SKIP_TYPES or ()) |
550
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
71 |
if writeprefix: |
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
72 |
self.w(OWL_CLOSING_ROOT) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
73 |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
74 |
def should_display_rschema(self, rschema): |
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
75 |
return not rschema in self.skiptypes and ( |
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
76 |
rschema.has_local_role('read') or |
2186 | 77 |
rschema.has_perm(self.req, 'read')) |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
78 |
|
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
79 |
def visit_schema(self, skiptypes): |
550
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
80 |
"""get a layout for a whole schema""" |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
81 |
self.skiptypes = skiptypes |
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
82 |
entities = sorted(eschema for eschema in self.schema.entities() |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2295
diff
changeset
|
83 |
if not eschema.final or eschema in skiptypes) |
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
|
84 |
self.w(u'<!-- classes definition -->') |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
85 |
for eschema in entities: |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
86 |
self.visit_entityschema(eschema) |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
87 |
self.w(u'<!-- property definition -->') |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
88 |
self.visit_property_schema(eschema) |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
89 |
self.w(u'<!-- datatype property -->') |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
90 |
self.visit_property_object_schema(eschema) |
674 | 91 |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
92 |
def visit_entityschema(self, 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
|
93 |
"""get a layout for an entity OWL schema""" |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
94 |
self.w(u'<owl:Class rdf:ID="%s">'% eschema) |
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
95 |
self.w(u'<!-- relations -->') |
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
|
96 |
for rschema, targetschemas, role in eschema.relation_definitions(): |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
97 |
if not self.should_display_rschema(rschema): |
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
|
98 |
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
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
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
|
103 |
card = rschema.rproperty(oeschema, eschema, 'cardinality')[1] |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
104 |
cardtag = OWL_CARD_MAP[card] |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
105 |
if cardtag: |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
106 |
self.w(u'''<rdfs:subClassOf> |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
107 |
<owl:Restriction> |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
108 |
<owl:onProperty rdf:resource="#%s"/> |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
109 |
%s |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
110 |
</owl:Restriction> |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
111 |
</rdfs:subClassOf>''' % (rschema, cardtag)) |
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
|
112 |
|
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 |
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
|
114 |
for rschema, aschema in eschema.attribute_definitions(): |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
115 |
if not self.should_display_rschema(rschema): |
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
|
116 |
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
|
117 |
self.w(u'''<rdfs:subClassOf> |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
118 |
<owl:Restriction> |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
119 |
<owl:onProperty rdf:resource="#%s"/> |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
120 |
<rdf:type rdf:resource="&owl;FunctionalProperty"/> |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
121 |
</owl:Restriction> |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
122 |
</rdfs:subClassOf>''' % rschema) |
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
|
123 |
self.w(u'</owl:Class>') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
124 |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
125 |
def visit_property_schema(self, 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
|
126 |
"""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
|
127 |
for rschema, targetschemas, role in eschema.relation_definitions(): |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
128 |
if not self.should_display_rschema(rschema): |
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
|
129 |
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
|
130 |
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
|
131 |
self.w(u'''<owl:ObjectProperty rdf:ID="%s"> |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
132 |
<rdfs:domain rdf:resource="#%s"/> |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
133 |
<rdfs:range rdf:resource="#%s"/> |
2295
4bad4fb08f2e
fix name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2186
diff
changeset
|
134 |
</owl:ObjectProperty>''' % (rschema, eschema, oeschema.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
|
135 |
|
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
136 |
def visit_property_object_schema(self, 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
|
137 |
for rschema, aschema in eschema.attribute_definitions(): |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
138 |
if not self.should_display_rschema(rschema): |
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
|
139 |
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
|
140 |
self.w(u'''<owl:DatatypeProperty rdf:ID="%s"> |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
141 |
<rdfs:domain rdf:resource="#%s"/> |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
142 |
<rdfs:range rdf:resource="%s"/> |
2295
4bad4fb08f2e
fix name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2186
diff
changeset
|
143 |
</owl:DatatypeProperty>''' % (rschema, eschema, OWL_TYPE_MAP[aschema.type])) |
550
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
144 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
145 |
|
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
146 |
class OWLABOXView(EntityView): |
550
2300370b8edd
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
537
diff
changeset
|
147 |
'''This view represents a part of the ABOX for a given entity.''' |
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
|
148 |
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
|
149 |
title = _('owlabox') |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
150 |
templatable = False |
537
f16da6c874da
small corrections
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
517
diff
changeset
|
151 |
content_type = 'application/xml' # 'text/xml' |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
152 |
|
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
153 |
def call(self): |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
154 |
self.w(OWL_OPENING_ROOT % {'appid': self.schema.name}) |
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
|
155 |
for i in xrange(self.rset.rowcount): |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
156 |
self.cell_call(i, 0) |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
157 |
self.w(OWL_CLOSING_ROOT) |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
158 |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
159 |
def cell_call(self, row, col): |
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
160 |
self.wview('owlaboxitem', self.rset, row=row, col=col) |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
161 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
162 |
|
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
163 |
class OWLABOXItemView(EntityView): |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
164 |
'''This view represents a part of the ABOX for a given entity.''' |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
165 |
id = 'owlaboxitem' |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
166 |
templatable = False |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
167 |
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
|
168 |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
169 |
def cell_call(self, row, col): |
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
|
170 |
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
|
171 |
eschema = entity.e_schema |
516 | 172 |
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
|
173 |
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
|
174 |
for rschema, aschema in eschema.attribute_definitions(): |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
175 |
if rschema.meta: |
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
|
176 |
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
|
177 |
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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
continue |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
182 |
try: |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
183 |
attr = entity.printable_value(aname, format='text/plain') |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
184 |
if attr: |
814 | 185 |
self.w(u'<%s>%s</%s>' % (aname, xml_escape(attr), aname)) |
585
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
186 |
except TransformError: |
23c2f934b669
refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
552
diff
changeset
|
187 |
pass |
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
|
188 |
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
|
189 |
for rschema, targetschemas, role in eschema.relation_definitions(): |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
190 |
if rschema.meta: |
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
|
191 |
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
|
192 |
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
|
193 |
continue |
516 | 194 |
if role == 'object': |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
195 |
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
|
196 |
else: |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
197 |
attr = rschema.type |
517 | 198 |
for x in getattr(entity, attr): |
516 | 199 |
self.w(u'<%s>%s %s</%s>' % (attr, x.id, x.eid, attr)) |
200 |
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
|
201 |
|
1263 | 202 |
|
203 |
class DownloadOWLSchemaAction(Action): |
|
204 |
id = 'download_as_owl' |
|
205 |
__select__ = none_rset() & match_view('schema') |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
206 |
|
1263 | 207 |
category = 'mainactions' |
208 |
title = _('download schema as owl') |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1263
diff
changeset
|
209 |
|
1263 | 210 |
def url(self): |
211 |
return self.build_url('view', vid='owl') |