AccountRole.java
4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package org.legrog.entities;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.*;
/**
* The database representation of a user role or group.
* A given {@link Account} may be part of one or more {@link AccountRole}.
* <br/>
* Warning: due to laziness of mapped objects, private attributes of all DB entities shall never be used directly.
* You shall always use the getter/setter methods.
* alias AccountRole
*
*/
/*
Importé depuis la v2.
*/
@Entity
// TODO évaluer extend v2
public class AccountRole /* extends org.roliste.data.DbEntity */
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int userRoleId;
/**
* The role identifier.
*/
private String rolename;
/**
* The {@link Account}s for this user role.
*/
@ManyToMany(mappedBy = "roles")
private Set<Account> accounts;
/**
* Builds a new and empty user role definition.
* All attributes are set to their default value.
* <br/>
* Needed by Hibernate for Java reflection.
*/
public AccountRole() {
super();
rolename = null;
visible = true;
// no need to synchronize this
accounts = new HashSet<Account>();
}
public int getUserRoleId() {
return userRoleId;
}
public void setUserRoleId(int userRoleId) {
this.userRoleId = userRoleId;
}
/**
* Returns the role identifier.
* @return the {@link String} identifier.
* @see #setRolename(String)
* hibernate.property
* column="NOM_ROLE"
* not-null="true"
* unique="true"
* access="property"
* length="50"
*/
public String getRolename() {
return rolename;
}
/**
* Initializes the role identifier.
* @param name the new {@link String} identifier.
* @see #getRolename()
*/
public void setRolename(String name) {
rolename = name;
}
/**
* The role validation status.
* A role may be temporarily deactivated.
*/
private boolean visible;
/**
* Indicates if the role is visible.
* If not, accounts should not be able to access the privileges
* they inherit from being part of this role.
* @return the visible flag.
* @see #setVisible(boolean)
* hibernate.property
* column="IND_VISIBLE"
* access="property"
*/
public boolean isVisible() {
return visible;
}
/**
* Initializes the user visible flag.
* @param visible the new flag value.
* @see #isVisible
*/
public void setVisible(boolean visible) {
this.visible = visible;
}
/**
* Retrieves the list of {@link Account}s for this user role.
* SHALL be used as a read-only attribute. In particular, avoid
* using {@link Set#add(Object)} or {@link Set#remove(Object)} on
* the returned value without caution.
* @return a {@link Set} of {@link Account}. May be <code>null</code>.
* @see #setAccounts(Set)
* hibernate.many-to-many
* column="UTILISATEUR_FK"
* class="org.roliste.data.db.Person"
* foreign-key="FK_UTILISATEURROLE_UTILISATEUR"
* hibernate.key
* column="ROLE_FK"
* not-null="true"
* foreign-key="FK_UTILISATEURROLE_ROLEUTILISATEUR"
* hibernate.set
* access="property"
* table="role_utilisateur"
* lazy="true"
* inverse="true"
*/
public Set<Account> getAccounts() {
return accounts;
}
/**
* Sets the list of {@link Account}s for this user role.
* @param accounts the new {@link Set} of {@link Account}s. May be
* <code>null</code> (we don't handle the relation from this side).
* @see #getAccounts()
*/
protected void setAccounts(Set<Account> accounts) {
this.accounts = accounts;
}
/**
* Returns a string representation of this user role definition.
* @return a string representing this user role definition.
* hidden
*/
@Override
public String toString() {
return "ID_ROLE=" + getUserRoleId() + " NOM_ROLE=" + rolename + " IND_VISIBLE=" + visible;
}
}