PortalAdminController up
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / dto / transport / PortalAdmin.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.dto.transport;
42
43 import java.io.Serializable;
44 import javax.persistence.ColumnResult;
45 import javax.persistence.ConstructorResult;
46 import javax.persistence.NamedNativeQueries;
47 import javax.persistence.NamedNativeQuery;
48 import javax.persistence.SqlResultSetMapping;
49 import javax.validation.constraints.Digits;
50 import javax.validation.constraints.Size;
51 import lombok.AllArgsConstructor;
52 import lombok.Getter;
53 import lombok.NoArgsConstructor;
54 import lombok.Setter;
55 import org.hibernate.validator.constraints.SafeHtml;
56
57
58 @NamedNativeQuery(
59     name = "PortalAdmin.PortalAdminDTO",
60     query = "SELECT " +
61         "u.id AS userId, " +
62         "u.loginId AS loginId " +
63         "u.firstName AS firstName " +
64         "u.lastName AS lastName " +
65         "FROM " +
66         "FnUser u, " +
67         "FnUserRole ur " +
68         "WHERE u.activeYn = 'true' AND u.user_id = ur.user_id AND ur.role_id= :adminRoleId",
69     resultSetMapping = "PortalAdminDTO")
70 @NamedNativeQuery(
71     name = "PortalAdmin.ActivePortalAdminDTO",
72     query = "SELECT " +
73         "u.id AS userId, " +
74         "u.loginId AS loginId " +
75         "u.firstName AS firstName " +
76         "u.lastName AS lastName " +
77         "FROM fn_user u, fn_user_role ur " +
78         "WHERE u.user_id = ur.user_id " +
79         "AND ur.user_id= :userId " +
80         "AND ur.role_id=:SYS_ADMIN_ROLE_ID",
81     resultSetMapping = "PortalAdminDTO")
82
83 @SqlResultSetMapping(
84     name = "PortalAdminDTO",
85     classes = @ConstructorResult(
86         targetClass = PortalAdmin.class,
87         columns = {
88             @ColumnResult(name = "userId"),
89             @ColumnResult(name = "loginId"),
90             @ColumnResult(name = "firstName"),
91             @ColumnResult(name = "lastName")
92         }
93     )
94 )
95
96 @Getter
97 @Setter
98 @NoArgsConstructor
99 @AllArgsConstructor
100 public class PortalAdmin implements Serializable {
101
102     private static final long serialVersionUID = 1L;
103
104     @Digits(integer = 11, fraction = 0)
105     private Long userId;
106     @Size(max = 25)
107     @SafeHtml
108     private String loginId;
109     @Size(max = 50)
110     @SafeHtml
111     private String firstName;
112     @Size(max = 50)
113     @SafeHtml
114     private String lastName;
115
116 }