web/views/owl.py
author Laure Bourgois <Laure.Bourgois@logilab.fr>
Mon, 02 Feb 2009 13:32:56 +0100
changeset 550 2300370b8edd
parent 537 f16da6c874da
child 551 44ec4836cc1a
permissions -rw-r--r--
refactoring OWLView (TBOX+ABOX) and OWLABOXView (pseudo-ABOX for a given entity). By now OWLView is using (for cost advantage) OWLABOXLightView.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
502
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     1
from logilab.mtconverter import html_escape
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     2
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     3
from cubicweb.common.view import StartupView
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     4
from cubicweb.common.view import EntityView
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     5
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     6
_ = 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
     7
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     8
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
     9
                '?': '<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
    10
                '+': '<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
    11
                '*': ''
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
OWL_CARD_MAP_DATA = {'String': 'xsd:string',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    15
                     'Datetime': 'xsd:dateTime',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    16
                     'Bytes': 'xsd:byte',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    17
                     'Float': 'xsd:float',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    18
                     'Boolean': 'xsd:boolean',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    19
                     'Int': 'xsd:int',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    20
                     'Date':'xsd:date',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    21
                     'Time': 'xsd:time',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    22
                     'Password': 'xsd:byte',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    23
                     'Decimal' : 'xsd:decimal',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    24
                     'Interval': 'xsd:duration'
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    25
                     }
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    26
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
    27
OWL_OPENING_ROOT = u'''<?xml version="1.0" encoding="UTF-8"?>
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
    28
        <!DOCTYPE rdf:RDF [
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    29
        <!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
    30
        <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    31
        <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    32
        <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    33
        <!ENTITY %s "http://logilab.org/owl/ontologies/%s#" >
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    34
        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    35
        ]>        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    37
            xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    38
            xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    39
            xmlns:owl="http://www.w3.org/2002/07/owl#"
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    40
            xmlns="http://logilab.org/owl/ontologies/%s#"
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    41
            xmlns:%s="http://logilab.org/owl/ontologies/%s#"
503
a2fca6cdc5ff OWLView correction (namespace)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 502
diff changeset
    42
            xmlns:base="http://logilab.org/owl/ontologies/%s">
502
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    43
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    44
    <owl:Ontology rdf:about="">
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    45
        <rdfs:comment>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    46
        %s Cubicweb OWL Ontology                           
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    47
                                        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    48
        </rdfs:comment>
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
    49
   </owl:Ontology>'''
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
    50
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
    51
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
    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
