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