2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.vid.asdc.beans;
23 import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
25 import com.fasterxml.jackson.annotation.JsonInclude;
26 import java.util.Collection;
27 import java.util.UUID;
29 public class Service {
31 public enum DistributionStatus {
33 DISTRIBUTION_NOT_APPROVED,
35 DISTRIBUTION_APPROVED,
39 DISTRIBUTION_REJECTED,
41 DISTRIBUTION_COMPLETE_OK
44 public enum LifecycleState {
46 NOT_CERTIFIED_CHECKOUT,
48 NOT_CERTIFIED_CHECKIN,
50 READY_FOR_CERTIFICATION,
52 CERTIFICATION_IN_PROGRESS,
59 private String invariantUUID;
63 private String version;
65 private String toscaModelURL;
67 private String category;
69 private Service.LifecycleState lifecycleState;
71 private String lastUpdaterUserId;
73 private String lastUpdaterFullName;
75 private String distributionStatus;
77 private Collection<Artifact> artifacts;
79 private Collection<SubResource> resources;
81 private String orchestrationType;
83 @JsonInclude(NON_NULL)
84 private Boolean isInstantiationTemplateExists;
87 public static class ServiceBuilder {
89 private String invariantUUID;
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;
100 public ServiceBuilder setUuid(String uuid) {
105 public ServiceBuilder setInvariantUUID(String invariantUUID) {
106 this.invariantUUID = invariantUUID;
110 public ServiceBuilder setName(String name) {
115 public ServiceBuilder setVersion(String version) {
116 this.version = version;
120 public ServiceBuilder setToscaModelURL(String toscaModelURL) {
121 this.toscaModelURL = toscaModelURL;
125 public ServiceBuilder setCategory(String category) {
126 this.category = category;
130 public ServiceBuilder setLifecycleState(Service.LifecycleState lifecycleState) {
131 this.lifecycleState = lifecycleState;
135 public ServiceBuilder setDistributionStatus(String distributionStatus) {
136 this.distributionStatus = distributionStatus;
140 public ServiceBuilder setArtifacts(Collection<Artifact> artifacts) {
141 this.artifacts = artifacts;
145 public ServiceBuilder setResources(Collection<SubResource> resources) {
146 this.resources = resources;
150 public ServiceBuilder setOrchestrationType(String orchestrationType) {
151 this.orchestrationType = orchestrationType;
155 public Service build() {
156 return new Service(this);
161 public String getUuid() {
165 public String getInvariantUUID() {
166 return invariantUUID;
169 public String getName() {
173 public String getVersion() {
177 public String getToscaModelURL() {
178 return toscaModelURL;
181 public String getCategory() {
185 public Service.LifecycleState getLifecycleState() {
186 return lifecycleState;
189 public String getLastUpdaterUserId() {
190 return lastUpdaterUserId;
193 public String getLastUpdaterFullName() {
194 return lastUpdaterFullName;
197 public String getDistributionStatus() {
198 return distributionStatus;
201 public Collection<Artifact> getArtifacts() {
205 public Collection<SubResource> getResources() {
209 public String getOrchestrationType() {
210 return orchestrationType;
213 public Boolean getIsInstantiationTemplateExists() {
214 return isInstantiationTemplateExists;
218 public void setUuid(String uuid) {
222 public void setInvariantUUID(String invariantUUID) {
223 this.invariantUUID = invariantUUID;
226 public void setName(String name) {
230 public void setVersion(String version) {
231 this.version = version;
234 public void setToscaModelURL(String toscaModelURL) {
235 this.toscaModelURL = toscaModelURL;
238 public void setCategory(String category) {
239 this.category = category;
242 public void setLifecycleState(Service.LifecycleState lifecycleState) {
243 this.lifecycleState = lifecycleState;
246 public void set(String lastUpdaterUserId) {
247 this.lastUpdaterUserId = lastUpdaterUserId;
250 public void setLastUpdaterFullName(String lastUpdaterFullName) {
251 this.lastUpdaterFullName = lastUpdaterFullName;
254 public void setDistributionStatus(String distributionStatus) {
255 this.distributionStatus = distributionStatus;
258 public void setArtifacts(Collection<Artifact> artifacts) {
259 this.artifacts = artifacts;
262 public void setResources(Collection<SubResource> resources) {
263 this.resources = resources;
266 public void setOrchestrationType(String orchestrationType) {
267 this.orchestrationType = orchestrationType;
270 public void setIsInstantiationTemplateExists(Boolean isInstantiationTemplateExists) {
271 this.isInstantiationTemplateExists = isInstantiationTemplateExists;
275 public String toString() {
281 public int hashCode() {
282 return UUID.fromString(getUuid()).hashCode();
286 public boolean equals(Object o) {
289 if (!(o instanceof Service))
292 final Service service = (Service) o;
294 return (service.getUuid().equals(getUuid()));
299 public Service(ServiceBuilder serviceBuilder) {
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;