web/views/owl.py
author Laure Bourgois <Laure.Bourgois@logilab.fr>
Wed, 28 Jan 2009 16:52:12 +0100
changeset 502 7882941d3530
child 503 a2fca6cdc5ff
permissions -rw-r--r--
owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
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.uilib import ureport_as_html, unormalize, ajax_replace_url
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     4
from cubicweb.common.view import StartupView
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     5
from cubicweb.common.view import EntityView
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
from cubicweb.web.httpcache import EtagHTTPCacheManager
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     7
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     8
_ = unicode
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
     9
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    10
OWL_CARD_MAP = {'1': '<rdf:type rdf:resource="&owl;FunctionalProperty"/>',                      
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    11
                '?': '<owl:maxCardinality rdf:datatype="&xsd;int">1</owl:maxCardinality>',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    12
                '+': '<owl:minCardinality rdf:datatype="&xsd;int">1</owl:minCardinality>',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    13
                '*': ''
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    14
                }
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    15
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    16
OWL_CARD_MAP_DATA = {'String': 'xsd:string',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    17
                     'Datetime': 'xsd:dateTime',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    18
                     'Bytes': 'xsd:byte',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    19
                     'Float': 'xsd:float',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    20
                     'Boolean': 'xsd:boolean',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    21
                     'Int': 'xsd:int',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    22
                     'Date':'xsd:date',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    23
                     'Time': 'xsd:time',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    24
                     'Password': 'xsd:byte',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    25
                     'Decimal' : 'xsd:decimal',
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    26
                     'Interval': 'xsd:duration'
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    27
                     }
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    28
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    29
class OWLView(StartupView):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    30
    id = 'owl'
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    31
    title = _('owl')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    32
    templatable =False
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
    def call(self):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    35
        skipmeta = int(self.req.form.get('skipmeta', True))
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    36
        self.visit_schemaOWL(display_relations=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
    37
                             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
    38
                                       '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
    39
                             skipmeta=skipmeta)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    40
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    41
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    42
    def visit_schemaOWL(self, display_relations=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
    43
                     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
    44
        """get a layout for a whole schema"""
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    45
        self.w(u'''<?xml version="1.0" encoding="UTF-8"?>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    46
        <!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
    47
        <!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
    48
        <!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
    49
        <!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
    50
        <!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
    51
        <!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
    52
        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    53
        ]>        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    54
        <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
    55
            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
    56
            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
    57
            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
    58
            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
    59
            xmlns:%s="http://logilab.org/owl/ontologies/%s#"
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    60
            xml:base="http://logilab.org/owl/ontologies/%s">
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    61
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    62
    <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
    63
        <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
    64
        %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
    65
                                        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    66
        </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
    67
   </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
    68
        ''' % (self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name))
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    69
        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
    70
                    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
    71
        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
    72
            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
    73
                        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
    74
        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
    75
        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
    76
        for key, eschema in sorted(keys):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
            self.visit_entityschemaOWL(eschema, 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
    78
        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
    79
        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
    80
        for key, eschema in sorted(keys):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    81
             self.visit_property_schemaOWL(eschema, 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
    82
        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
    83
        for key, eschema in sorted(keys):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    84
            self.visit_property_object_schemaOWL(eschema, 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
    85
        self.w(u'</rdf:RDF>')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    86
           
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    87
    def eschema_link_url(self, 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
    88
        return self.req.build_url('eetype/%s?vid=eschema' % 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
    89
    
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
    90
    def rschema_link_url(self, rschema):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        return self.req.build_url('ertype/%s?vid=eschema' % rschema)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
    def possible_views(self, etype):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        rset = self.req.etype_rset(etype)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        return [v for v in self._possible_views(self.req, rset)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
                if v.category != '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
    97
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
    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
    99
        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
   100
                       
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
    def visit_entityschemaOWL(self, eschema, 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
   102
        """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
   103
        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
   104
        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   105
        if 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
   106
            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
   107
            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
   108
                                '''%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
   109
        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
   110
             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
   111
                                '''% 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
   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'<!-- 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
   114
        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
   115
            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
   116
                continue
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   117
            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
   118
                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
   119
            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
   120
                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
   121
                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
   122
                    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
   123
                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
   124
                    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
   125
                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
   126
                              <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
   127
                              <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
   128
                                %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
   129
                              </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
   130
                           </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
   131
                                ''' % (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
   132
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        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
   134
              
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        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
   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
            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
   139
            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
   140
                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
   141
            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
   142
            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
   143
                              <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
   144
                                 <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
   145
                                 <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
   146
                                 </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
   147
                        </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
   148
                          
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        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
   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
    def visit_property_schemaOWL(self, eschema, 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
   153
        """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
   154
        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
   155
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        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
   157
            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
   158
                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
   159
            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
   160
                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
   161
            rschemaurl = self.rschema_link_url(rschema)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   162
            for 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
   163
                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
   164
                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
   165
                              <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
   166
                              <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
   167
                           </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
   168
                             
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
                                ''' % (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
   170
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   171
    def visit_property_object_schemaOWL(self, eschema, 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
   172
               
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        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
   174
            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
   175
                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
   176
            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
   177
            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
   178
                continue
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   179
            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
   180
            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
   181
                          <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
   182
                          <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
   183
                       </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
   184
                   % (aname, eschema, OWL_CARD_MAP_DATA[card_data]))
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
class OWLABOXView(EntityView):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   186
    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
   187
    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
   188
    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
   189
    accepts = ('Any',)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
    def call(self):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   192
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   193
        rql = ('Any X')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        rset = self.req.execute(rql)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        skipmeta = int(self.req.form.get('skipmeta', True))
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   196
        self.w(u'''<?xml version="1.0" encoding="UTF-8"?>
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   197
        <!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
   198
        <!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
   199
        <!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
   200
        <!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
   201
        <!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
   202
        <!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
   203
        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        ]>        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        <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
   206
            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
   207
            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
   208
            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
   209
            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
   210
            xmlns:%s="http://logilab.org/owl/ontologies/%s#"
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   211
            xmlns:base="http://logilab.org/owl/ontologies/%s">
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   212
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   213
    <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
   214
        <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
   215
        %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
   216
                                        
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   217
        </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
   218
   </owl:Ontology>''' % (self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name, self.schema.name))
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   219
        #self.view('owl', rset)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   220
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   221
        for 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
   222
            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
   223
                                       '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
   224
                             skipmeta=skipmeta)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   225
        self.w(u'</rdf:RDF>')
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   226
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   227
    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
   228
        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
   229
        eschema = entity.e_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
   230
        self.w(u'''<%s rdf:ID="%s">''' % (eschema, entity.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
   231
        print 'i'*40
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   232
        self.w(u'<!--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
   233
        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
   234
            if rschema.type in skiprels:
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   235
                continue
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   236
            if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')):
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   237
                continue
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
            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
   239
            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
   240
                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
   241
            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
   242
            if attr is not None:
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
                self.w(u'''<%s>%s</%s>'''% (aname, html_escape(unicode(attr)), 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
   244
            
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   245
        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
   246
        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
   247
            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
   248
                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
   249
            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
   250
                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
   251
            if role =='object':
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less ABOX. indeed, it layout ABOX information only for an specific entity and not all entities)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
diff changeset
   252
                reverse = 'reverse_%s' % 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
   253
                rel = getattr(entity, reverse)
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
            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
   255
                rel = getattr(entity, 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
   256
                reverse = '%s' % 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
   257
            if len(rel)!=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
   258
                print rel
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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 x in rel:
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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 hasattr(x, '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
   261
                        self.w(u'''<%s>%s %s %s</%s> ''' % (reverse, targetschemas[0], html_escape(unicode(x.name)), html_escape(unicode(x.eid)), reverse))
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
                    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
   263
                        self.w(u'''<%s>%s %s</%s> ''' % (reverse, targetschemas[0], html_escape(unicode(x.eid)), reverse))
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
                       
7882941d3530 owl module has two views : OWLView (TBOX) and OWLABOXView (more or less 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
        self.w(u'''</%s>'''% 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
   266