2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ===================================================================
10 * Unless otherwise specified, all software contained herein is licensed
11 * under the Apache License, Version 2.0 (the "License");
12 * you may not use this software except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * Unless otherwise specified, all documentation contained herein is licensed
24 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
25 * you may not use this documentation except in compliance with the License.
26 * You may obtain a copy of the License at
28 * https://creativecommons.org/licenses/by/4.0/
30 * Unless required by applicable law or agreed to in writing, documentation
31 * distributed under the License is distributed on an "AS IS" BASIS,
32 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 * See the License for the specific language governing permissions and
34 * limitations under the License.
36 * ============LICENSE_END============================================
41 package org.onap.portal.domain.db.fn;
43 import java.io.Serializable;
45 import javax.persistence.CascadeType;
46 import javax.persistence.Column;
47 import javax.persistence.Embeddable;
48 import javax.persistence.Entity;
49 import javax.persistence.FetchType;
50 import javax.persistence.GeneratedValue;
51 import javax.persistence.GenerationType;
52 import javax.persistence.Id;
53 import javax.persistence.IdClass;
54 import javax.persistence.Index;
55 import javax.persistence.JoinColumn;
56 import javax.persistence.JoinTable;
57 import javax.persistence.ManyToMany;
58 import javax.persistence.NamedQueries;
59 import javax.persistence.NamedQuery;
60 import javax.persistence.OneToMany;
61 import javax.persistence.Table;
62 import javax.validation.constraints.Digits;
63 import javax.validation.constraints.NotNull;
64 import javax.validation.constraints.Size;
65 import lombok.AllArgsConstructor;
66 import lombok.Builder;
68 import lombok.NoArgsConstructor;
70 import org.hibernate.validator.constraints.SafeHtml;
71 import org.onap.portal.domain.db.ep.EpAppRoleFunction;
72 import org.onap.portal.domain.db.ep.EpRoleNotification;
73 import org.onap.portal.domain.db.ep.EpUserRolesRequestDet;
74 import org.onap.portal.domain.db.ep.EpWidgetCatalogRole;
75 import org.onap.portal.domain.dto.DomainVo;
78 CREATE TABLE `fn_role` (
79 `role_id` int(11) NOT NULL AUTO_INCREMENT,
80 `role_name` varchar(300) NOT NULL,
81 `active_yn` varchar(1) NOT NULL DEFAULT 'y',
82 `priority` decimal(4,0) DEFAULT NULL,
83 `app_id` int(11) DEFAULT NULL,
84 `app_role_id` int(11) DEFAULT NULL,
85 PRIMARY KEY (`role_id`),
86 UNIQUE KEY `fn_role_name_app_id_idx` (`role_name`,`app_id`) USING BTREE
92 name = "FnRole.retrieveAppRolesByRoleNameAndByAppId",
93 query = "FROM FnRole where roleName =:roleName and appId =:appId"),
95 name = "FnRole.retrieveAppRolesByAppId",
96 query = "FROM FnRole where appId =:appId"),
98 name = "FnRole.retrieveAppRolesWhereAppIdIsNull",
99 query = "FROM FnRole where appId is null"),
101 name = "FnRole.retrieveAppRoleByRoleIdWhereAppIdIsNull",
102 query = "FROM FnRole where roleId =:roleId and appId is null"),
104 name = "FnRole.retrieveAppRoleByAppRoleIdAndByAppId",
105 query = "FROM FnRole where appRoleId =:appRoleId and appId =:appId"),
107 name = "FnRole.retrieveAppRoleByRoleIdAndAppId",
108 query = "FROM FnRole where roleId =:roleId and appId =:appId"),
110 name = "FnRole.retrieveAppRolesByRoleNameAndWhereAppIdIsNull",
111 query = "FROM FnRole where roleName =:roleName and appId is null"),
113 name = "FnRole.retrieveActiveRolesOfApplication",
114 query = "from FnRole where activeYn = 'Y' and appId=:appId"),
116 name = "FnRole.getUserRoleOnUserIdAndAppId",
119 + " FnUserRole fur\n"
121 + " fr.roleId = fur.roleId\n"
122 + " AND fur.userId = :userId"
123 + " AND fur.appId = :appId\n"
124 + " AND fr.activeYn = 'y'"),
126 name = "FnRole.getGlobalRolesOfPortal",
130 + " roleName like 'global_%'"
131 + " and appId is null"
132 + " and activeYn = 'Y'"
136 @Table(name = "fn_role", indexes = {
137 @Index(name = "fn_role_name_app_id_idx", columnList = "role_name, app_id", unique = true)
145 public class FnRole extends DomainVo implements Serializable {
148 @GeneratedValue(strategy = GenerationType.AUTO)
149 @Column(name = "role_id", length = 11, nullable = false)
150 @Digits(integer = 11, fraction = 0)
152 @Column(name = "role_name", length = 300, nullable = false)
156 private String roleName;
157 @Column(name = "active_yn", length = 1, columnDefinition = "character varying(1) default 'y'", nullable = false)
159 private Boolean activeYn;
160 @Column(name = "priority", length = 4, columnDefinition = "decimal(4,0) DEFAULT NULL")
161 @Digits(integer = 4, fraction = 0)
162 private Integer priority;
163 @Column(name = "app_Id", length = 11, columnDefinition = "int(11) default null")
164 @Digits(integer = 11, fraction = 0)
166 @Column(name = "app_role_id", length = 11, columnDefinition = "int(11) default null")
167 @Digits(integer = 11, fraction = 0)
168 private Long appRoleId;
170 targetEntity = FnRoleFunction.class,
172 cascade = CascadeType.ALL,
173 fetch = FetchType.LAZY
175 private Set<FnRoleFunction> fnRoleFunctions;
176 @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
178 name = "fn_user_pseudo_role",
179 joinColumns = {@JoinColumn(name = "pseudo_role_Id", referencedColumnName = "role_id")},
180 inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "user_id")},
182 @Index(name = "fk_pseudo_role_user_id", columnList = "user_id")
185 private Set<FnUser> fnUsers;
187 targetEntity = FnRoleComposite.class,
188 mappedBy = "childRoles",
189 cascade = CascadeType.ALL,
190 fetch = FetchType.LAZY
192 private Set<FnRoleComposite> childRoles;
194 targetEntity = FnRoleComposite.class,
195 mappedBy = "parentRoles",
196 cascade = CascadeType.ALL,
197 fetch = FetchType.LAZY
199 private Set<FnRoleComposite> parentRoles;
200 @ManyToMany(cascade = CascadeType.ALL,
201 fetch = FetchType.LAZY)
202 private Set<FnRoleFunction> roleFunctions;
204 targetEntity = EpRoleNotification.class,
205 mappedBy = "notificationID",
206 cascade = CascadeType.ALL,
207 fetch = FetchType.LAZY
209 private Set<EpRoleNotification> epRoleNotifications;
211 targetEntity = FnMenuFunctionalRoles.class,
213 cascade = CascadeType.ALL,
214 fetch = FetchType.LAZY
216 private Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles;
218 targetEntity = EpWidgetCatalogRole.class,
220 cascade = CascadeType.ALL,
221 fetch = FetchType.LAZY
223 private Set<EpWidgetCatalogRole> epWidgetCatalogRoles;
225 targetEntity = EpAppRoleFunction.class,
227 cascade = CascadeType.ALL,
228 fetch = FetchType.LAZY
230 private Set<EpAppRoleFunction> epAppRoleFunctions;
232 targetEntity = EpUserRolesRequestDet.class,
233 mappedBy = "requestedRoleId",
234 cascade = CascadeType.ALL,
235 fetch = FetchType.LAZY
237 private Set<EpUserRolesRequestDet> epUserRolesRequestDets;
239 targetEntity = FnUserRole.class,
241 cascade = CascadeType.ALL,
242 fetch = FetchType.LAZY
244 private Set<FnUserRole> fnUserRoles;
246 public FnRole(Long roleId, String roleName, Boolean activeYn, Integer priority,
247 Set<FnRoleFunction> fnRoleFunctions, Set<FnRoleComposite> childRoles,
248 Set<FnRoleComposite> parentRoles) {
249 this.roleId = roleId;
250 this.roleName = roleName;
251 this.activeYn = activeYn;
252 this.priority = priority;
253 this.fnRoleFunctions = fnRoleFunctions;
254 this.childRoles = childRoles;
255 this.parentRoles = parentRoles;