ca151a731a82a5b73d524b75430c49bfcbdb6ae8
[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 /**
27  * The Class Service.
28  */
29 public class Service {
30
31     /**
32      * The Enum DistributionStatus.
33      */
34     public enum DistributionStatus {
35
36     /** The distribution not approved. */
37     DISTRIBUTION_NOT_APPROVED,
38
39     /** The distribution approved. */
40     DISTRIBUTION_APPROVED,
41
42     /** The distributed. */
43     DISTRIBUTED,
44
45     /** The distribution rejected. */
46     DISTRIBUTION_REJECTED,
47
48     /** The destributed for tenant isolation. */
49     DISTRIBUTION_COMPLETE_OK
50     }
51
52     /**
53      * The Enum LifecycleState.
54      */
55     public enum LifecycleState {
56
57         /** The not certified checkout. */
58         NOT_CERTIFIED_CHECKOUT,
59
60         /** The not certified checkin. */
61         NOT_CERTIFIED_CHECKIN,
62
63         /** The ready for certification. */
64         READY_FOR_CERTIFICATION,
65
66         /** The certification in progress. */
67         CERTIFICATION_IN_PROGRESS,
68
69         /** The certified. */
70         CERTIFIED
71     }
72
73     /** The uuid. */
74     private String uuid;
75
76     /** The invariant UUID. */
77     private String invariantUUID;
78
79     /** The name. */
80     private String name;
81
82     /** The version. */
83     private String version;
84
85     /** The tosca model URL. */
86     private String toscaModelURL;
87
88     /** The category. */
89     private String category;
90
91     /** The lifecycle state. */
92     private Service.LifecycleState lifecycleState;
93
94     /** The last updater user uid. */
95     private String lastUpdaterUserId;
96
97     /** The last updater full name. */
98     private String lastUpdaterFullName;
99
100     /** The distribution status. */
101     private String distributionStatus;
102
103     /** The artifacts. */
104     private Collection<Artifact> artifacts;
105
106     /** The resources. */
107     private Collection<SubResource> resources;
108     
109     
110     public static class ServiceBuilder {
111        private String uuid;
112        private String invariantUUID;
113        private String name;
114        private String version;
115        private String toscaModelURL;
116        private String category;
117        private Service.LifecycleState lifecycleState;
118        private String distributionStatus;
119        private Collection<Artifact> artifacts;
120        private Collection<SubResource> resources;
121
122         public ServiceBuilder setUuid(String uuid) {
123             this.uuid = uuid;
124             return this;
125         }
126
127         public ServiceBuilder setInvariantUUID(String invariantUUID) {
128             this.invariantUUID = invariantUUID;
129             return this;
130         }
131
132         public ServiceBuilder setName(String name) {
133             this.name = name;
134             return this;
135         }
136
137         public ServiceBuilder setVersion(String version) {
138             this.version = version;
139             return this;
140         }
141
142         public ServiceBuilder setToscaModelURL(String toscaModelURL) {
143             this.toscaModelURL = toscaModelURL;
144             return this;
145         }
146
147         public ServiceBuilder setCategory(String category) {
148             this.category = category;
149             return this;
150         }
151
152         public ServiceBuilder setLifecycleState(Service.LifecycleState lifecycleState) {
153             this.lifecycleState = lifecycleState;
154             return this;
155         }
156
157         public ServiceBuilder setDistributionStatus(String distributionStatus) {
158             this.distributionStatus = distributionStatus;
159             return this;
160         }
161
162         public ServiceBuilder setArtifacts(Collection<Artifact> artifacts) {
163             this.artifacts = artifacts;
164             return this;
165         }
166
167         public ServiceBuilder setResources(Collection<SubResource> resources) {
168             this.resources = resources;
169             return this;
170         }
171
172         public Service build() {
173             return new Service(this);
174         }
175     }
176     
177
178     /**
179      * Gets the uuid.
180      *
181      * @return the uuid
182      */
183     public String getUuid() {
184         return uuid;
185     }
186
187     /**
188      * Gets the invariant UUID.
189      *
190      * @return the invariant UUID
191      */
192     public String getInvariantUUID() {
193         return invariantUUID;
194     }
195
196     /**
197      * Gets the name.
198      *
199      * @return the name
200      */
201     public String getName() {
202         return name;
203     }
204
205     /**
206      * Gets the version.
207      *
208      * @return the version
209      */
210     public String getVersion() {
211         return version;
212     }
213
214     /**
215      * Gets the tosca model URL.
216      *
217      * @return the tosca model URL
218      */
219     public String getToscaModelURL() {
220         return toscaModelURL;
221     }
222
223     /**
224      * Gets the category.
225      *
226      * @return the category
227      */
228     public String getCategory() {
229         return category;
230     }
231
232     /**
233      * Gets the lifecycle state.
234      *
235      * @return the lifecycle state
236      */
237     public Service.LifecycleState getLifecycleState() {
238         return lifecycleState;
239     }
240
241     /**
242      * Gets the last updater user uid.
243      *
244      * @return the last updater user uid
245      */
246     public String getLastUpdaterUserId() {
247         return lastUpdaterUserId;
248     }
249
250     /**
251      * Gets the last updater full name.
252      *
253      * @return the last updater full name
254      */
255     public String getLastUpdaterFullName() {
256         return lastUpdaterFullName;
257     }
258
259     /**
260      * Gets the distribution status.
261      *
262      * @return the distribution status
263      */
264     public String getDistributionStatus() {
265         return distributionStatus;
266     }
267
268     /**
269      * Gets the artifacts.
270      *
271      * @return the artifacts
272      */
273     public Collection<Artifact> getArtifacts() {
274         return artifacts;
275     }
276
277     /**
278      * Gets the resources.
279      *
280      * @return the resources
281      */
282     public Collection<SubResource> getResources() {
283         return resources;
284     }
285
286     /**
287      * Sets the uuid.
288      *
289      * @param uuid the new uuid
290      */
291     public void setUuid(String uuid) {
292         this.uuid = uuid;
293     }
294
295     /**
296      * Sets the invariant UUID.
297      *
298      * @param invariantUUID the new invariant UUID
299      */
300     public void setInvariantUUID(String invariantUUID) {
301         this.invariantUUID = invariantUUID;
302     }
303
304     /**
305      * Sets the name.
306      *
307      * @param name the new name
308      */
309     public void setName(String name) {
310         this.name = name;
311     }
312
313     /**
314      * Sets the version.
315      *
316      * @param version the new version
317      */
318     public void setVersion(String version) {
319         this.version = version;
320     }
321
322     /**
323      * Sets the tosca model URL.
324      *
325      * @param toscaModelURL the new tosca model URL
326      */
327     public void setToscaModelURL(String toscaModelURL) {
328         this.toscaModelURL = toscaModelURL;
329     }
330
331     /**
332      * Sets the category.
333      *
334      * @param category the new category
335      */
336     public void setCategory(String category) {
337         this.category = category;
338     }
339
340     /**
341      * Sets the lifecycle state.
342      *
343      * @param lifecycleState the new lifecycle state
344      */
345     public void setLifecycleState(Service.LifecycleState lifecycleState) {
346         this.lifecycleState = lifecycleState;
347     }
348
349     /**
350      * Sets the last updater user uid.
351      *
352      * @param lastUpdaterUserId the new last updater user uid
353      */
354     public void set(String lastUpdaterUserId) {
355         this.lastUpdaterUserId = lastUpdaterUserId;
356     }
357
358     /**
359      * Sets the last updater full name.
360      *
361      * @param lastUpdaterFullName the new last updater full name
362      */
363     public void setLastUpdaterFullName(String lastUpdaterFullName) {
364         this.lastUpdaterFullName = lastUpdaterFullName;
365     }
366
367     /**
368      * Sets the distribution status.
369      *
370      * @param distributionStatus the new distribution status
371      */
372     public void setDistributionStatus(String distributionStatus) {
373         this.distributionStatus = distributionStatus;
374     }
375
376     /**
377      * Sets the artifacts.
378      *
379      * @param artifacts the new artifacts
380      */
381     public void setArtifacts(Collection<Artifact> artifacts) {
382         this.artifacts = artifacts;
383     }
384
385     /**
386      * Sets the resources.
387      *
388      * @param resources the new resources
389      */
390     public void setResources(Collection<SubResource> resources) {
391         this.resources = resources;
392     }
393
394     /*
395      * (non-Javadoc)
396      * 
397      * @see java.lang.Object#toString()
398      */
399     @Override
400     public String toString() {
401         return uuid;
402     }
403
404     /*
405      * (non-Javadoc)
406      * 
407      * @see java.lang.Object#hashCode()
408      */
409     @Override
410     public int hashCode() {
411         return UUID.fromString(getUuid()).hashCode();
412     }
413
414     /*
415      * (non-Javadoc)
416      * 
417      * @see java.lang.Object#equals(java.lang.Object)
418      */
419     @Override
420     public boolean equals(Object o) {
421         if (o == this)
422             return true;
423         if (!(o instanceof Service))
424             return false;
425
426         final Service service = (Service) o;
427
428         return (service.getUuid().equals(getUuid()));
429     }
430
431     public Service() {}
432
433     public Service(ServiceBuilder serviceBuilder) {
434
435         this.uuid = serviceBuilder.uuid;
436         this.invariantUUID = serviceBuilder.invariantUUID;
437         this.name = serviceBuilder.name;
438         this.version = serviceBuilder.version;
439         this.toscaModelURL = serviceBuilder.toscaModelURL;
440         this.category = serviceBuilder.category;
441         this.lifecycleState = serviceBuilder.lifecycleState;
442         this.distributionStatus = serviceBuilder.distributionStatus;
443         this.artifacts = serviceBuilder.artifacts;
444         this.resources = serviceBuilder.resources;
445     }
446 }