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