ffc6667a6b5f0cd806adfcc9f6d4b1f159869aee
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / db / fn / FnApp.java
1 /*
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  * Modifications Copyright (c) 2019 Samsung
8  * ===================================================================
9  *
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
14  *
15  *             http://www.apache.org/licenses/LICENSE-2.0
16  *
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.
22  *
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
27  *
28  *             https://creativecommons.org/licenses/by/4.0/
29  *
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.
35  *
36  * ============LICENSE_END============================================
37  *
38  *
39  */
40
41 package org.onap.portal.domain.db.fn;
42
43 import java.io.Serializable;
44 import java.util.ArrayList;
45 import java.util.List;
46 import javax.persistence.CascadeType;
47 import javax.persistence.Column;
48 import javax.persistence.Embeddable;
49 import javax.persistence.Entity;
50 import javax.persistence.FetchType;
51 import javax.persistence.GeneratedValue;
52 import javax.persistence.GenerationType;
53 import javax.persistence.Id;
54 import javax.persistence.NamedQueries;
55 import javax.persistence.NamedQuery;
56 import javax.persistence.OneToMany;
57 import javax.persistence.Table;
58 import javax.validation.constraints.Digits;
59 import javax.validation.constraints.NotNull;
60 import javax.validation.constraints.Pattern;
61 import javax.validation.constraints.Size;
62 import lombok.AllArgsConstructor;
63 import lombok.EqualsAndHashCode;
64 import lombok.Getter;
65 import lombok.NoArgsConstructor;
66 import lombok.Setter;
67 import org.hibernate.validator.constraints.SafeHtml;
68 import org.hibernate.validator.constraints.URL;
69 import org.onap.portal.domain.dto.DomainVo;
70
71 /*
72 CREATE TABLE `fn_app` (
73         `app_id` int(11) NOT NULL AUTO_INCREMENT,
74         `app_name` varchar(100) NOT NULL DEFAULT '?',
75         `app_image_url` varchar(256) DEFAULT NULL,
76         `app_description` varchar(512) DEFAULT NULL,
77         `app_notes` varchar(4096) DEFAULT NULL,
78         `app_url` varchar(256) DEFAULT NULL,
79         `app_alternate_url` varchar(256) DEFAULT NULL,
80         `app_rest_endpoint` varchar(2000) DEFAULT NULL,
81         `ml_app_name` varchar(50) NOT NULL DEFAULT '?',
82         `ml_app_admin_id` varchar(7) NOT NULL DEFAULT '?',
83         `mots_id` int(11) DEFAULT NULL,
84         `app_password` varchar(256) NOT NULL DEFAULT '?',
85         `open` char(1) DEFAULT 'N',
86         `enabled` char(1) DEFAULT 'Y',
87         `thumbnail` mediumblob DEFAULT NULL,
88         `app_username` varchar(50) DEFAULT NULL,
89         `ueb_key` varchar(256) DEFAULT NULL,
90         `ueb_secret` varchar(256) DEFAULT NULL,
91         `ueb_topic_name` varchar(256) DEFAULT NULL,
92         `app_type` int(11) NOT NULL DEFAULT 1,
93         `auth_central` char(1) NOT NULL DEFAULT 'N',
94         `auth_namespace` varchar(100) DEFAULT NULL,
95         PRIMARY KEY (`app_id`)
96         )
97 */
98
99 @NamedQueries({
100         @NamedQuery(
101                 name = "FnApp.retrieveWhereAuthCentralIsYAndOpenIsNAndAuthNamespaceIsNotNull",
102                 query = "from FnApp where auth_central = 'Y' and open = 'N' and auth_namespace is not null")
103 })
104
105 @Table(name = "fn_app")
106 @NoArgsConstructor
107 @AllArgsConstructor
108 @EqualsAndHashCode(callSuper = true)
109 @Embeddable
110 @Getter
111 @Setter
112 @Entity
113 public class FnApp extends DomainVo implements Serializable {
114
115        @Id
116        @GeneratedValue(strategy = GenerationType.AUTO)
117        @Column(name = "app_Id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT")
118        @Digits(integer = 11, fraction = 0)
119        private Long appId;
120        @Column(name = "app_name", length = 100, nullable = false, columnDefinition = "varchar(100) not null default '?'")
121        @Size(max = 100)
122        @SafeHtml
123        @NotNull
124        private String appName;
125        @Column(name = "app_image_url", length = 256)
126        @Size(max = 256)
127        @SafeHtml
128        private String appImageUrl;
129        @Column(name = "app_description", length = 512)
130        @Size(max = 256)
131        @SafeHtml
132        private String appDescription;
133        @Column(name = "app_notes", length = 4096)
134        @Size(max = 4096)
135        @SafeHtml
136        private String appNotes;
137        @Column(name = "app_url", length = 256)
138        @Size(max = 256)
139        @SafeHtml
140        //TODO URL
141        @URL
142        private String appUrl;
143        @Column(name = "app_alternate_url", length = 256)
144        @Size(max = 256)
145        @SafeHtml
146        private String appAlternateUrl;
147        @Column(name = "app_rest_endpoint", length = 2000)
148        @Size(max = 2000)
149        @SafeHtml
150        private String appRestEndpoint;
151        @Column(name = "ml_app_name", length = 50, nullable = false, columnDefinition = "varchar(50) not null default '?'")
152        @Size(max = 50)
153        @SafeHtml
154        @NotNull
155        private String ml_app_name;
156        @Column(name = "ml_app_admin_id", length = 7, nullable = false, columnDefinition = "varchar(7) not null default '?'")
157        @Size(max = 7)
158        @SafeHtml
159        @NotNull
160        private String mlAppAdminId;
161        @Column(name = "mots_id", length = 11)
162        @Digits(integer = 11, fraction = 0)
163        private Long motsId;
164        @Column(name = "app_password", length = 256, nullable = false, columnDefinition = "varchar(256) not null default '?'")
165        @Size(max = 256)
166        @SafeHtml
167        @NotNull
168        private String appPassword;
169        @Column(name = "open", length = 1, columnDefinition = "char(1) default 'N'")
170        @Pattern(regexp = "[YNyn]")
171        @Size(max = 1)
172        @NotNull
173        @SafeHtml
174        private String open;
175        @Column(name = "ENABLED", length = 1, columnDefinition = "char(1) default 'N'")
176        @Pattern(regexp = "[YNyn]")
177        @Size(max = 1)
178        @NotNull
179        @SafeHtml
180        private String enabled;
181        @Column(name = "active_yn", length = 1, columnDefinition = "char(1) default 'Y'")
182        @Pattern(regexp = "[YNyn]")
183        @Size(max = 1)
184        @NotNull
185        @SafeHtml
186        private String activeYn;
187        @Column(name = "thumbnail", columnDefinition = "mediumblob null default null")
188        private byte[] thumbnail;
189        @Column(name = "app_username", length = 50)
190        @Size(max = 50)
191        @SafeHtml
192        private String appUsername;
193        @Column(name = "ueb_key", length = 256)
194        @Size(max = 256)
195        @SafeHtml
196        private String uebKey;
197        @Column(name = "ueb_secret", length = 256)
198        @Size(max = 256)
199        @SafeHtml
200        private String uebSecret;
201        @Column(name = "ueb_topic_name", length = 256)
202        @Size(max = 256)
203        @SafeHtml
204        private String uebTopicName;
205        @Column(name = "app_type", length = 11, columnDefinition = "int(11) not null default 1")
206        @Digits(integer = 11, fraction = 0)
207        private Long appType;
208        @Column(name = "auth_central", length = 1, columnDefinition = "char(1) not null default 'N'", nullable = false)
209        @Pattern(regexp = "[YNyn]")
210        @Size(max = 1)
211        @NotNull
212        @SafeHtml
213        private String authCentral;
214        @Column(name = "auth_namespace", length = 100)
215        @Size(max = 100)
216        @SafeHtml
217        private String authNamespace;
218        @OneToMany(
219                targetEntity = FnMenuFunctionalRoles.class,
220                mappedBy = "appId",
221                cascade = CascadeType.ALL,
222                fetch = FetchType.LAZY
223        )
224        private List<FnMenuFunctionalRoles> fnMenuFunctionalRoles = new ArrayList<>();
225        @OneToMany(
226                targetEntity = EpUserRolesRequest.class,
227                mappedBy = "appId",
228                cascade = CascadeType.ALL,
229                fetch = FetchType.LAZY
230        )
231        private List<EpUserRolesRequest> epUserRolesRequests = new ArrayList<>();
232        @OneToMany(
233                targetEntity = EpAppFunction.class,
234                mappedBy = "appId",
235                cascade = CascadeType.ALL,
236                fetch = FetchType.LAZY
237        )
238        private List<EpAppFunction> epAppFunctions = new ArrayList<>();
239        @OneToMany(
240                targetEntity = EpAppRoleFunction.class,
241                mappedBy = "appId",
242                cascade = CascadeType.ALL,
243                fetch = FetchType.LAZY
244        )
245        private List<EpAppRoleFunction> epAppRoleFunctions = new ArrayList<>();
246        @OneToMany(
247                targetEntity = FnUserRole.class,
248                mappedBy = "appId",
249                cascade = CascadeType.ALL,
250                fetch = FetchType.LAZY
251        )
252        private List<FnUserRole> fnUserRoles = new ArrayList<>();
253        @OneToMany(
254                targetEntity = EpWebAnalyticsSource.class,
255                mappedBy = "appId",
256                cascade = CascadeType.ALL,
257                fetch = FetchType.LAZY
258        )
259        private List<EpWebAnalyticsSource> epWebAnalyticsSources = new ArrayList<>();
260        @OneToMany(
261                targetEntity = EpWidgetCatalogRole.class,
262                mappedBy = "appId",
263                cascade = CascadeType.ALL,
264                fetch = FetchType.LAZY
265        )
266        private List<EpWidgetCatalogRole> epWidgetCatalogRoles = new ArrayList<>();
267        @OneToMany(
268                targetEntity = EpMicroservice.class,
269                mappedBy = "appId",
270                cascade = CascadeType.ALL,
271                fetch = FetchType.LAZY
272        )
273        private List<EpMicroservice> epMicroservices = new ArrayList<>();
274        @OneToMany(
275                targetEntity = EpPersUserAppManSort.class,
276                mappedBy = "appId",
277                cascade = CascadeType.ALL,
278                fetch = FetchType.LAZY
279        )
280        private List<EpPersUserAppManSort> epPersUserAppManSorts = new ArrayList<>();
281        @OneToMany(
282                targetEntity = FnPersUserAppSel.class,
283                mappedBy = "appId",
284                cascade = CascadeType.ALL,
285                fetch = FetchType.LAZY
286        )
287        private List<FnPersUserAppSel> fnPersUserAppSels = new ArrayList<>();
288        @OneToMany(
289                targetEntity = FnWidget.class,
290                mappedBy = "appId",
291                cascade = CascadeType.ALL,
292                fetch = FetchType.LAZY
293        )
294        private List<FnWidget> fnWidgets = new ArrayList<>();
295 }