Portal Spring Boot Development
[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.db.ep.EpAppFunction;
70 import org.onap.portal.domain.db.ep.EpAppRoleFunction;
71 import org.onap.portal.domain.db.ep.EpMicroservice;
72 import org.onap.portal.domain.db.ep.EpUserRolesRequest;
73 import org.onap.portal.domain.db.ep.EpWebAnalyticsSource;
74 import org.onap.portal.domain.db.ep.EpWidgetCatalogRole;
75 import org.onap.portal.domain.dto.DomainVo;
76
77 /*
78 CREATE TABLE `fn_app` (
79         `app_id` int(11) NOT NULL AUTO_INCREMENT,
80         `app_name` varchar(100) NOT NULL DEFAULT '?',
81         `app_image_url` varchar(256) DEFAULT NULL,
82         `app_description` varchar(512) DEFAULT NULL,
83         `app_notes` varchar(4096) DEFAULT NULL,
84         `app_url` varchar(256) DEFAULT NULL,
85         `app_alternate_url` varchar(256) DEFAULT NULL,
86         `app_rest_endpoint` varchar(2000) DEFAULT NULL,
87         `ml_app_name` varchar(50) NOT NULL DEFAULT '?',
88         `ml_app_admin_id` varchar(7) NOT NULL DEFAULT '?',
89         `mots_id` int(11) DEFAULT NULL,
90         `app_password` varchar(256) NOT NULL DEFAULT '?',
91         `open` char(1) DEFAULT 'N',
92         `enabled` char(1) DEFAULT 'Y',
93         `thumbnail` mediumblob DEFAULT NULL,
94         `app_username` varchar(50) DEFAULT NULL,
95         `ueb_key` varchar(256) DEFAULT NULL,
96         `ueb_secret` varchar(256) DEFAULT NULL,
97         `ueb_topic_name` varchar(256) DEFAULT NULL,
98         `app_type` int(11) NOT NULL DEFAULT 1,
99         `auth_central` char(1) NOT NULL DEFAULT 'N',
100         `auth_namespace` varchar(100) DEFAULT NULL,
101         PRIMARY KEY (`app_id`)
102         )
103 */
104
105 @NamedQueries({
106         @NamedQuery(
107                 name = "FnApp.retrieveWhereAuthCentralIsYAndOpenIsNAndAuthNamespaceIsNotNull",
108                 query = "from FnApp where auth_central = 'Y' and open = 'N' and auth_namespace is not null")
109 })
110
111 @Table(name = "fn_app")
112 @NoArgsConstructor
113 @AllArgsConstructor
114 @EqualsAndHashCode(callSuper = true)
115 @Embeddable
116 @Getter
117 @Setter
118 @Entity
119 public class FnApp extends DomainVo implements Serializable {
120
121        @Id
122        @GeneratedValue(strategy = GenerationType.AUTO)
123        @Column(name = "app_Id", length = 11, nullable = false)
124        @Digits(integer = 11, fraction = 0)
125        private Long appId;
126        @Column(name = "app_name", length = 100, nullable = false, columnDefinition = "varchar(100) not null default '?'")
127        @Size(max = 100)
128        @SafeHtml
129        @NotNull
130        private String appName;
131        @Column(name = "app_image_url", length = 256)
132        @Size(max = 256)
133        @SafeHtml
134        private String appImageUrl;
135        @Column(name = "app_description", length = 512)
136        @Size(max = 256)
137        @SafeHtml
138        private String appDescription;
139        @Column(name = "app_notes", length = 4096)
140        @Size(max = 4096)
141        @SafeHtml
142        private String appNotes;
143        @Column(name = "app_url", length = 256)
144        @Size(max = 256)
145        @SafeHtml
146        //TODO URL
147        @URL
148        private String appUrl;
149        @Column(name = "app_alternate_url", length = 256)
150        @Size(max = 256)
151        @SafeHtml
152        private String appAlternateUrl;
153        @Column(name = "app_rest_endpoint", length = 2000)
154        @Size(max = 2000)
155        @SafeHtml
156        private String appRestEndpoint;
157        @Column(name = "ml_app_name", length = 50, nullable = false, columnDefinition = "varchar(50) not null default '?'")
158        @Size(max = 50)
159        @SafeHtml
160        @NotNull
161        private String ml_app_name;
162        @Column(name = "ml_app_admin_id", length = 7, nullable = false, columnDefinition = "varchar(7) not null default '?'")
163        @Size(max = 7)
164        @SafeHtml
165        @NotNull
166        private String mlAppAdminId;
167        @Column(name = "mots_id", length = 11)
168        @Digits(integer = 11, fraction = 0)
169        private Long motsId;
170        @Column(name = "app_password", length = 256, nullable = false, columnDefinition = "varchar(256) not null default '?'")
171        @Size(max = 256)
172        @SafeHtml
173        @NotNull
174        private String appPassword;
175        @Column(name = "open", length = 1, columnDefinition = "char(1) default 'N'")
176        @Pattern(regexp = "[YNyn]")
177        @Size(max = 1)
178        @NotNull
179        @SafeHtml
180        private String open;
181        @Column(name = "ENABLED", length = 1, columnDefinition = "char(1) default 'N'")
182        @Pattern(regexp = "[YNyn]")
183        @Size(max = 1)
184        @NotNull
185        @SafeHtml
186        private String enabled;
187        @Column(name = "active_yn", length = 1, columnDefinition = "char(1) default 'Y'")
188        @Pattern(regexp = "[YNyn]")
189        @Size(max = 1)
190        @NotNull
191        @SafeHtml
192        private String activeYn;
193        @Column(name = "thumbnail", columnDefinition = "mediumblob null default null")
194        private byte[] thumbnail;
195        @Column(name = "app_username", length = 50)
196        @Size(max = 50)
197        @SafeHtml
198        private String appUsername;
199        @Column(name = "ueb_key", length = 256)
200        @Size(max = 256)
201        @SafeHtml
202        private String uebKey;
203        @Column(name = "ueb_secret", length = 256)
204        @Size(max = 256)
205        @SafeHtml
206        private String uebSecret;
207        @Column(name = "ueb_topic_name", length = 256)
208        @Size(max = 256)
209        @SafeHtml
210        private String uebTopicName;
211        @Column(name = "app_type", length = 11, columnDefinition = "int(11) not null default 1")
212        @Digits(integer = 11, fraction = 0)
213        private Long appType;
214        @Column(name = "auth_central", length = 1, columnDefinition = "char(1) not null default 'N'", nullable = false)
215        @Pattern(regexp = "[YNyn]")
216        @Size(max = 1)
217        @NotNull
218        @SafeHtml
219        private String authCentral;
220        @Column(name = "auth_namespace", length = 100)
221        @Size(max = 100)
222        @SafeHtml
223        private String authNamespace;
224        @OneToMany(
225                targetEntity = FnMenuFunctionalRoles.class,
226                mappedBy = "appId",
227                cascade = CascadeType.ALL,
228                fetch = FetchType.LAZY
229        )
230        private List<FnMenuFunctionalRoles> fnMenuFunctionalRoles = new ArrayList<>();
231        @OneToMany(
232                targetEntity = EpUserRolesRequest.class,
233                mappedBy = "appId",
234                cascade = CascadeType.ALL,
235                fetch = FetchType.LAZY
236        )
237        private List<EpUserRolesRequest> epUserRolesRequests = new ArrayList<>();
238        @OneToMany(
239                targetEntity = EpAppFunction.class,
240                mappedBy = "appId",
241                cascade = CascadeType.ALL,
242                fetch = FetchType.LAZY
243        )
244        private List<EpAppFunction> epAppFunctions = new ArrayList<>();
245        @OneToMany(
246                targetEntity = EpAppRoleFunction.class,
247                mappedBy = "appId",
248                cascade = CascadeType.ALL,
249                fetch = FetchType.LAZY
250        )
251        private List<EpAppRoleFunction> epAppRoleFunctions = new ArrayList<>();
252        @OneToMany(
253                targetEntity = FnUserRole.class,
254                mappedBy = "appId",
255                cascade = CascadeType.ALL,
256                fetch = FetchType.LAZY
257        )
258        private List<FnUserRole> fnUserRoles = new ArrayList<>();
259        @OneToMany(
260                targetEntity = EpWebAnalyticsSource.class,
261                mappedBy = "appId",
262                cascade = CascadeType.ALL,
263                fetch = FetchType.LAZY
264        )
265        private List<EpWebAnalyticsSource> epWebAnalyticsSources = new ArrayList<>();
266        @OneToMany(
267                targetEntity = EpWidgetCatalogRole.class,
268                mappedBy = "appId",
269                cascade = CascadeType.ALL,
270                fetch = FetchType.LAZY
271        )
272        private List<EpWidgetCatalogRole> epWidgetCatalogRoles = new ArrayList<>();
273        @OneToMany(
274                targetEntity = EpMicroservice.class,
275                mappedBy = "appId",
276                cascade = CascadeType.ALL,
277                fetch = FetchType.LAZY
278        )
279        private List<EpMicroservice> epMicroservices = new ArrayList<>();
280        @OneToMany(
281                targetEntity = FnPersUserAppSel.class,
282                mappedBy = "appId",
283                cascade = CascadeType.ALL,
284                fetch = FetchType.LAZY
285        )
286        private List<FnPersUserAppSel> fnPersUserAppSels = new ArrayList<>();
287 }