class OWLView(StartupView):
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
    """This view export in owl format schema database. It is the TBOX"""
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
    id = 'owl'
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
    title = _('owl')
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
    templatable =False
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
    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
    59
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
    60
    def call(self):
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
    61
        
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
    62
        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
    63
        self.w(OWL_OPENING_ROOT % (self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name))
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
        self.wview('tbox', None, writeprefix=False)
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
        entities = [eschema for eschema in self.schema.entities()
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
                    if not eschema.is_final()]
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 skipmeta:
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
            entities = [eschema for eschema in entities
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
    69
                        if not eschema.meta]
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
        for entity in entities:
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
            rql = 'Any X where X is %s'
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
            rset = self.req.execute(rql% 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
    73
            if rset:
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
                self.wview('owlaboxlight', rset, writeprefix=False)
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
    75
        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
    76
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
    77
class TBoxView(StartupView):
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
    78
    """This view export in owl format the whole cubicweb ontologie. First part is the TBOX, second part is an ABOX ligth version."""
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
    79
    id = 'tbox'
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
    title = _('tbox')
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
    81
    templatable =False
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
    82
    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
    83
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
    84
    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
    85
        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
    86
        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
    87
            self.w(OWL_OPENING_ROOT % (self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name) )
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
    88
              
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
    89
        self.visit_schema(display_relations=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
    90
                             skiprels=('is', 'is_instance_of', 'identity',
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
    91
                                       'owned_by', 'created_by'),
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
    92
                             skipmeta=skipmeta)
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
    93
        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
    94
            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
    95
        
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
    96
    def visit_schema(self, display_relations=0,
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
    97
                     skiprels=(), 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
    98
        """get a layout for a whole schema"""
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
    99
        
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
   100
        entities = [eschema for eschema in self.schema.entities()
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   101
                    if not eschema.is_final()]
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   102
        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
   103
            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
   104
                        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
   105
        keys = [(eschema.type, eschema) for eschema in entities]
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   106
        self.w(u'<!-- classes definition -->')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   107
        for key, eschema in sorted(keys):
506
f60de0a5ef95 cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 503
diff changeset
   108
            self.visit_entityschema(eschema, skiprels)
502
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   109
        self.w(u'<!-- property definition -->')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   110
        self.w(u'<!-- object property -->')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   111
        for key, eschema in sorted(keys):
506
f60de0a5ef95 cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 503
diff changeset
   112
             self.visit_property_schema(eschema, skiprels)
502
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   113
        self.w(u'<!-- datatype property -->')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   114
        for key, eschema in sorted(keys):
506
f60de0a5ef95 cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 503
diff changeset
   115
            self.visit_property_object_schema(eschema, skiprels)
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
   116
         
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
   117
    def stereotype(self, name):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   118
        return Span((' <<%s>>' % name,), klass='stereotype')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   119
                       
506
f60de0a5ef95 cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 503
diff changeset
   120
    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
   121
        """get a layout for an entity OWL schema"""
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   122
        etype = eschema.type
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   123
        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   124
        if eschema.meta:
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   125
            self.stereotype('meta')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   126
            self.w(u'''<owl:Class rdf:ID="%s"><rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   127
                                '''%eschema, stereotype)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   128
        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
   129
             self.w(u'''<owl:Class rdf:ID="%s"><rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   130
                                '''% eschema)         
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   131
       
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   132
        self.w(u'<!-- 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
   133
        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
   134
            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
   135
                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
   136
            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
   137
                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
   138
            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
   139
                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
   140
                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
   141
                    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
   142
                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
   143
                    card = rschema.rproperty(oeschema, eschema, 'cardinality')[1]
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   144
                self.w(u'''<rdfs:subClassOf>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   145
                              <owl:Restriction>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   146
                              <owl:onProperty rdf:resource="#%s"/>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   147
                                %s
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   148
                              </owl:Restriction>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   149
                           </rdfs:subClassOf>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   150
                                ''' % (label, OWL_CARD_MAP[card]))
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   151
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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'<!-- 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
   153
              
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   154
        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
   155
            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
   156
                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
   157
            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
   158
            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
   159
                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
   160
            card_data = aschema.type
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   161
            self.w(u'''<rdfs:subClassOf>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   162
                              <owl:Restriction>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   163
                                 <owl:onProperty rdf:resource="#%s"/>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   164
                                 <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
   165
                                 </owl:Restriction>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   166
                        </rdfs:subClassOf>'''
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   167
                          
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
                   % 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
   169
        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
   170
    
506
f60de0a5ef95 cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 503
diff changeset
   171
    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
   172
        """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
   173
        etype = eschema.type
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   174
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   175
        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
   176
            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
   177
                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
   178
            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
   179
                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
   180
            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
   181
                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
   182
                self.w(u'''<owl:ObjectProperty rdf:ID="%s">
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   183
                              <rdfs:domain rdf:resource="#%s"/>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   184
                              <rdfs:range rdf:resource="#%s"/>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   185
                           </owl:ObjectProperty>                   
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   186
                             
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
                                ''' % (label, eschema, oeschema.type ))
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   188
506
f60de0a5ef95 cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 503
diff changeset
   189
    def visit_property_object_schema(self, eschema, skiprels=()):
502
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   190
               
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        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
   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
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
            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
   195
            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
   196
                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
   197
            card_data = aschema.type
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   198
            self.w(u'''<owl:DatatypeProperty rdf:ID="%s">
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   199
                          <rdfs:domain rdf:resource="#%s"/>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   200
                          <rdfs:range rdf:resource="%s"/>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   201
                       </owl:DatatypeProperty>'''
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   202
                   % (aname, eschema, OWL_CARD_MAP_DATA[card_data]))
506
f60de0a5ef95 cleaning OWLView
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 503
diff changeset
   203
            
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
   204
class OWLABOXLightView(EntityView):
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
   205
    '''This view represents the lihgt 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
   206
    id = 'owlaboxlight'
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
   207
    title = _('owlaboxlight')
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
   208
    templatable =False
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
   209
    accepts = ('Any',)
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
   210
    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
   211
    
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
   212
    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
   213
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
   214
        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
   215
        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
   216
            self.w(OWL_OPENING_ROOT % (self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name))
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
   217
        for i in xrange(self.rset.rowcount):
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
   218
            self.cell_call(i, 0, skiprels=('is', 'is_instance_of', 'identity',
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
   219
                                       'owned_by', 'created_by'),
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
   220
                             skipmeta=skipmeta)
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
   221
        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
   222
            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
   223
        
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
   224
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
   225
    def cell_call(self, row, col, skiprels=(), 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
   226
        entity = self.complete_entity(row, col)
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
   227
        eschema = entity.e_schema
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
   228
        self.w(u'<%s rdf:ID="%s">' % (eschema, entity.eid))
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
   229
        self.w(u'</%s>'% eschema)
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
   230
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
   231
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
   232
class OWLABOXEView(EntityView):
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
   233
    '''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
   234
    
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
   235
    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
   236
    title = _('owlabox')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   237
    templatable =False
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   238
    accepts = ('Any',)
537
f16da6c874da small corrections
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 517
diff changeset
   239
    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
   240
    
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
   241
    def call(self, writeprefix=True):
502
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   242
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   243
        skipmeta = int(self.req.form.get('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
   244
        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
   245
            self.w(OWL_OPENING_ROOT % (self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, 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
   246
        for i in xrange(self.rset.rowcount):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   247
            self.cell_call(i, 0, skiprels=('is', 'is_instance_of', 'identity',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   248
                                       'owned_by', 'created_by'),
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   249
                             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
   250
        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
   251
            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
   252
        
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
   253
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   254
    def cell_call(self, row, col, skiprels=(), skipmeta=True):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   255
        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
   256
        eschema = entity.e_schema
516
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   257
        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
   258
        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
   259
        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
   260
            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
   261
                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
   262
            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
   263
                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
   264
            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
   265
            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
   266
                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
   267
            attr = getattr(entity, aname)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   268
            if attr is not None:
516
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   269
                self.w(u'<%s>%s</%s>' % (aname, html_escape(unicode(attr)), aname))
502
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   270
        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
   271
        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
   272
            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
   273
                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
   274
            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
   275
                continue
516
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   276
            if role == 'object':
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   277
                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
   278
            else:
516
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   279
                attr = rschema.type        
517
sylvain.thenault@logilab.fr
parents: 516
diff changeset
   280
            for x in getattr(entity, attr):
516
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   281
                self.w(u'<%s>%s %s</%s>' % (attr, x.id, x.eid, attr))
56fd73de1f06 owl cleanup
sylvain.thenault@logilab.fr
parents: 512
diff changeset
   282
        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
   283