aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java
blob: f5dd5d85fb6e1771033653ae06e5e259198cf1b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
/*-
 * ============LICENSE_START=======================================================
 * VID
 * ================================================================================
 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.vid.asdc.beans;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Collection;
import java.util.UUID;

public class Service {

    public enum DistributionStatus {

    DISTRIBUTION_NOT_APPROVED,

    DISTRIBUTION_APPROVED,

    DISTRIBUTED,

    DISTRIBUTION_REJECTED,

    DISTRIBUTION_COMPLETE_OK
    }

    public enum LifecycleState {

        NOT_CERTIFIED_CHECKOUT,

        NOT_CERTIFIED_CHECKIN,

        READY_FOR_CERTIFICATION,

        CERTIFICATION_IN_PROGRESS,

        CERTIFIED
    }

    private String uuid;

    private String invariantUUID;

    private String name;

    private String version;

    private String toscaModelURL;

    private String category;

    private Service.LifecycleState lifecycleState;

    private String lastUpdaterUserId;

    private String lastUpdaterFullName;

    private String distributionStatus;

    private Collection<Artifact> artifacts;

    private Collection<SubResource> resources;

    private String orchestrationType;

    @JsonInclude(NON_NULL)
    private Boolean isInstantiationTemplateExists;
    
    
    public static class ServiceBuilder {
       private String uuid;
       private String invariantUUID;
       private String name;
       private String version;
       private String toscaModelURL;
       private String category;
       private Service.LifecycleState lifecycleState;
       private String distributionStatus;
       private Collection<Artifact> artifacts;
       private Collection<SubResource> resources;
        private String orchestrationType;

        public ServiceBuilder setUuid(String uuid) {
            this.uuid = uuid;
            return this;
        }

        public ServiceBuilder setInvariantUUID(String invariantUUID) {
            this.invariantUUID = invariantUUID;
            return this;
        }

        public ServiceBuilder setName(String name) {
            this.name = name;
            return this;
        }

        public ServiceBuilder setVersion(String version) {
            this.version = version;
            return this;
        }

        public ServiceBuilder setToscaModelURL(String toscaModelURL) {
            this.toscaModelURL = toscaModelURL;
            return this;
        }

        public ServiceBuilder setCategory(String category) {
            this.category = category;
            return this;
        }

        public ServiceBuilder setLifecycleState(Service.LifecycleState lifecycleState) {
            this.lifecycleState = lifecycleState;
            return this;
        }

        public ServiceBuilder setDistributionStatus(String distributionStatus) {
            this.distributionStatus = distributionStatus;
            return this;
        }

        public ServiceBuilder setArtifacts(Collection<Artifact> artifacts) {
            this.artifacts = artifacts;
            return this;
        }

        public ServiceBuilder setResources(Collection<SubResource> resources) {
            this.resources = resources;
            return this;
        }

        public ServiceBuilder setOrchestrationType(String orchestrationType) {
            this.orchestrationType = orchestrationType;
            return this;
        }

        public Service build() {
            return new Service(this);
        }
    }
    

    public String getUuid() {
        return uuid;
    }

    public String getInvariantUUID() {
        return invariantUUID;
    }

    public String getName() {
        return name;
    }

    public String getVersion() {
        return version;
    }

    public String getToscaModelURL() {
        return toscaModelURL;
    }

    public String getCategory() {
        return category;
    }

    public Service.LifecycleState getLifecycleState() {
        return lifecycleState;
    }

    public String getLastUpdaterUserId() {
        return lastUpdaterUserId;
    }

    public String getLastUpdaterFullName() {
        return lastUpdaterFullName;
    }

    public String getDistributionStatus() {
        return distributionStatus;
    }

    public Collection<Artifact> getArtifacts() {
        return artifacts;
    }

    public Collection<SubResource> getResources() {
        return resources;
    }

    public String getOrchestrationType() {
        return orchestrationType;
    }

    public Boolean getIsInstantiationTemplateExists() {
        return isInstantiationTemplateExists;
    }


    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public void setInvariantUUID(String invariantUUID) {
        this.invariantUUID = invariantUUID;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public void setToscaModelURL(String toscaModelURL) {
        this.toscaModelURL = toscaModelURL;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public void setLifecycleState(Service.LifecycleState lifecycleState) {
        this.lifecycleState = lifecycleState;
    }

    public void set(String lastUpdaterUserId) {
        this.lastUpdaterUserId = lastUpdaterUserId;
    }

    public void setLastUpdaterFullName(String lastUpdaterFullName) {
        this.lastUpdaterFullName = lastUpdaterFullName;
    }

    public void setDistributionStatus(String distributionStatus) {
        this.distributionStatus = distributionStatus;
    }

    public void setArtifacts(Collection<Artifact> artifacts) {
        this.artifacts = artifacts;
    }

    public void setResources(Collection<SubResource> resources) {
        this.resources = resources;
    }

    public void setOrchestrationType(String orchestrationType) {
        this.orchestrationType = orchestrationType;
    }

    public void setIsInstantiationTemplateExists(Boolean isInstantiationTemplateExists) {
        this.isInstantiationTemplateExists = isInstantiationTemplateExists;
    }

    @Override
    public String toString() {
        return uuid;
    }

    @Override

    public int hashCode() {
        return UUID.fromString(getUuid()).hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (o == this)
            return true;
        if (!(o instanceof Service))
            return false;

        final Service service = (Service) o;

        return (service.getUuid().equals(getUuid()));
    }

    public Service() {}

    public Service(ServiceBuilder serviceBuilder) {

        this.uuid = serviceBuilder.uuid;
        this.invariantUUID = serviceBuilder.invariantUUID;
        this.name = serviceBuilder.name;
        this.version = serviceBuilder.version;
        this.toscaModelURL = serviceBuilder.toscaModelURL;
        this.category = serviceBuilder.category;
        this.lifecycleState = serviceBuilder.lifecycleState;
        this.distributionStatus = serviceBuilder.distributionStatus;
        this.artifacts = serviceBuilder.artifacts;
        this.resources = serviceBuilder.resources;
        this.orchestrationType = serviceBuilder.orchestrationType;
    }
}