Respect owning-entity-id when searching instances by Subscriber
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / ServiceInstanceSearchResult.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.vid.model;
22
23 import com.fasterxml.jackson.annotation.JsonProperty;
24 import org.apache.commons.lang3.StringUtils;
25 import org.onap.vid.roles.WithPermissionPropertiesOwningEntity;
26 import org.onap.vid.roles.WithPermissionPropertiesSubscriberAndServiceType;
27
28 public class ServiceInstanceSearchResult
29         implements WithPermissionPropertiesSubscriberAndServiceType, WithPermissionPropertiesOwningEntity {
30
31         private final String SUBSCRIBER_ID_FRONTEND_ALIAS = "globalCustomerId";
32
33         private String serviceInstanceId;
34
35         private String subscriberId;
36
37         private String serviceType;
38
39         private String serviceInstanceName;
40
41         private String subscriberName;
42
43         private String aaiModelInvariantId;
44
45         private String aaiModelVersionId;
46
47         private String owningEntityId;
48
49         private boolean isPermitted;
50
51         public ServiceInstanceSearchResult(){
52         }
53         
54         public ServiceInstanceSearchResult(String serviceInstanceId, String subscriberId, String serviceType,
55                 String serviceInstanceName, String subscriberName, String aaiModelInvariantId,
56                 String aaiModelVersionId, String owningEntityId, boolean isPermitted) {
57                 this.serviceInstanceId = serviceInstanceId;
58                 this.subscriberId = subscriberId;
59                 this.serviceType = serviceType;
60                 this.serviceInstanceName = serviceInstanceName;
61                 this.subscriberName = subscriberName;
62                 this.aaiModelInvariantId = aaiModelInvariantId;
63                 this.aaiModelVersionId = aaiModelVersionId;
64                 this.owningEntityId = owningEntityId;
65                 this.isPermitted = isPermitted;
66         }
67
68         public String getServiceInstanceId() {
69                 return serviceInstanceId;
70         }
71
72         public void setServiceInstanceId(String serviceInstanceId) {
73                 this.serviceInstanceId = serviceInstanceId;
74         }
75
76         @Override
77         @JsonProperty(SUBSCRIBER_ID_FRONTEND_ALIAS)
78         public String getSubscriberId() {
79                 return subscriberId;
80         }
81
82         public void setSubscriberId(String subscriberId) {
83                 this.subscriberId = subscriberId;
84         }
85
86         @Override
87         public String getServiceType() {
88                 return serviceType;
89         }
90
91         public void setServiceType(String serviceType) {
92                 this.serviceType = serviceType;
93         }
94
95         public String getServiceInstanceName() {
96                 return serviceInstanceName;
97         }
98
99         public void setServiceInstanceName(String serviceInstanceName) {
100                 this.serviceInstanceName = serviceInstanceName;
101         }
102
103         public String getSubscriberName() {
104                 return subscriberName;
105         }
106
107         public void setSubscriberName(String subscriberName) {
108                 this.subscriberName = subscriberName;
109         }
110
111         public String getAaiModelInvariantId() {
112                 return aaiModelInvariantId;
113         }
114
115         public void setAaiModelInvariantId(String aaiModelInvariantId) {
116                 this.aaiModelInvariantId = aaiModelInvariantId;
117         }
118
119         public String getAaiModelVersionId() {
120                 return aaiModelVersionId;
121         }
122
123         public void setAaiModelVersionId(String aaiModelVersionId) {
124                 this.aaiModelVersionId = aaiModelVersionId;
125         }
126
127         @Override
128         public String getOwningEntityId() {
129                 return owningEntityId;
130         }
131
132         public void setOwningEntityId(String owningEntityId) {
133                 this.owningEntityId = owningEntityId;
134         }
135
136         public boolean getIsPermitted() {
137                 return isPermitted;
138         }
139
140         public void setIsPermitted(boolean isPermitted) {
141                 this.isPermitted = isPermitted;
142         }
143
144         @Override
145         public boolean equals(Object o) {
146                 if (this == o) {
147                         return true;
148                 }
149                 if (o == null || getClass() != o.getClass()) {
150                         return false;
151                 }
152
153                 ServiceInstanceSearchResult that = (ServiceInstanceSearchResult) o;
154
155                 return StringUtils.equals(serviceInstanceId, that.serviceInstanceId);
156         }
157
158         @Override
159         public int hashCode() {
160                 return serviceInstanceId != null ? serviceInstanceId.hashCode() : 0;
161         }
162 }