Last change
on this file since 2 was
2,
checked in by robert@…, 12 years ago
|
Initial import of basic functionality
|
File size:
1.3 KB
|
Line | |
---|
1 | package nl.tno.metagenomics.auth |
---|
2 | |
---|
3 | import nl.tno.metagenomics.Study |
---|
4 | |
---|
5 | /* |
---|
6 | * User is used to track the activity of a user within the Metagenomics Module |
---|
7 | * And data uploaded is linked to the user that provided the data |
---|
8 | */ |
---|
9 | class User { |
---|
10 | |
---|
11 | String identifier // ID of GSCF user |
---|
12 | String username // Username of GSCF user |
---|
13 | |
---|
14 | static hasMany = [ auth: Auth ] |
---|
15 | |
---|
16 | public boolean equals( Object o ) { |
---|
17 | if( o == null ) |
---|
18 | return false |
---|
19 | |
---|
20 | if( o instanceof User ) { |
---|
21 | User other = (User) o; |
---|
22 | |
---|
23 | // If anything is null, return false |
---|
24 | if( other.identifier == null || other.username == null || this.identifier == null || this.username == null ) |
---|
25 | return false; |
---|
26 | |
---|
27 | return (other.identifier == this.identifier && other.username == this.username); |
---|
28 | } else { |
---|
29 | return false |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | public boolean canRead( Study study ) { |
---|
34 | Auth authorization = auth.find { it.study.equals( study ) } |
---|
35 | |
---|
36 | if( !authorization ) |
---|
37 | return false |
---|
38 | |
---|
39 | return authorization.canRead |
---|
40 | } |
---|
41 | |
---|
42 | public boolean canWrite( Study study ) { |
---|
43 | Auth authorization = auth.find { it.study.equals( study ) } |
---|
44 | |
---|
45 | if( !authorization ) |
---|
46 | return false |
---|
47 | |
---|
48 | return authorization.canWrite |
---|
49 | } |
---|
50 | |
---|
51 | public boolean isOwner( Study study ) { |
---|
52 | Auth authorization = auth.find { it.study.equals( study ) } |
---|
53 | |
---|
54 | if( !authorization ) |
---|
55 | return false |
---|
56 | |
---|
57 | return authorization.isOwner |
---|
58 | } |
---|
59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.