web/views/owl.py
author sylvain.thenault@logilab.fr
Mon, 02 Mar 2009 20:44:14 +0100
branchtls-sprint
changeset 984 536e421b082b
parent 939 ad72e06320e2
child 1263 01152fffd593
permissions -rw-r--r--
import updates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
984
536e421b082b import updates
sylvain.thenault@logilab.fr
parents: 939
diff changeset
     1
"""produces some Ontology Web Language schema and views
536e421b082b import updates
sylvain.thenault@logilab.fr
parents: 939
diff changeset
     2
536e421b082b import updates
sylvain.thenault@logilab.fr
parents: 939
diff changeset
     3
:organization: Logilab
536e421b082b import updates
sylvain.thenault@logilab.fr
parents: 939
diff changeset
     4
:copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
536e421b082b import updates
sylvain.thenault@logilab.fr
parents: 939
diff changeset
     5
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
536e421b082b import updates
sylvain.thenault@logilab.fr
parents: 939
diff changeset
     6
"""
536e421b082b import updates
sylvain.thenault@logilab.fr
parents: 939
diff changeset
     7
__docformat__ = "restructuredtext en"
536e421b082b import updates
sylvain.thenault@logilab.fr
parents: 939
diff changeset
     8
814
c0bee055c594 small fix
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 674
diff changeset
     9
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
    10
984
536e421b082b import updates
sylvain.thenault@logilab.fr
parents: 939
diff changeset
    11
from cubicweb.view import StartupView, EntityView
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
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
_ = 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
    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
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
    16
                '?': '<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
    17
                '+': '<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
    18
                '*': ''
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
                }
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    21
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
    22
                'Datetime': 'xsd:dateTime',
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    23
                'Bytes': 'xsd:byte',
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    24
                'Float': 'xsd:float',
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    25
                'Boolean': 'xsd:boolean',
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    26
                'Int': 'xsd:int',
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    27
                'Date':'xsd:date',
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    28
                'Time': 'xsd:time',
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    29
                'Password': 'xsd:byte',
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    30
                'Decimal' : 'xsd:decimal',
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    31
                'Interval': 'xsd:duration'
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    32
                }
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
    33
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
    34
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
    35
<!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
    36
        <!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
    37
        <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    38
]>        
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    39
<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
    40
    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
    41
    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
    42
    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
    43
    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
    44
    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
    45
    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
    46
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    47
  <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
    48
    <rdfs:comment>
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    49
    %(appid)s Cubicweb OWL Ontology                           
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    50
    </rdfs:comment>
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    51
  </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
    52
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
    53
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
    54
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    55
DEFAULT_SKIP_RELS = frozenset(('is', 'is_instance_of', 'identity',
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    56
                               'owned_by', 'created_by'))
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
    57
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    58
class OWLView(StartupView):
551
44ec4836cc1a comments fix
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 550
diff changeset
    59
    """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
    60
    id = 'owl'
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    61
    title = _('owl')
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    62
    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
    63
    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
    64
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
    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
    66
        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
    67
        if writeprefix:
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    68
            self.w(OWL_OPENING_ROOT % {'appid': self.schema.name})
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    69
        self.visit_schema(skipmeta=skipmeta)
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
    70
        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
    71
            self.w(OWL_CLOSING_ROOT)
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
        
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    73
    def visit_schema(self, skiprels=DEFAULT_SKIP_RELS, skipmeta=True):
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
    74
        """get a layout for a whole schema"""
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    75
        entities = sorted([eschema for eschema in self.schema.entities()
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    76
                           if not eschema.is_final()])
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
    77
        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
    78
            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
    79
                        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
    80
        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
    81
        for eschema in entities:
506
f60de0a5ef95 cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 503
diff changeset
    82
            self.visit_entityschema(eschema, skiprels)
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    83
            self.w(u'<!-- property definition -->')
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    84
            self.visit_property_schema(eschema, skiprels)
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
    85
            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
    86
            self.visit_property_object_schema(eschema)
674
8580f1632055 small fix
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 585
diff changeset
    87
506
f60de0a5ef95 cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 503
diff changeset
    88
    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
    89
        """get a layout for an entity OWL schema"""
674
8580f1632055 small fix
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 585
diff changeset
    90
        self.w(u'<owl:Class rdf:ID="%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
    91
        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
    92
        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
    93
            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
    94
                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
    95
            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
    96
                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
    97
            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
    98
                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
    99
                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
   100
                    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
   101
                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
   102
                    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
   103
                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
   104
                if cardtag:
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   105
                    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
   106
 <owl:Restriction>
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   107
  <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
   108
  %s
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   109
 </owl:Restriction>
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   110
</rdfs:subClassOf>
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   111
''' % (label, 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
              
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        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
   116
            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
   117
                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
   118
            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
   119
            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
   120
                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
   121
            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
   122
  <owl:Restriction>
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   123
   <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
   124
   <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
   125
  </owl:Restriction>
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   126
</rdfs:subClassOf>'''                         
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
   127
                   % 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
   128
        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
   129
    
506
f60de0a5ef95 cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 503
diff changeset
   130
    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
   131
        """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
   132
        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
   133
            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
   134
                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
   135
            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
   136
                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
   137
            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
   138
                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
   139
                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
   140
 <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
   141
 <rdfs:range 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
</owl:ObjectProperty>                                                
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   143
''' % (label, 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
   144
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   145
    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
   146
        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
   147
            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
   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
            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
   150
            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
   151
                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
   152
            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
   153
  <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
   154
  <rdfs:range rdf:resource="%s"/>
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   155
</owl:DatatypeProperty>'''
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   156
                   % (aname, 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
   157
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   158
            
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   159
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
   160
    '''This view represents a part of the ABOX for a given entity.'''
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
   161
    
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
   162
    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
   163
    title = _('owlabox')
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   164
    templatable = False
537
f16da6c874da small corrections
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 517
diff changeset
   165
    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
   166
    
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   167
    def call(self):
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   168
        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
   169
        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
   170
            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
   171
        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
   172
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   173
    def cell_call(self, row, col, skiprels=DEFAULT_SKIP_RELS):
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   174
        self.wview('owlaboxitem', self.rset, row=row, col=col, skiprels=skiprels)
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   175
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
   176
        
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   177
class OWLABOXItemView(EntityView):
688
cddfbdee0eb3 remove all accepts = ('Foo',) declaration and use __selectors__ = implements('Foo') instead
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 674
diff changeset
   178
    '''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
   179
    id = 'owlaboxitem'
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   180
    templatable = False
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   181
    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
   182
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   183
    def cell_call(self, row, col, skiprels=DEFAULT_SKIP_RELS):
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
   184
        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
   185
        eschema = entity.e_schema
516
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   186
        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
   187
        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
   188
        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
   189
            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
   190
                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
   191
            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
   192
                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
   193
            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
   194
            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
   195
                continue
585
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   196
            try:
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   197
                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
   198
                if attr:
814
c0bee055c594 small fix
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 674
diff changeset
   199
                    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
   200
            except TransformError:
23c2f934b669 refactoring owl view (now corresponding to tbox) and owlabox view
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 552
diff changeset
   201
                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
   202
        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
   203
        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
   204
            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
   205
                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
   206
            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
   207
                continue
516
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   208
            if role == 'object':
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   209
                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
   210
            else:
516
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   211
                attr = rschema.type        
517
sylvain.thenault@logilab.fr
parents: 516
diff changeset
   212
            for x in getattr(entity, attr):
516
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   213
                self.w(u'<%s>%s %s</%s>' % (attr, x.id, x.eid, attr))
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   214
        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
   215