server/test/data-schema2sql/schema/schema.py
changeset 11057 0b59724cb3f2
parent 11052 058bb3dc685f
child 11058 23eb30449fe5
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
     1 # copyright 2004-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of yams.
       
     5 #
       
     6 # yams is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # yams is distributed in the hope that it will be useful, but WITHOUT ANY
       
    12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
       
    13 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License along
       
    17 # with yams. If not, see <http://www.gnu.org/licenses/>.
       
    18 from yams.buildobjs import (EntityType, RelationDefinition, RelationType,
       
    19                             SubjectRelation, String, Int, Float, Date, Boolean)
       
    20 from yams.constraints import Attribute, BoundaryConstraint
       
    21 
       
    22 class Affaire(EntityType):
       
    23     sujet = String(maxsize=128)
       
    24     ref = String(maxsize=12)
       
    25 
       
    26     concerne = SubjectRelation('Societe')
       
    27     obj_wildcard = SubjectRelation('*')
       
    28     sym_rel = SubjectRelation('Person', symmetric=True)
       
    29     inline_rel = SubjectRelation('Person', inlined=True, cardinality='?*')
       
    30 
       
    31 class subj_wildcard(RelationDefinition):
       
    32     subject = '*'
       
    33     object = 'Affaire'
       
    34 
       
    35 
       
    36 class Person(EntityType):
       
    37     __unique_together__ = [('nom', 'prenom')]
       
    38     nom    = String(maxsize=64, fulltextindexed=True, required=True)
       
    39     prenom = String(maxsize=64, fulltextindexed=True)
       
    40     sexe   = String(maxsize=1, default='M')
       
    41     promo  = String(vocabulary=('bon','pasbon'))
       
    42     titre  = String(maxsize=128, fulltextindexed=True)
       
    43     adel   = String(maxsize=128)
       
    44     ass    = String(maxsize=128)
       
    45     web    = String(maxsize=128)
       
    46     tel    = Int(__permissions__={'read': (),
       
    47                                   'add': ('managers',),
       
    48                                   'update': ('managers',)})
       
    49     fax    = Int()
       
    50     datenaiss = Date()
       
    51     test   = Boolean()
       
    52     salary = Float()
       
    53     travaille = SubjectRelation('Societe',
       
    54                                 __permissions__={'read': (),
       
    55                                                  'add': (),
       
    56                                                  'delete': ('managers',),
       
    57                                                  })
       
    58 
       
    59     evaluee = SubjectRelation('Note')
       
    60 
       
    61 class Salaried(Person):
       
    62     __specializes_schema__ = True
       
    63 
       
    64 class Societe(EntityType):
       
    65     nom  = String(maxsize=64, fulltextindexed=True)
       
    66     web = String(maxsize=128)
       
    67     tel  = Int()
       
    68     fax  = Int(constraints=[BoundaryConstraint('<=', Attribute('tel'))])
       
    69     rncs = String(maxsize=32)
       
    70     ad1  = String(maxsize=128)
       
    71     ad2  = String(maxsize=128)
       
    72     ad3  = String(maxsize=128)
       
    73     cp   = String(maxsize=12)
       
    74     ville = String(maxsize=32)
       
    75 
       
    76     evaluee = SubjectRelation('Note')
       
    77 
       
    78 
       
    79 class Note(EntityType):
       
    80     date = String(maxsize=10)
       
    81     type = String(maxsize=1)
       
    82     para = String(maxsize=512)
       
    83 
       
    84 
       
    85 class pkginfo(EntityType):
       
    86     modname = String(maxsize=30, required=True)
       
    87     version = String(maxsize=10, required=True, default='0.1')
       
    88     copyright = String(required=True)
       
    89     license = String(vocabulary=('GPL', 'ZPL'))
       
    90     short_desc = String(maxsize=80, required=True)
       
    91     long_desc = String(required=True, fulltextindexed=True)
       
    92     author = String(maxsize=100, required=True)
       
    93     author_email = String(maxsize=100, required=True)
       
    94     mailinglist = String(maxsize=100)
       
    95     debian_handler = String(vocabulary=('machin', 'bidule'))
       
    96 
       
    97 
       
    98 class evaluee(RelationType):
       
    99     __permissions__ = {
       
   100         'read': ('managers',),
       
   101         'add': ('managers',),
       
   102         'delete': ('managers',),
       
   103         }
       
   104 
       
   105 class concerne(RelationDefinition):
       
   106     subject = 'Person'
       
   107     object = 'Affaire'
       
   108     __permissions__ = {
       
   109         'read': ('managers',),
       
   110         'add': ('managers',),
       
   111         'delete': ('managers',),
       
   112         }