|
1 # copyright 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 CubicWeb. |
|
5 # |
|
6 # CubicWeb 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 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 # FOR 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 CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
18 |
|
19 from yams.buildobjs import (EntityType, RelationDefinition, ComputedRelation, |
|
20 Int, Float) |
|
21 |
|
22 |
|
23 class Employee(EntityType): |
|
24 pass |
|
25 |
|
26 |
|
27 class employees(RelationDefinition): |
|
28 subject = 'Company' |
|
29 object = 'Employee' |
|
30 |
|
31 |
|
32 class associates(RelationDefinition): |
|
33 subject = 'Company' |
|
34 object = 'Employee' |
|
35 |
|
36 |
|
37 class works_for(ComputedRelation): |
|
38 rule = 'O employees S, NOT EXISTS (O associates S)' |
|
39 |
|
40 |
|
41 class Company(EntityType): |
|
42 score = Float(formula='Any AVG(NN) WHERE X employees E, N concerns E, N note NN') |
|
43 score100 = Float(formula='Any AVG(NN) WHERE X employees E, N concerns E, N note100 NN') |
|
44 |
|
45 |
|
46 class Note(EntityType): |
|
47 note = Int() |
|
48 note100 = Int(formula='Any N*100 WHERE X note N') |
|
49 |
|
50 |
|
51 class concerns(RelationDefinition): |
|
52 subject = 'Note' |
|
53 object = 'Employee' |
|
54 |
|
55 |
|
56 class whatever(ComputedRelation): |
|
57 rule = 'S employees E, O associates E' |
|
58 |
|
59 |
|
60 class renamed(ComputedRelation): |
|
61 rule = 'S employees E, O concerns E' |
|
62 |
|
63 |
|
64 class perm_changes(ComputedRelation): |
|
65 __permissions__ = {'read': ('managers',)} |
|
66 rule = 'S employees E, O concerns E' |