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;
67 import lombok.NoArgsConstructor;
69 import org.hibernate.validator.constraints.SafeHtml;
70 import org.onap.portal.domain.db.ep.EpAppRoleFunction;
71 import org.onap.portal.domain.db.ep.EpRoleNotification;
72 import org.onap.portal.domain.db.ep.EpUserRolesRequestDet;
73 import org.onap.portal.domain.db.ep.EpWidgetCatalogRole;
74 import org.onap.portal.domain.dto.DomainVo;
77 CREATE TABLE `fn_role` (
78 `role_id` int(11) NOT NULL AUTO_INCREMENT,
79 `role_name` varchar(300) NOT NULL,
80 `active_yn` varchar(1) NOT NULL DEFAULT 'y',
81 `priority` decimal(4,0) DEFAULT NULL,
82 `app_id` int(11) DEFAULT NULL,
83 `app_role_id` int(11) DEFAULT NULL,
84 PRIMARY KEY (`role_id`),
85 UNIQUE KEY `fn_role_name_app_id_idx` (`role_name`,`app_id`) USING BTREE
91 name = "FnRole.retrieveAppRolesByRoleNameAndByAppId",
92 query = "FROM FnRole where roleName =:roleName and appId =:appId"),
94 name = "FnRole.retrieveAppRolesByAppId",
95 query = "FROM FnRole where appId =:appId"),
97 name = "FnRole.retrieveAppRolesWhereAppIdIsNull",
98 query = "FROM FnRole where appId is null"),
100 name = "FnRole.retrieveAppRoleByRoleIdWhereAppIdIsNull",
101 query = "FROM FnRole where roleId =:roleId and appId is null"),
103 name = "FnRole.retrieveAppRoleByAppRoleIdAndByAppId",
104 query = "FROM FnRole where appRoleId =:appRoleId and appId =:appId"),
106 name = "FnRole.retrieveAppRoleByRoleIdAndAppId",
107 query = "FROM FnRole where roleId =:roleId and appId =:appId"),
109 name = "FnRole.retrieveAppRolesByRoleNameAndWhereAppIdIsNull",
110 query = "FROM FnRole where roleName =:roleName and appId is null"),
112 name = "FnRole.retrieveActiveRolesOfApplication",
113 query = "from FnRole where active_yn = 'Y' and appId=:appId"),
115 name = "FnRole.getUserRoleOnUserIdAndAppId",
118 + " FnUserRole fur\n"
120 + " fr.roleId = fur.roleId\n"
121 + " AND fur.userId = :userId"
122 + " AND fur.appId = :appId\n"
123 + " AND fr.activeYn = 'y'")
126 @Table(name = "fn_role", indexes = {
127 @Index(name = "fn_role_name_app_id_idx", columnList = "role_name, app_id", unique = true)
134 public class FnRole extends DomainVo implements Serializable {
137 @GeneratedValue(strategy = GenerationType.AUTO)
138 @Column(name = "role_id", length = 11, nullable = false)
139 @Digits(integer = 11, fraction = 0)
141 @Column(name = "role_name", length = 300, nullable = false)
145 private String roleName;
146 @Column(name = "active_yn", length = 1, columnDefinition = "character varying(1) default 'y'", nullable = false)
148 private Boolean activeYn;
149 @Column(name = "priority", length = 4, columnDefinition = "decimal(4,0) DEFAULT NULL")
150 @Digits(integer = 4, fraction = 0)
151 private Integer priority;
152 @Column(name = "app_Id", length = 11, columnDefinition = "int(11) default null")
153 @Digits(integer = 11, fraction = 0)
155 @Column(name = "app_role_id", length = 11, columnDefinition = "int(11) default null")
156 @Digits(integer = 11, fraction = 0)
157 private Long appRoleId;
159 targetEntity = FnRoleFunction.class,
161 cascade = CascadeType.ALL,
162 fetch = FetchType.LAZY
164 private Set<FnRoleFunction> fnRoleFunctions;
165 @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
167 name = "fn_user_pseudo_role",
168 joinColumns = {@JoinColumn(name = "pseudo_role_Id", referencedColumnName = "role_id")},
169 inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "user_id")},
171 @Index(name = "fk_pseudo_role_user_id", columnList = "user_id")
174 private Set<FnUser> fnUsers;
176 targetEntity = FnRoleComposite.class,
177 mappedBy = "childRoles",
178 cascade = CascadeType.ALL,
179 fetch = FetchType.LAZY
181 private Set<FnRoleComposite> childRoles;
183 targetEntity = FnRoleComposite.class,
184 mappedBy = "parentRoles",
185 cascade = CascadeType.ALL,
186 fetch = FetchType.LAZY
188 private Set<FnRoleComposite> parentRoles;
189 @ManyToMany(cascade = CascadeType.ALL,
190 fetch = FetchType.LAZY)
191 private Set<FnRoleFunction> roleFunctions;
193 targetEntity = EpRoleNotification.class,
194 mappedBy = "notificationID",
195 cascade = CascadeType.ALL,
196 fetch = FetchType.LAZY
198 private Set<EpRoleNotification> epRoleNotifications;
200 targetEntity = FnMenuFunctionalRoles.class,
202 cascade = CascadeType.ALL,
203 fetch = FetchType.LAZY
205 private Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles;
207 targetEntity = EpWidgetCatalogRole.class,
209 cascade = CascadeType.ALL,
210 fetch = FetchType.LAZY
212 private Set<EpWidgetCatalogRole> epWidgetCatalogRoles;
214 targetEntity = EpAppRoleFunction.class,
216 cascade = CascadeType.ALL,
217 fetch = FetchType.LAZY
219 private Set<EpAppRoleFunction> epAppRoleFunctions;
221 targetEntity = EpUserRolesRequestDet.class,
222 mappedBy = "requestedRoleId",
223 cascade = CascadeType.ALL,
224 fetch = FetchType.LAZY
226 private Set<EpUserRolesRequestDet> epUserRolesRequestDets;
228 targetEntity = FnUserRole.class,
230 cascade = CascadeType.ALL,
231 fetch = FetchType.LAZY
233 private Set<FnUserRole> fnUserRoles;
235 public FnRole(Long roleId, String roleName, Boolean activeYn, Integer priority,
236 Set<FnRoleFunction> fnRoleFunctions, Set<FnRoleComposite> childRoles,
237 Set<FnRoleComposite> parentRoles) {
238 this.roleId = roleId;
239 this.roleName = roleName;
240 this.activeYn = activeYn;
241 this.priority = priority;
242 this.fnRoleFunctions = fnRoleFunctions;
243 this.childRoles = childRoles;
244 this.parentRoles = parentRoles;