adding orchestration type to service models view
[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     
81     public static class ServiceBuilder {
82        private String uuid;
83        private String invariantUUID;
84        private String name;
85        private String version;
86        private String toscaModelURL;
87        private String category;
88        private Service.LifecycleState lifecycleState;
89        private String distributionStatus;
90        private Collection<Artifact> artifacts;
91        private Collection<SubResource> resources;
92         private String orchestrationType;
93
94         public ServiceBuilder setUuid(String uuid) {
95             this.uuid = uuid;
96             return this;
97         }
98
99         public ServiceBuilder setInvariantUUID(String invariantUUID) {
100             this.invariantUUID = invariantUUID;
101             return this;
102         }
103
104         public ServiceBuilder setName(String name) {
105             this.name = name;
106             return this;
107         }
108
109         public ServiceBuilder setVersion(String version) {
110             this.version = version;
111             return this;
112         }
113
114         public ServiceBuilder setToscaModelURL(String toscaModelURL) {
115             this.toscaModelURL = toscaModelURL;
116             return this;
117         }
118
119         public ServiceBuilder setCategory(String category) {
120             this.category = category;
121             return this;
122         }
123
124         public ServiceBuilder setLifecycleState(Service.LifecycleState lifecycleState) {
125             this.lifecycleState = lifecycleState;
126             return this;
127         }
128
129         public ServiceBuilder setDistributionStatus(String distributionStatus) {
130             this.distributionStatus = distributionStatus;
131             return this;
132         }
133
134         public ServiceBuilder setArtifacts(Collection<Artifact> artifacts) {
135             this.artifacts = artifacts;
136             return this;
137         }
138
139         public ServiceBuilder setResources(Collection<SubResource> resources) {
140             this.resources = resources;
141             return this;
142         }
143
144         public ServiceBuilder setOrchestrationType(String orchestrationType) {
145             this.orchestrationType = orchestrationType;
146             return this;
147         }
148
149         public Service build() {
150             return new Service(this);
151         }
152     }
153     
154
155     public String getUuid() {
156         return uuid;
157     }
158
159     public String getInvariantUUID() {
160         return invariantUUID;
161     }
162
163     public String getName() {
164         return name;
165     }
166
167     public String getVersion() {
168         return version;
169     }
170
171     public String getToscaModelURL() {
172         return toscaModelURL;
173     }
174
175     public String getCategory() {
176         return category;
177     }
178
179     public Service.LifecycleState getLifecycleState() {
180         return lifecycleState;
181     }
182
183     public String getLastUpdaterUserId() {
184         return lastUpdaterUserId;
185     }
186
187     public String getLastUpdaterFullName() {
188         return lastUpdaterFullName;
189     }
190
191     public String getDistributionStatus() {
192         return distributionStatus;
193     }
194
195     public Collection<Artifact> getArtifacts() {
196         return artifacts;
197     }
198
199     public Collection<SubResource> getResources() {
200         return resources;
201     }
202
203     public String getOrchestrationType() {
204         return orchestrationType;
205     }
206
207     public void setUuid(String uuid) {
208         this.uuid = uuid;
209     }
210
211     public void setInvariantUUID(String invariantUUID) {
212         this.invariantUUID = invariantUUID;
213     }
214
215     public void setName(String name) {
216         this.name = name;
217     }
218
219     public void setVersion(String version) {
220         this.version = version;
221     }
222
223     public void setToscaModelURL(String toscaModelURL) {
224         this.toscaModelURL = toscaModelURL;
225     }
226
227     public void setCategory(String category) {
228         this.category = category;
229     }
230
231     public void setLifecycleState(Service.LifecycleState lifecycleState) {
232         this.lifecycleState = lifecycleState;
233     }
234
235     public void set(String lastUpdaterUserId) {
236         this.lastUpdaterUserId = lastUpdaterUserId;
237     }
238
239     public void setLastUpdaterFullName(String lastUpdaterFullName) {
240         this.lastUpdaterFullName = lastUpdaterFullName;
241     }
242
243     public void setDistributionStatus(String distributionStatus) {
244         this.distributionStatus = distributionStatus;
245     }
246
247     public void setArtifacts(Collection<Artifact> artifacts) {
248         this.artifacts = artifacts;
249     }
250
251     public void setResources(Collection<SubResource> resources) {
252         this.resources = resources;
253     }
254
255     public void setOrchestrationType(String orchestrationType) {
256         this.orchestrationType = orchestrationType;
257     }
258
259     @Override
260     public String toString() {
261         return uuid;
262     }
263
264     @Override
265     public int hashCode() {
266         return UUID.fromString(getUuid()).hashCode();
267     }
268
269     @Override
270     public boolean equals(Object o) {
271         if (o == this)
272             return true;
273         if (!(o instanceof Service))
274             return false;
275
276         final Service service = (Service) o;
277
278         return (service.getUuid().equals(getUuid()));
279     }
280
281     public Service() {}
282
283     public Service(ServiceBuilder serviceBuilder) {
284
285         this.uuid = serviceBuilder.uuid;
286         this.invariantUUID = serviceBuilder.invariantUUID;
287         this.name = serviceBuilder.name;
288         this.version = serviceBuilder.version;
289         this.toscaModelURL = serviceBuilder.toscaModelURL;
290         this.category = serviceBuilder.category;
291         this.lifecycleState = serviceBuilder.lifecycleState;
292         this.distributionStatus = serviceBuilder.distributionStatus;
293         this.artifacts = serviceBuilder.artifacts;
294         this.resources = serviceBuilder.resources;
295         this.orchestrationType = serviceBuilder.orchestrationType;
296     }
297 }