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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
/*
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ===================================================================
* Modifications Copyright (c) 2019 Samsung
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
* under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Unless otherwise specified, all documentation contained herein is licensed
* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
* https://creativecommons.org/licenses/by/4.0/
*
* Unless required by applicable law or agreed to in writing, documentation
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ============LICENSE_END============================================
*
*
*/
package org.onap.portal.domain.db.fn;
import java.io.Serializable;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.validator.constraints.SafeHtml;
import org.onap.portal.domain.db.ep.EpAppRoleFunction;
import org.onap.portal.domain.db.ep.EpRoleNotification;
import org.onap.portal.domain.db.ep.EpUserRolesRequestDet;
import org.onap.portal.domain.db.ep.EpWidgetCatalogRole;
import org.onap.portal.domain.dto.DomainVo;
/*
CREATE TABLE `fn_role` (
`role_id` int(11) NOT NULL AUTO_INCREMENT,
`role_name` varchar(300) NOT NULL,
`active_yn` varchar(1) NOT NULL DEFAULT 'y',
`priority` decimal(4,0) DEFAULT NULL,
`app_id` int(11) DEFAULT NULL,
`app_role_id` int(11) DEFAULT NULL,
PRIMARY KEY (`role_id`),
UNIQUE KEY `fn_role_name_app_id_idx` (`role_name`,`app_id`) USING BTREE
)
*/
@NamedQueries({
@NamedQuery(
name = "FnRole.retrieveAppRolesByRoleNameAndByAppId",
query = "FROM FnRole where role_name =:roleName and app_id =:appId"),
@NamedQuery(
name = "FnRole.retrieveAppRolesByAppId",
query = "FROM FnRole where app_id =:appId"),
@NamedQuery(
name = "FnRole.retrieveAppRolesWhereAppIdIsNull",
query = "FROM FnRole where app_id is null"),
@NamedQuery(
name = "FnRole.retrieveAppRoleByRoleIdWhereAppIdIsNull",
query = "FROM FnRole where role_id =:roleId and app_id is null"),
@NamedQuery(
name = "FnRole.retrieveAppRoleByAppRoleIdAndByAppId",
query = "FROM FnRole where appRoleId =:appRoleId and appId =:appId"),
@NamedQuery(
name = "FnRole.retrieveAppRoleByRoleIdAndAppId",
query = "FROM FnRole where role_id =:roleId and app_id =:appId"),
@NamedQuery(
name = "FnRole.retrieveAppRolesByRoleNameAndWhereAppIdIsNull",
query = "FROM FnRole where role_name =:roleName and app_id is null"),
@NamedQuery(
name = "FnRole.retrieveActiveRolesOfApplication",
query = "from FnRole where active_yn = 'Y' and app_id=:appId"),
@NamedQuery(name = "FnRole.retrieveRoleToUpdateInExternalAuthSystem",
query = "FROM FnRole where role_name =:roleName and app_id =:appId")
})
@Table(name = "fn_role", indexes = {
@Index(name = "fn_role_name_app_id_idx", columnList = "role_name, app_id", unique = true)
})
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Entity
public class FnRole extends DomainVo implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "role_id", length = 11, nullable = false)
@Digits(integer = 11, fraction = 0)
private Long roleId;
@Column(name = "role_name", length = 300, nullable = false)
@Size(max = 300)
@NotNull
@SafeHtml
private String roleName;
@Column(name = "active_yn", length = 1, columnDefinition = "character varying(1) default 'y'", nullable = false)
@NotNull
private Boolean activeYn;
@Column(name = "priority", length = 4, columnDefinition = "decimal(4,0) DEFAULT NULL")
@Digits(integer = 4, fraction = 0)
private Long priority;
@Column(name = "app_Id", length = 11, columnDefinition = "int(11) default null")
@Digits(integer = 11, fraction = 0)
private Long appId;
@Column(name = "app_role_id", length = 11, columnDefinition = "int(11) default null")
@Digits(integer = 11, fraction = 0)
private Long appRoleId;
@OneToMany(
targetEntity = FnRoleFunction.class,
mappedBy = "roleId",
cascade = CascadeType.ALL,
fetch = FetchType.LAZY
)
private Set<FnRoleFunction> fnRoleFunctions;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(
name = "fn_user_pseudo_role",
joinColumns = {@JoinColumn(name = "pseudo_role_Id", referencedColumnName = "role_id")},
inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "user_id")},
indexes = {
@Index(name = "fk_pseudo_role_user_id", columnList = "user_id")
}
)
private Set<FnUser> fnUsers;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(
name = "fn_role_composite",
joinColumns = {@JoinColumn(name = "parent_role_id", referencedColumnName = "role_id")},
inverseJoinColumns = {@JoinColumn(name = "child_role_id", referencedColumnName = "role_id")},
indexes = {
@Index(name = "fk_fn_role_composite_child", columnList = "child_role_id")
}
)
private Set<FnRole> fnRoles;
@ManyToMany(cascade = CascadeType.ALL,
fetch = FetchType.LAZY)
private Set<FnRole> fnRoleList;
@OneToMany(
targetEntity = EpRoleNotification.class,
mappedBy = "notificationID",
cascade = CascadeType.ALL,
fetch = FetchType.LAZY
)
private Set<EpRoleNotification> epRoleNotifications;
@OneToMany(
targetEntity = FnMenuFunctionalRoles.class,
mappedBy = "roleId",
cascade = CascadeType.ALL,
fetch = FetchType.LAZY
)
private Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles;
@OneToMany(
targetEntity = EpWidgetCatalogRole.class,
mappedBy = "roleId",
cascade = CascadeType.ALL,
fetch = FetchType.LAZY
)
private Set<EpWidgetCatalogRole> epWidgetCatalogRoles;
@OneToMany(
targetEntity = EpAppRoleFunction.class,
mappedBy = "fnRole",
cascade = CascadeType.ALL,
fetch = FetchType.LAZY
)
private Set<EpAppRoleFunction> epAppRoleFunctions;
@OneToMany(
targetEntity = EpUserRolesRequestDet.class,
mappedBy = "requestedRoleId",
cascade = CascadeType.ALL,
fetch = FetchType.LAZY
)
private Set<EpUserRolesRequestDet> epUserRolesRequestDets;
@OneToMany(
targetEntity = FnUserRole.class,
mappedBy = "roleId",
cascade = CascadeType.ALL,
fetch = FetchType.LAZY
)
private Set<FnUserRole> fnUserRoles;
}
|