author | Julien Cristau <julien.cristau@logilab.fr> |
Mon, 09 Nov 2015 16:21:29 +0100 | |
changeset 10879 | 3193d9ede8dd |
parent 10790 | 117a6bbefbfd |
permissions | -rw-r--r-- |
10199
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
1 |
# copyright 2004-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
3 |
# |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
4 |
# This file is part of yams. |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
5 |
# |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
6 |
# yams is free software: you can redistribute it and/or modify it under the |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
9 |
# any later version. |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
10 |
# |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
11 |
# yams is distributed in the hope that it will be useful, but WITHOUT ANY |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
12 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
13 |
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
14 |
# details. |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
15 |
# |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
17 |
# with yams. If not, see <http://www.gnu.org/licenses/>. |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
18 |
from yams.buildobjs import (EntityType, RelationType, RelationDefinition, |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
19 |
SubjectRelation, Int, String, Boolean) |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
20 |
from yams.constraints import SizeConstraint, UniqueConstraint |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
21 |
|
10790
117a6bbefbfd
[server/test] use relative import
Julien Cristau <julien.cristau@logilab.fr>
parents:
10199
diff
changeset
|
22 |
from . import RESTRICTED_RTYPE_PERMS |
10199
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
23 |
|
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
24 |
class State(EntityType): |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
25 |
"""used to associate simple states to an entity |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
26 |
type and/or to define workflows |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
27 |
""" |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
28 |
__permissions__ = { |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
29 |
'read': ('managers', 'users', 'guests',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
30 |
'add': ('managers', 'users',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
31 |
'delete': ('managers', 'owners',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
32 |
'update': ('managers', 'owners',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
33 |
} |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
34 |
|
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
35 |
# attributes |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
36 |
eid = Int(required=True, uid=True) |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
37 |
name = String(required=True, |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
38 |
indexed=True, internationalizable=True, |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
39 |
constraints=[SizeConstraint(256)]) |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
40 |
description = String(fulltextindexed=True) |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
41 |
# relations |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
42 |
state_of = SubjectRelation('Eetype', cardinality='+*') |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
43 |
next_state = SubjectRelation('State', cardinality='**') |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
44 |
|
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
45 |
|
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
46 |
class state_of(RelationType): |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
47 |
"""link a state to one or more entity type""" |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
48 |
__permissions__ = RESTRICTED_RTYPE_PERMS |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
49 |
|
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
50 |
class next_state(RelationType): |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
51 |
"""define a workflow by associating a state to possible following states |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
52 |
""" |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
53 |
__permissions__ = RESTRICTED_RTYPE_PERMS |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
54 |
|
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
55 |
class initial_state(RelationType): |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
56 |
"""indicate which state should be used by default when an entity using states |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
57 |
is created |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
58 |
""" |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
59 |
__permissions__ = { |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
60 |
'read': ('managers', 'users', 'guests',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
61 |
'add': ('managers', 'users',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
62 |
'delete': ('managers', 'users',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
63 |
} |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
64 |
subject = 'Eetype' |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
65 |
object = 'State' |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
66 |
cardinality = '?*' |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
67 |
inlined = True |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
68 |
|
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
69 |
class Eetype(EntityType): |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
70 |
"""define an entity type, used to build the application schema""" |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
71 |
__permissions__ = { |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
72 |
'read': ('managers', 'users', 'guests',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
73 |
'add': ('managers',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
74 |
'delete': ('managers',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
75 |
'update': ('managers', 'owners',), |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
76 |
} |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
77 |
name = String(required=True, indexed=True, internationalizable=True, |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
78 |
constraints=[UniqueConstraint(), SizeConstraint(64)]) |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
79 |
description = String(fulltextindexed=True) |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
80 |
meta = Boolean() |
218c28bff695
Steal schema2sql module from yams
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
81 |
final = Boolean() |