2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.openecomp.sdc.be.datatypes.elements;
23 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
24 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
25 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
27 import java.util.ArrayList;
28 import java.util.List;
30 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
32 public class ArtifactDataDefinition extends ToscaDataDefinition {
34 public ArtifactDataDefinition() {
35 setArtifactVersion("0");
38 public ArtifactDataDefinition(Map<String, Object> art) {
40 setArtifactVersion("0");
44 public ArtifactDataDefinition(ArtifactDataDefinition a) {
45 this.setUniqueId(a.getUniqueId());
46 this.setArtifactType(a.getArtifactType());
47 this.setArtifactRef(a.getArtifactRef());
48 this.setArtifactName(a.getArtifactName());
49 this.setArtifactRepository(a.getArtifactRepository());
50 this.setArtifactChecksum(a.getArtifactChecksum());
51 this.setUserIdCreator(a.getUserIdCreator());
52 this.setUserIdLastUpdater(a.getUserIdLastUpdater());
53 this.setCreatorFullName(a.getCreatorFullName());
54 this.setUpdaterFullName(a.getUpdaterFullName());
55 this.setCreationDate(a.getCreationDate());
56 this.setLastUpdateDate(a.getLastUpdateDate());
57 this.setDescription(a.getDescription());
58 this.setEsId(a.getEsId());
59 this.setArtifactLabel(a.getArtifactLabel());
60 this.setArtifactCreator(a.getArtifactCreator());
61 this.setMandatory(a.getMandatory());
62 this.setArtifactDisplayName(a.getArtifactDisplayName());
63 this.setApiUrl(a.getApiUrl());
64 this.setServiceApi(a.getServiceApi());
65 this.setArtifactGroupType(a.getArtifactGroupType());
66 this.setTimeout(a.getTimeout());
67 this.setArtifactVersion(a.getArtifactVersion());
68 this.setArtifactUUID(a.getArtifactUUID());
69 this.setPayloadUpdateDate(a.getPayloadUpdateDate());
70 this.setHeatParamsUpdateDate(a.getHeatParamsUpdateDate());
71 this.setGenerated(a.getGenerated());
72 this.setDuplicated(a.getDuplicated());
73 if (a.getRequiredArtifacts() != null) {
74 this.setRequiredArtifacts(new ArrayList<>(a.getRequiredArtifacts()));
76 if (a.getHeatParameters() != null) {
77 this.setHeatParameters(new ArrayList<>(a.getHeatParameters()));
79 this.setGeneratedFromId(a.getGeneratedFromId());
80 this.setIsFromCsar(a.getIsFromCsar());
85 public String getArtifactName() {
86 return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
90 public String getArtifactType() {
91 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE);
94 public boolean isHeatEnvType() {
95 return ArtifactTypeEnum.HEAT_ENV.getType().equals(getArtifactType());
98 public void setArtifactType(String artifactType) {
99 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE, artifactType);
103 public String getArtifactRef() {
104 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_REF);
108 public void setArtifactRef(String artifactRef) {
109 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_REF, artifactRef);
112 public String getArtifactRepository() {
113 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_REPOSITORY);
117 public void setArtifactRepository(String artifactRepository) {
118 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_REPOSITORY, artifactRepository);
121 public void setArtifactName(String artifactName) {
122 setToscaPresentationValue(JsonPresentationFields.NAME, artifactName);
126 public String getArtifactChecksum() {
127 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_CHECKSUM);
130 public void setArtifactChecksum(String artifactChecksum) {
131 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_CHECKSUM, artifactChecksum);
134 public String getUserIdCreator() {
136 return (String) getToscaPresentationValue(JsonPresentationFields.USER_ID_CREATOR);
139 public void setUserIdCreator(String userIdCreator) {
140 setToscaPresentationValue(JsonPresentationFields.USER_ID_CREATOR, userIdCreator);
143 public String getUserIdLastUpdater() {
144 return (String) getToscaPresentationValue(JsonPresentationFields.USER_ID_LAST_UPDATER);
147 public void setUserIdLastUpdater(String userIdLastUpdater) {
148 setToscaPresentationValue(JsonPresentationFields.USER_ID_LAST_UPDATER, userIdLastUpdater);
151 public String getCreatorFullName() {
152 return (String) getToscaPresentationValue(JsonPresentationFields.CREATOR_FULL_NAME);
155 public void setCreatorFullName(String creatorFullName) {
156 setToscaPresentationValue(JsonPresentationFields.CREATOR_FULL_NAME, creatorFullName);
159 public String getUpdaterFullName() {
160 return (String) getToscaPresentationValue(JsonPresentationFields.UPDATER_FULL_NAME);
163 public void setUpdaterFullName(String updaterFullName) {
164 setToscaPresentationValue(JsonPresentationFields.UPDATER_FULL_NAME, updaterFullName);
167 public Long getCreationDate() {
168 return (Long) getToscaPresentationValue(JsonPresentationFields.CREATION_DATE);
171 public void setCreationDate(Long creationDate) {
172 setToscaPresentationValue(JsonPresentationFields.CREATION_DATE, creationDate);
175 public Long getLastUpdateDate() {
176 return (Long) getToscaPresentationValue(JsonPresentationFields.LAST_UPDATE_DATE);
179 public void setLastUpdateDate(Long lastUpdateDate) {
180 setToscaPresentationValue(JsonPresentationFields.LAST_UPDATE_DATE, lastUpdateDate);
183 public String getUniqueId() {
184 return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
187 public void setUniqueId(String uniqueId) {
188 setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
191 public String getDescription() {
192 return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
195 public void setDescription(String description) {
196 setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
199 public String getArtifactLabel() {
200 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_LABEL);
203 public void setArtifactLabel(String artifactLabel) {
204 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_LABEL, artifactLabel);
207 public String getEsId() {
208 return (String) getToscaPresentationValue(JsonPresentationFields.ES_ID);
211 public boolean hasNoMandatoryEsId() {
212 return getEsId() == null && getMandatory();
215 public void setEsId(String esId) {
216 setToscaPresentationValue(JsonPresentationFields.ES_ID, esId);
219 public String getArtifactCreator() {
220 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_CREATOR);
223 public void setArtifactCreator(String artifactCreator) {
224 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_CREATOR, artifactCreator);
227 public Boolean getMandatory() {
228 Boolean isMandatory = (Boolean) getToscaPresentationValue(JsonPresentationFields.IS_ABSTRACT);
229 return isMandatory == null ? Boolean.FALSE : isMandatory;
232 public void setMandatory(Boolean mandatory) {
233 setToscaPresentationValue(JsonPresentationFields.IS_ABSTRACT, mandatory);
236 public String getArtifactDisplayName() {
237 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_DISPLAY_NAME);
240 public void setArtifactDisplayName(String artifactDisplayName) {
241 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_DISPLAY_NAME, artifactDisplayName);
244 public String getApiUrl() {
245 return (String) getToscaPresentationValue(JsonPresentationFields.API_URL);
248 public void setApiUrl(String apiUrl) {
249 setToscaPresentationValue(JsonPresentationFields.API_URL, apiUrl);
252 public Boolean getServiceApi() {
253 Boolean serviceApi = (Boolean) getToscaPresentationValue(JsonPresentationFields.SERVICE_API);
254 return serviceApi == null ? Boolean.FALSE : serviceApi;
257 public void setServiceApi(Boolean serviceApi) {
258 setToscaPresentationValue(JsonPresentationFields.SERVICE_API, serviceApi);
261 public ArtifactGroupTypeEnum getArtifactGroupType() {
262 ArtifactGroupTypeEnum artifactGroupType = null;
263 String groupType = (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_GROUP_TYPE);
264 if (groupType != null && !groupType.isEmpty()) {
265 artifactGroupType = ArtifactGroupTypeEnum.findType(groupType);
267 return artifactGroupType;
270 public void setArtifactGroupType(ArtifactGroupTypeEnum artifactGroupType) {
271 if (artifactGroupType != null) {
272 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_GROUP_TYPE, artifactGroupType.getType());
276 public Integer getTimeout() {
277 return (Integer) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_TIMEOUT);
280 public void setTimeout(Integer timeout) {
281 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_TIMEOUT, timeout);
284 public String getArtifactVersion() {
285 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_VERSION);
288 public void setArtifactVersion(String artifactVersion) {
289 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_VERSION, artifactVersion);
292 public String getArtifactUUID() {
293 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_UUID);
296 public void setArtifactUUID(String artifactUUID) {
297 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_UUID, artifactUUID);
300 public Long getPayloadUpdateDate() {
301 return (Long) getToscaPresentationValue(JsonPresentationFields.PAYLOAD_UPDATE_DATE);
304 public void setPayloadUpdateDate(Long payloadUpdateDate) {
305 setToscaPresentationValue(JsonPresentationFields.PAYLOAD_UPDATE_DATE, payloadUpdateDate);
308 public Long getHeatParamsUpdateDate() {
309 return (Long) getToscaPresentationValue(JsonPresentationFields.HEAT_PARAMS_UPDATE_DATE);
312 public void setHeatParamsUpdateDate(Long heatParamsUpdateDate) {
313 setToscaPresentationValue(JsonPresentationFields.HEAT_PARAMS_UPDATE_DATE, heatParamsUpdateDate);
316 public List<String> getRequiredArtifacts() {
317 return (List<String>) getToscaPresentationValue(JsonPresentationFields.REQUIRED_ARTIFACTS);
320 public void setRequiredArtifacts(List<String> requiredArtifacts) {
321 setToscaPresentationValue(JsonPresentationFields.REQUIRED_ARTIFACTS, requiredArtifacts);
324 public Boolean getGenerated() {
325 Boolean generated = (Boolean) getToscaPresentationValue(JsonPresentationFields.GENERATED);
326 return generated == null ? Boolean.FALSE : generated;
329 public void setGenerated(Boolean generated) {
330 setToscaPresentationValue(JsonPresentationFields.GENERATED, generated);
333 public Boolean getDuplicated() {
334 Boolean duplicated = (Boolean) getToscaPresentationValue(JsonPresentationFields.DUPLICATED);
335 return duplicated == null ? Boolean.FALSE : duplicated;
338 public void setDuplicated(Boolean duplicated) {
339 setToscaPresentationValue(JsonPresentationFields.DUPLICATED, duplicated);
342 public List<HeatParameterDataDefinition> getHeatParameters() {
343 return (List<HeatParameterDataDefinition>) getToscaPresentationValue(JsonPresentationFields.HEAT_PARAMETERS);
346 public void setHeatParameters(List<HeatParameterDataDefinition> properties) {
347 setToscaPresentationValue(JsonPresentationFields.HEAT_PARAMETERS, properties);
350 public String getGeneratedFromId() {
351 return (String) getToscaPresentationValue(JsonPresentationFields.GENERATED_FROM_ID);
354 public boolean getIsFromCsar() {
355 Boolean isFromCsar = (Boolean) getToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR);
356 return isFromCsar == null ? Boolean.FALSE : isFromCsar;
359 public void setIsFromCsar(Boolean isFromCsar) {
360 setToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR, isFromCsar);
363 public void setGeneratedFromId(String generatedFromId) {
364 setToscaPresentationValue(JsonPresentationFields.GENERATED_FROM_ID, generatedFromId);
369 public String toString() {
370 return "ArtifactDataDefinition [uniqueId=" + getUniqueId() + ", artifactType=" + getArtifactType() + ", artifactRef=" + getArtifactRef() + ", artifactName=" + getArtifactName() + ", artifactRepository=" + getArtifactRepository() + ", artifactChecksum="
371 + getArtifactChecksum() + ", userIdCreator=" + getUserIdCreator() + ", userIdLastUpdater=" + getUserIdLastUpdater() + ", creatorFullName=" + getCreatorFullName() + ", updaterFullName=" + getUpdaterFullName() + ", creationDate=" + getCreationDate()
372 + ", lastUpdateDate=" + getLastUpdateDate() + ", esId=" + getEsId() + ", artifactLabel=" + getArtifactLabel() + ", artifactCreator=" + getArtifactCreator() + ", description=" + getDescription() + ", mandatory=" + getMandatory() + ", artifactDisplayName="
373 + getArtifactDisplayName() + ", apiUrl=" + getApiUrl() + ", serviceApi=" + getServiceApi() + ", artifactGroupType=" + getArtifactGroupType() + ", timeout=" + getTimeout() + ", artifactVersion=" + getArtifactVersion() + ", artifactUUID=" + getArtifactUUID()
374 + ", payloadUpdateDate=" + getPayloadUpdateDate() + ", heatParamsUpdateDate=" + getHeatParamsUpdateDate() + ", requiredArtifacts=" + getRequiredArtifacts() + "]";
378 public int hashCode() {
379 final int prime = 31;
382 String apiUrl = getApiUrl();
383 String artifactChecksum = getArtifactChecksum();
384 String artifactCreator = getArtifactCreator();
385 String artifactDisplayName = getArtifactDisplayName();
386 ArtifactGroupTypeEnum artifactGroupType = getArtifactGroupType();
387 String artifactLabel = getArtifactLabel();
388 String artifactName = getArtifactName();
389 String artifactRef = getArtifactRef();
390 String artifactRepository = getArtifactRepository();
391 String artifactType = getArtifactType();
393 String artifactUUID = getArtifactUUID();
394 String artifactVersion = getArtifactVersion();
395 String userIdCreator = getUserIdCreator();
396 String userIdLastUpdater = getUserIdLastUpdater();
397 Long creationDate = getCreationDate();
399 String creatorFullName = getCreatorFullName();
400 String description = getDescription();
401 String esId = getEsId();
402 Long heatParamsUpdateDate = getHeatParamsUpdateDate();
403 Long lastUpdateDate = getLastUpdateDate();
404 Boolean mandatory = getMandatory();
406 Long payloadUpdateDate = getPayloadUpdateDate();
407 List<String> requiredArtifacts = getRequiredArtifacts();
408 Boolean serviceApi = getServiceApi();
409 Integer timeout = getTimeout();
410 String uniqueId = getUniqueId();
411 String updaterFullName = getUpdaterFullName();
413 result = prime * result + ((apiUrl == null) ? 0 : apiUrl.hashCode());
414 result = prime * result + ((artifactChecksum == null) ? 0 : artifactChecksum.hashCode());
415 result = prime * result + ((artifactCreator == null) ? 0 : artifactCreator.hashCode());
416 result = prime * result + ((artifactDisplayName == null) ? 0 : artifactDisplayName.hashCode());
417 result = prime * result + ((artifactGroupType == null) ? 0 : artifactGroupType.hashCode());
418 result = prime * result + ((artifactLabel == null) ? 0 : artifactLabel.hashCode());
419 result = prime * result + ((artifactName == null) ? 0 : artifactName.hashCode());
420 result = prime * result + ((artifactRef == null) ? 0 : artifactRef.hashCode());
421 result = prime * result + ((artifactRepository == null) ? 0 : artifactRepository.hashCode());
422 result = prime * result + ((artifactType == null) ? 0 : artifactType.hashCode());
423 result = prime * result + ((artifactUUID == null) ? 0 : artifactUUID.hashCode());
424 result = prime * result + ((artifactVersion == null) ? 0 : artifactVersion.hashCode());
425 result = prime * result + ((userIdCreator == null) ? 0 : userIdCreator.hashCode());
426 result = prime * result + ((userIdLastUpdater == null) ? 0 : userIdLastUpdater.hashCode());
427 result = prime * result + ((creationDate == null) ? 0 : creationDate.hashCode());
428 result = prime * result + ((creatorFullName == null) ? 0 : creatorFullName.hashCode());
429 result = prime * result + ((description == null) ? 0 : description.hashCode());
430 result = prime * result + ((esId == null) ? 0 : esId.hashCode());
431 result = prime * result + ((heatParamsUpdateDate == null) ? 0 : heatParamsUpdateDate.hashCode());
432 result = prime * result + ((lastUpdateDate == null) ? 0 : lastUpdateDate.hashCode());
433 result = prime * result + ((mandatory == null) ? 0 : mandatory.hashCode());
434 result = prime * result + ((payloadUpdateDate == null) ? 0 : payloadUpdateDate.hashCode());
435 result = prime * result + ((requiredArtifacts == null) ? 0 : requiredArtifacts.hashCode());
436 result = prime * result + ((serviceApi == null) ? 0 : serviceApi.hashCode());
437 result = prime * result + ((timeout == null) ? 0 : timeout.hashCode());
438 result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
439 result = prime * result + ((updaterFullName == null) ? 0 : updaterFullName.hashCode());
444 public boolean equals(Object obj) {
451 if (getClass() != obj.getClass()) {
454 ArtifactDataDefinition other = (ArtifactDataDefinition) obj;
455 if (getApiUrl() == null) {
456 if (other.getApiUrl() != null) {
459 } else if (!getArtifactRepository().equals(other.getArtifactRepository())) {
462 if (getArtifactType() == null) {
463 if (other.getArtifactType() != null) {
466 } else if (!getArtifactType().equals(other.getArtifactType())) {
469 if (getArtifactUUID() == null) {
470 if (other.getArtifactUUID() != null) {
473 } else if (!getArtifactUUID().equals(other.getArtifactUUID())) {
476 if (getArtifactVersion() == null) {
477 if (other.getArtifactVersion() != null) {
480 } else if (!getArtifactVersion().equals(other.getArtifactVersion())) {
483 if (getUserIdCreator() == null) {
484 if (other.getUserIdCreator() != null) {
487 } else if (!getUserIdCreator().equals(other.getUserIdCreator())) {
490 if (getUserIdLastUpdater() == null) {
491 if (other.getUserIdLastUpdater() != null) {
494 } else if (!getUserIdLastUpdater().equals(other.getUserIdLastUpdater())) {
497 if (getCreationDate() == null) {
498 if (other.getCreationDate() != null) {
501 } else if (!getCreationDate().equals(other.getCreationDate())) {
504 if (getCreatorFullName() == null) {
505 if (other.getCreatorFullName() != null) {
508 } else if (!getCreatorFullName().equals(other.getCreatorFullName())) {
511 if (getDescription() == null) {
512 if (other.getDescription() != null) {
515 } else if (!getDescription().equals(other.getDescription())) {
518 if (getEsId() == null) {
519 if (other.getEsId() != null) {
522 } else if (!getEsId().equals(other.getEsId())) {
525 if (getHeatParamsUpdateDate() == null) {
526 if (other.getHeatParamsUpdateDate() != null) {
529 } else if (!getHeatParamsUpdateDate().equals(other.getHeatParamsUpdateDate())) {
532 if (getLastUpdateDate() == null) {
533 if (other.getLastUpdateDate() != null) {
536 } else if (!getLastUpdateDate().equals(other.getLastUpdateDate())) {
539 if (getMandatory() == null) {
540 if (other.getMandatory() != null) {
543 } else if (!getMandatory().equals(other.getMandatory())) {
546 if (getPayloadUpdateDate() == null) {
547 if (other.getPayloadUpdateDate() != null) {
550 } else if (!getPayloadUpdateDate().equals(other.getPayloadUpdateDate())) {
553 if (getRequiredArtifacts() == null) {
554 if (other.getRequiredArtifacts() != null) {
557 } else if (!getRequiredArtifacts().equals(other.getRequiredArtifacts())) {
560 if (getServiceApi() == null) {
561 if (other.getServiceApi() != null) {
564 } else if (!getServiceApi().equals(other.getServiceApi())) {
567 if (getTimeout() == null) {
568 if (other.getTimeout() != null) {
571 } else if (!getTimeout().equals(other.getTimeout())) {
574 if (getUniqueId() == null) {
575 if (other.getUniqueId() != null) {
578 } else if (!getUniqueId().equals(other.getUniqueId())) {
581 if (getUpdaterFullName() == null) {
582 if (other.getUpdaterFullName() != null) {
585 } else if (!getUpdaterFullName().equals(other.getUpdaterFullName())) {