Add only non-null isInstantiationTemplateExists to Models list
[vid.git] / vid-app-common / src / main / java / org / onap / vid / asdc / beans / Service.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.asdc.beans;
22
23 import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
24
25 import com.fasterxml.jackson.annotation.JsonInclude;
26 import java.util.Collection;
27 import java.util.UUID;
28
29 public class Service {
30
31     public enum DistributionStatus {
32
33     DISTRIBUTION_NOT_APPROVED,
34
35     DISTRIBUTION_APPROVED,
36
37     DISTRIBUTED,
38
39     DISTRIBUTION_REJECTED,
40
41     DISTRIBUTION_COMPLETE_OK
42     }
43
44     public enum LifecycleState {
45
46         NOT_CERTIFIED_CHECKOUT,
47
48         NOT_CERTIFIED_CHECKIN,
49
50         READY_FOR_CERTIFICATION,
51
52         CERTIFICATION_IN_PROGRESS,
53
54         CERTIFIED
55     }
56
57     private String uuid;
58
59     private String invariantUUID;
60
61     private String name;
62
63     private String version;
64
65     private String toscaModelURL;
66
67     private String category;
68
69     private Service.LifecycleState lifecycleState;
70
71     private String lastUpdaterUserId;
72
73     private String lastUpdaterFullName;
74
75     private String distributionStatus;
76
77     private Collection<Artifact> artifacts;
78
79     private Collection<SubResource> resources;
80
81     private String orchestrationType;
82
83     @JsonInclude(NON_NULL)
84     private Boolean isInstantiationTemplateExists;
85     
86     
87     public static class ServiceBuilder {
88        private String uuid;
89        private String invariantUUID;
90        private String name;
91        private String version;
92        private String toscaModelURL;
93        private String category;
94        private Service.LifecycleState lifecycleState;
95        private String distributionStatus;
96        private Collection<Artifact> artifacts;
97        private Collection<SubResource> resources;
98         private String orchestrationType;
99
100         public ServiceBuilder setUuid(String uuid) {
101             this.uuid = uuid;
102             return this;
103         }
104
105         public ServiceBuilder setInvariantUUID(String invariantUUID) {
106             this.invariantUUID = invariantUUID;
107             return this;
108         }
109
110         public ServiceBuilder setName(String name) {
111             this.name = name;
112             return this;
113         }
114
115         public ServiceBuilder setVersion(String version) {
116             this.version = version;
117             return this;
118         }
119
120         public ServiceBuilder setToscaModelURL(String toscaModelURL) {
121             this.toscaModelURL = toscaModelURL;
122             return this;
123         }
124
125         public ServiceBuilder setCategory(String category) {
126             this.category = category;
127             return this;
128         }
129
130         public ServiceBuilder setLifecycleState(Service.LifecycleState lifecycleState) {
131             this.lifecycleState = lifecycleState;
132             return this;
133         }
134
135         public ServiceBuilder setDistributionStatus(String distributionStatus) {
136             this.distributionStatus = distributionStatus;
137             return this;
138         }
139
140         public ServiceBuilder setArtifacts(Collection<Artifact> artifacts) {
141             this.artifacts = artifacts;
142             return this;
143         }
144
145         public ServiceBuilder setResources(Collection<SubResource> resources) {
146             this.resources = resources;
147             return this;
148         }
149
150         public ServiceBuilder setOrchestrationType(String orchestrationType) {
151             this.orchestrationType = orchestrationType;
152             return this;
153         }
154
155         public Service build() {
156             return new Service(this);
157         }
158     }
159     
160
161     public String getUuid() {
162         return uuid;
163     }
164
165     public String getInvariantUUID() {
166         return invariantUUID;
167     }
168
169     public String getName() {
170         return name;
171     }
172
173     public String getVersion() {
174         return version;
175     }
176
177     public String getToscaModelURL() {
178         return toscaModelURL;
179     }
180
181     public String getCategory() {
182         return category;
183     }
184
185     public Service.LifecycleState getLifecycleState() {
186         return lifecycleState;
187     }
188
189     public String getLastUpdaterUserId() {
190         return lastUpdaterUserId;
191     }
192
193     public String getLastUpdaterFullName() {
194         return lastUpdaterFullName;
195     }
196
197     public String getDistributionStatus() {
198         return distributionStatus;
199     }
200
201     public Collection<Artifact> getArtifacts() {
202         return artifacts;
203     }
204
205     public Collection<SubResource> getResources() {
206         return resources;
207     }
208
209     public String getOrchestrationType() {
210         return orchestrationType;
211     }
212
213     public Boolean getIsInstantiationTemplateExists() {
214         return isInstantiationTemplateExists;
215     }
216
217
218     public void setUuid(String uuid) {
219         this.uuid = uuid;
220     }
221
222     public void setInvariantUUID(String invariantUUID) {
223         this.invariantUUID = invariantUUID;
224     }
225
226     public void setName(String name) {
227         this.name = name;
228     }
229
230     public void setVersion(String version) {
231         this.version = version;
232     }
233
234     public void setToscaModelURL(String toscaModelURL) {
235         this.toscaModelURL = toscaModelURL;
236     }
237
238     public void setCategory(String category) {
239         this.category = category;
240     }
241
242     public void setLifecycleState(Service.LifecycleState lifecycleState) {
243         this.lifecycleState = lifecycleState;
244     }
245
246     public void set(String lastUpdaterUserId) {
247         this.lastUpdaterUserId = lastUpdaterUserId;
248     }
249
250     public void setLastUpdaterFullName(String lastUpdaterFullName) {
251         this.lastUpdaterFullName = lastUpdaterFullName;
252     }
253
254     public void setDistributionStatus(String distributionStatus) {
255         this.distributionStatus = distributionStatus;
256     }
257
258     public void setArtifacts(Collection<Artifact> artifacts) {
259         this.artifacts = artifacts;
260     }
261
262     public void setResources(Collection<SubResource> resources) {
263         this.resources = resources;
264     }
265
266     public void setOrchestrationType(String orchestrationType) {
267         this.orchestrationType = orchestrationType;
268     }
269
270     public void setIsInstantiationTemplateExists(Boolean isInstantiationTemplateExists) {
271         this.isInstantiationTemplateExists = isInstantiationTemplateExists;
272     }
273
274     @Override
275     public String toString() {
276         return uuid;
277     }
278
279     @Override
280
281     public int hashCode() {
282         return UUID.fromString(getUuid()).hashCode();
283     }
284
285     @Override
286     public boolean equals(Object o) {
287         if (o == this)
288             return true;
289         if (!(o instanceof Service))
290             return false;
291
292         final Service service = (Service) o;
293
294         return (service.getUuid().equals(getUuid()));
295     }
296
297     public Service() {}
298
299     public Service(ServiceBuilder serviceBuilder) {
300
301         this.uuid = serviceBuilder.uuid;
302         this.invariantUUID = serviceBuilder.invariantUUID;
303         this.name = serviceBuilder.name;
304         this.version = serviceBuilder.version;
305         this.toscaModelURL = serviceBuilder.toscaModelURL;
306         this.category = serviceBuilder.category;
307         this.lifecycleState = serviceBuilder.lifecycleState;
308         this.distributionStatus = serviceBuilder.distributionStatus;
309         this.artifacts = serviceBuilder.artifacts;
310         this.resources = serviceBuilder.resources;
311         this.orchestrationType = serviceBuilder.orchestrationType;
312     }
313 }