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"
115 @Table(name = "fn_app")
118 @EqualsAndHashCode(callSuper = true)
122 public class FnApp extends DomainVo implements Serializable {
124 @Column(name = "app_name", length = 100, nullable = false, columnDefinition = "varchar(100) not null default '?'")
128 private String appName = "?";
129 @Column(name = "app_image_url", length = 256)
132 private String appImageUrl;
133 @Column(name = "app_description", length = 512)
136 private String appDescription;
137 @Column(name = "app_notes", length = 4096)
140 private String appNotes;
141 @Column(name = "app_url", length = 256)
146 private String appUrl;
147 @Column(name = "app_alternate_url", length = 256)
150 private String appAlternateUrl;
151 @Column(name = "app_rest_endpoint", length = 2000)
154 private String appRestEndpoint;
155 @Column(name = "ml_app_name", length = 50, nullable = false, columnDefinition = "varchar(50) not null default '?'")
159 private String mlAppName = "?";
160 @Column(name = "ml_app_admin_id", length = 7, nullable = false, columnDefinition = "varchar(7) not null default '?'")
163 private String mlAppAdminId = "?";
164 @Column(name = "mots_id", length = 11)
165 @Digits(integer = 11, fraction = 0)
167 @Column(name = "app_password", length = 256, nullable = false, columnDefinition = "varchar(256) not null default '?'")
171 private String appPassword = "?";
172 @Column(name = "open")
173 private Boolean open = false;
174 @Column(name = "enabled")
175 private Boolean enabled = false;
176 @Column(name = "active_yn")
178 private Boolean activeYn = true;
179 @Column(name = "_thumbnail", columnDefinition = "mediumblob null default null")
180 private byte[] thumbnail;
181 @Column(name = "app_username", length = 50)
184 private String appUsername;
185 @Column(name = "ueb_key", length = 256)
188 private String uebKey;
189 @Column(name = "ueb_secret", length = 256)
192 private String uebSecret;
193 @Column(name = "ueb_topic_name", length = 256)
196 private String uebTopicName;
197 @Column(name = "app_type", length = 11, columnDefinition = "int(11) not null default 1")
198 @Digits(integer = 11, fraction = 0)
199 private Long appType = 1L;
200 @Column(name = "auth_central", length = 1, nullable = false)
201 private Boolean authCentral;
202 @Column(name = "auth_namespace", length = 100)
205 private String authNamespace;
207 targetEntity = FnMenuFunctionalRoles.class,
209 cascade = CascadeType.MERGE,
210 fetch = FetchType.LAZY
212 private Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles;
214 targetEntity = EpUserRolesRequest.class,
216 cascade = CascadeType.MERGE,
217 fetch = FetchType.LAZY
219 private Set<EpUserRolesRequest> epUserRolesRequests;
221 targetEntity = EpAppFunction.class,
223 cascade = CascadeType.MERGE,
224 fetch = FetchType.LAZY
226 private Set<EpAppFunction> epAppFunctions;
228 targetEntity = EpAppRoleFunction.class,
230 cascade = CascadeType.MERGE,
231 fetch = FetchType.LAZY
233 private Set<EpAppRoleFunction> epAppRoleFunctions;
235 targetEntity = FnUserRole.class,
236 mappedBy = "fnAppId",
237 cascade = CascadeType.MERGE,
238 fetch = FetchType.LAZY
240 private Set<FnUserRole> fnUserRoles;
242 targetEntity = EpWebAnalyticsSource.class,
244 cascade = CascadeType.MERGE,
245 fetch = FetchType.LAZY
247 private Set<EpWebAnalyticsSource> epWebAnalyticsSources;
249 targetEntity = EpWidgetCatalogRole.class,
251 cascade = CascadeType.MERGE,
252 fetch = FetchType.LAZY
254 private Set<EpWidgetCatalogRole> epWidgetCatalogRoles;
256 targetEntity = EpMicroservice.class,
258 cascade = CascadeType.MERGE,
259 fetch = FetchType.LAZY
261 private Set<EpMicroservice> epMicroservices;
263 targetEntity = FnPersUserAppSel.class,
265 cascade = CascadeType.MERGE,
266 fetch = FetchType.LAZY
268 private Set<FnPersUserAppSel> fnPersUserAppSels;
270 public Boolean isRestrictedApp() {
271 return (this.appType == 2);
275 public FnApp(@Digits(integer = 11, fraction = 0) Long id, LocalDateTime created,
276 LocalDateTime modified, Long rowNum, Serializable auditUserId,
277 DomainVo createdId, DomainVo modifiedId, Set<DomainVo> fnUsersCreatedId,
278 Set<DomainVo> fnUsersModifiedId,
279 @Size(max = 100) @SafeHtml @NotNull String appName,
280 @Size(max = 256) @SafeHtml String appImageUrl,
281 @Size(max = 256) @SafeHtml String appDescription,
282 @Size(max = 4096) @SafeHtml String appNotes,
283 @Size(max = 256) @SafeHtml @URL String appUrl,
284 @Size(max = 256) @SafeHtml String appAlternateUrl,
285 @Size(max = 2000) @SafeHtml String appRestEndpoint,
286 @Size(max = 50) @SafeHtml @NotNull String mlAppName,
287 @Size(max = 7) @SafeHtml @NotNull String mlAppAdminId,
288 @Digits(integer = 11, fraction = 0) Long motsId,
289 @Size(max = 256) @SafeHtml @NotNull String appPassword, Boolean open, Boolean enabled, Boolean activeYn, byte[] thumbnail,
290 @Size(max = 50) @SafeHtml String appUsername,
291 @Size(max = 256) @SafeHtml String uebKey,
292 @Size(max = 256) @SafeHtml String uebSecret,
293 @Size(max = 256) @SafeHtml String uebTopicName,
294 @Digits(integer = 11, fraction = 0) Long appType, Boolean authCentral,
295 @Size(max = 100) @SafeHtml String authNamespace,
296 Set<FnMenuFunctionalRoles> fnMenuFunctionalRoles,
297 Set<EpUserRolesRequest> epUserRolesRequests,
298 Set<EpAppFunction> epAppFunctions, Set<EpAppRoleFunction> epAppRoleFunctions,
299 Set<FnUserRole> fnUserRoles, Set<EpWebAnalyticsSource> epWebAnalyticsSources,
300 Set<EpWidgetCatalogRole> epWidgetCatalogRoles,
301 Set<EpMicroservice> epMicroservices, Set<FnPersUserAppSel> fnPersUserAppSels) {
302 super(id, created, modified, rowNum, auditUserId, createdId, modifiedId, fnUsersCreatedId, fnUsersModifiedId);
303 this.appName = appName;
304 this.appImageUrl = appImageUrl;
305 this.appDescription = appDescription;
306 this.appNotes = appNotes;
307 this.appUrl = appUrl;
308 this.appAlternateUrl = appAlternateUrl;
309 this.appRestEndpoint = appRestEndpoint;
310 this.mlAppName = mlAppName;
311 this.mlAppAdminId = mlAppAdminId;
312 this.motsId = motsId;
313 this.appPassword = appPassword;
315 this.enabled = enabled;
316 this.activeYn = activeYn;
317 this.thumbnail = thumbnail;
318 this.appUsername = appUsername;
319 this.uebKey = uebKey;
320 this.uebSecret = uebSecret;
321 this.uebTopicName = uebTopicName;
322 this.appType = appType;
323 this.authCentral = authCentral;
324 this.authNamespace = authNamespace;
325 this.fnMenuFunctionalRoles = fnMenuFunctionalRoles;
326 this.epUserRolesRequests = epUserRolesRequests;
327 this.epAppFunctions = epAppFunctions;
328 this.epAppRoleFunctions = epAppRoleFunctions;
329 this.fnUserRoles = fnUserRoles;
330 this.epWebAnalyticsSources = epWebAnalyticsSources;
331 this.epWidgetCatalogRoles = epWidgetCatalogRoles;
332 this.epMicroservices = epMicroservices;
333 this.fnPersUserAppSels = fnPersUserAppSels;