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;
44 import java.time.LocalDateTime;
46 import javax.persistence.CascadeType;
47 import javax.persistence.Column;
48 import javax.persistence.Entity;
49 import javax.persistence.FetchType;
50 import javax.persistence.NamedQueries;
51 import javax.persistence.NamedQuery;
52 import javax.persistence.OneToMany;
53 import javax.persistence.Table;
54 import javax.validation.constraints.Digits;
55 import javax.validation.constraints.NotNull;
56 import javax.validation.constraints.Pattern;
57 import javax.validation.constraints.Size;
58 import lombok.AllArgsConstructor;
59 import lombok.Builder;
60 import lombok.EqualsAndHashCode;
62 import lombok.NoArgsConstructor;
64 import org.hibernate.validator.constraints.SafeHtml;
65 import org.hibernate.validator.constraints.URL;
66 import org.onap.portal.domain.db.ep.EpAppFunction;
67 import org.onap.portal.domain.db.ep.EpAppRoleFunction;
68 import org.onap.portal.domain.db.ep.EpMicroservice;
69 import org.onap.portal.domain.db.ep.EpUserRolesRequest;
70 import org.onap.portal.domain.db.ep.EpWebAnalyticsSource;
71 import org.onap.portal.domain.db.ep.EpWidgetCatalogRole;
72 import org.onap.portal.domain.db.DomainVo;
75 CREATE TABLE `fn_app` (
76 `app_id` int(11) NOT NULL AUTO_INCREMENT,
77 `app_name` varchar(100) NOT NULL DEFAULT '?',
78 `app_image_url` varchar(256) DEFAULT NULL,
79 `app_description` varchar(512) DEFAULT NULL,
80 `app_notes` varchar(4096) DEFAULT NULL,
81 `app_url` varchar(256) DEFAULT NULL,
82 `app_alternate_url` varchar(256) DEFAULT NULL,
83 `app_rest_endpoint` varchar(2000) DEFAULT NULL,
84 `ml_app_name` varchar(50) NOT NULL DEFAULT '?',
85 `ml_app_admin_id` varchar(7) NOT NULL DEFAULT '?',
86 `mots_id` int(11) DEFAULT NULL,
87 `app_password` varchar(256) NOT NULL DEFAULT '?',
88 `open` char(1) DEFAULT 'N',
89 `enabled` char(1) DEFAULT 'Y',
90 `thumbnail` mediumblob DEFAULT NULL,
91 `app_username` varchar(50) DEFAULT NULL,
92 `ueb_key` varchar(256) DEFAULT NULL,
93 `ueb_secret` varchar(256) DEFAULT NULL,
94 `ueb_topic_name` varchar(256) DEFAULT NULL,
95 `app_type` int(11) NOT NULL DEFAULT 1,
96 `auth_central` char(1) NOT NULL DEFAULT 'N',
97 `auth_namespace` varchar(100) DEFAULT NULL,
98 PRIMARY KEY (`app_id`)
104 name = "FnApp.retrieveWhereAuthCentralIsYAndOpenIsNAndAuthNamespaceIsNotNull",
105 query = "from FnApp where authCentral = 'Y' and open = 'N' and authNamespace is not null"),
107 name = "FnApp.getByUebKey",
108 query = "from FnApp where uebKey = :uebKey"),
110 name = "FnApp.getCentralizedApps",
111 query = "from FnApp where authCentral = 'Y' and open = 'N' and authNamespace is not null"),
113 name = "FnApp.retrieveWhereAppName",
114 query = "FROM FnApp WHERE appName = :appName"
118 //TODO appName as unique index?
120 @Table(name = "fn_app")
123 @EqualsAndHashCode(callSuper = true)
127 public class FnApp extends DomainVo implements Serializable {
129 @Column(name = "app_name", length = 100, nullable = false, columnDefinition = "varchar(100) not null default '?'")
133 private String appName = "?";
134 @Column(name = "app_image_url", length = 256)
137 private String appImageUrl;
138 @Column(name = "app_description", length = 512)
141 private String appDescription;
142 @Column(name = "app_notes", length = 4096)
145 private String appNotes;
146 @Column(name = "app_url", length = 256)
151 private String appUrl;
152 @Column(name = "app_alternate_url", length = 256)
155 private String appAlternateUrl;
156 @Column(name = "app_rest_endpoint", length = 2000)
159 private String appRestEndpoint;
160 @Column(name = "ml_app_name", length = 50, nullable = false, columnDefinition = "varchar(50) not null default '?'")
164 private String mlAppName = "?";
165 @Column(name = "ml_app_admin_id", length = 7, nullable = false, columnDefinition = "varchar(7) not null default '?'")
168 private String mlAppAdminId = "?";
169 @Column(name = "mots_id", length = 11)
170 @Digits(integer = 11, fraction = 0)
172 @Column(name = "app_password", length = 256, nullable = false, columnDefinition = "varchar(256) not null default '?'")
176 private String appPassword = "?";
177 @Column(name = "open")
178 private Boolean open = false;
179 @Column(name = "enabled")
180 private Boolean enabled = false;
181 @Column(name = "active_yn")
183 private Boolean activeYn = true;
184 @Column(name = "_thumbnail", columnDefinition = "mediumblob null default null")
185 private byte[] thumbnail;
186 @Column(name = "app_username", length = 50)
189 private String appUsername;
190 @Column(name = "ueb_key", length = 256)
193 private String uebKey;
194 @Column(name = "ueb_secret", length = 256)
197 private String uebSecret;
198 @Column(name = "ueb_topic_name", length = 256)
201 private String uebTopicName;
202 @Column(name = "app_type", length = 11, columnDefinition = "int(11) not null default 1")
203 @Digits(integer = 11, fraction = 0)
204 private Long appType = 1L;
205 @Column(name = "auth_central", length = 1, nullable = false)
206 private Boolean authCentral;
207 @Column(name = "auth_namespace", length = 100)
210 private String authNamespace;
212 targetEntity = FnMenuFunctionalRoles.class,
214 cascade = CascadeType.MERGE,
215 fetch = FetchType.LAZY
217 private Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles;
219 targetEntity = EpUserRolesRequest.class,
221 cascade = CascadeType.MERGE,
222 fetch = FetchType.LAZY
224 private Set<EpUserRolesRequest> epUserRolesRequests;
226 targetEntity = EpAppFunction.class,
228 cascade = CascadeType.MERGE,
229 fetch = FetchType.LAZY
231 private Set<EpAppFunction> epAppFunctions;
233 targetEntity = EpAppRoleFunction.class,
235 cascade = CascadeType.MERGE,
236 fetch = FetchType.LAZY
238 private Set<EpAppRoleFunction> epAppRoleFunctions;
240 targetEntity = FnUserRole.class,
241 mappedBy = "fnAppId",
242 cascade = CascadeType.MERGE,
243 fetch = FetchType.LAZY
245 private Set<FnUserRole> fnUserRoles;
247 targetEntity = EpWebAnalyticsSource.class,
249 cascade = CascadeType.MERGE,
250 fetch = FetchType.LAZY
252 private Set<EpWebAnalyticsSource> epWebAnalyticsSources;
254 targetEntity = EpWidgetCatalogRole.class,
256 cascade = CascadeType.MERGE,
257 fetch = FetchType.LAZY
259 private Set<EpWidgetCatalogRole> epWidgetCatalogRoles;
261 targetEntity = EpMicroservice.class,
263 cascade = CascadeType.MERGE,
264 fetch = FetchType.LAZY
266 private Set<EpMicroservice> epMicroservices;
268 targetEntity = FnPersUserAppSel.class,
270 cascade = CascadeType.MERGE,
271 fetch = FetchType.LAZY
273 private Set<FnPersUserAppSel> fnPersUserAppSels;
275 public Boolean isRestrictedApp() {
276 return (this.appType == 2);
280 public FnApp(@Digits(integer = 11, fraction = 0) Long id, LocalDateTime created,
281 LocalDateTime modified, Long rowNum, Serializable auditUserId,
282 DomainVo createdId, DomainVo modifiedId, Set<DomainVo> fnUsersCreatedId,
283 Set<DomainVo> fnUsersModifiedId,
284 @Size(max = 100) @SafeHtml @NotNull String appName,
285 @Size(max = 256) @SafeHtml String appImageUrl,
286 @Size(max = 256) @SafeHtml String appDescription,
287 @Size(max = 4096) @SafeHtml String appNotes,
288 @Size(max = 256) @SafeHtml @URL String appUrl,
289 @Size(max = 256) @SafeHtml String appAlternateUrl,
290 @Size(max = 2000) @SafeHtml String appRestEndpoint,
291 @Size(max = 50) @SafeHtml @NotNull String mlAppName,
292 @Size(max = 7) @SafeHtml @NotNull String mlAppAdminId,
293 @Digits(integer = 11, fraction = 0) Long motsId,
294 @Size(max = 256) @SafeHtml @NotNull String appPassword, Boolean open, Boolean enabled, Boolean activeYn, byte[] thumbnail,
295 @Size(max = 50) @SafeHtml String appUsername,
296 @Size(max = 256) @SafeHtml String uebKey,
297 @Size(max = 256) @SafeHtml String uebSecret,
298 @Size(max = 256) @SafeHtml String uebTopicName,
299 @Digits(integer = 11, fraction = 0) Long appType, Boolean authCentral,
300 @Size(max = 100) @SafeHtml String authNamespace,
301 Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles,
302 Set<EpUserRolesRequest> epUserRolesRequests,
303 Set<EpAppFunction> epAppFunctions, Set<EpAppRoleFunction> epAppRoleFunctions,
304 Set<FnUserRole> fnUserRoles, Set<EpWebAnalyticsSource> epWebAnalyticsSources,
305 Set<EpWidgetCatalogRole> epWidgetCatalogRoles,
306 Set<EpMicroservice> epMicroservices, Set<FnPersUserAppSel> fnPersUserAppSels) {
307 super(id, created, modified, rowNum, auditUserId, createdId, modifiedId, fnUsersCreatedId, fnUsersModifiedId);
308 this.appName = appName;
309 this.appImageUrl = appImageUrl;
310 this.appDescription = appDescription;
311 this.appNotes = appNotes;
312 this.appUrl = appUrl;
313 this.appAlternateUrl = appAlternateUrl;
314 this.appRestEndpoint = appRestEndpoint;
315 this.mlAppName = mlAppName;
316 this.mlAppAdminId = mlAppAdminId;
317 this.motsId = motsId;
318 this.appPassword = appPassword;
320 this.enabled = enabled;
321 this.activeYn = activeYn;
322 this.thumbnail = thumbnail;
323 this.appUsername = appUsername;
324 this.uebKey = uebKey;
325 this.uebSecret = uebSecret;
326 this.uebTopicName = uebTopicName;
327 this.appType = appType;
328 this.authCentral = authCentral;
329 this.authNamespace = authNamespace;
330 this.fnMenuFunctionalRoles = fnMenuFunctionalRoles;
331 this.epUserRolesRequests = epUserRolesRequests;
332 this.epAppFunctions = epAppFunctions;
333 this.epAppRoleFunctions = epAppRoleFunctions;
334 this.fnUserRoles = fnUserRoles;
335 this.epWebAnalyticsSources = epWebAnalyticsSources;
336 this.epWidgetCatalogRoles = epWidgetCatalogRoles;
337 this.epMicroservices = epMicroservices;
338 this.fnPersUserAppSels = fnPersUserAppSels;